Shreyansh Cloud API Documentation

Introduction

Welcome to the Shreyansh Cloud API documentation. Our platform provides powerful AI capabilities through a simple, intuitive API. Whether you're building a chatbot, analyzing text, or generating content, our API can help you integrate advanced AI features into your applications.

The Shreyansh Cloud API is organized around REST principles. It accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes to indicate the success or failure of API requests.

Note: This documentation is regularly updated as we improve and expand our API. Make sure to check back for the latest information and features.

Quick Start Guide

Getting started with Shreyansh Cloud is easy. Follow these steps to begin integrating our AI capabilities into your applications:

  1. Sign up for an account - Visit chat.shreyansh.cloud/signup to create your account.
  2. Get your API key - Once signed in, navigate to the API section in your dashboard to generate an API key.
  3. Make your first API call - Use our code examples below to make your first API call and start exploring our capabilities.

Installation

Install our official client library for your preferred programming language:

JavaScript/Node.js
npm install @shreyansh-cloud/sdk
Python
pip install shreyansh-cloud

Chat API Overview

The Chat API allows you to create interactive conversational experiences using our advanced language models. You can create chat completions, which are conversations between a user and our AI.

Base URL

All API requests should be made to the following base URL:

https://api.shreyansh.cloud/v1

Endpoints

POST /chat/completions

Creates a model response for the given conversation.

GET /models

Lists the currently available models.

Authentication

To authenticate API requests, you need to include your API key in the Authorization header:

HTTP Header
Authorization: Bearer YOUR_API_KEY

Important: Keep your API keys secure and never expose them in client-side code. Always call the API from your server where you can safely store your API key.

Code Examples

Here are some examples to help you get started with our Chat API:

Example: Simple Chat Completion

JavaScript
import { ShreyAnshAI } from '@shreyansh-cloud/sdk';

const shreyansh = new ShreyAnshAI('YOUR_API_KEY');

async function generateResponse() {
  const response = await shreyansh.chat.completions.create({
    model: 'shreyansh-1',
    messages: [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: 'Tell me about artificial intelligence.' }
    ],
    temperature: 0.7
  });

  console.log(response.choices[0].message.content);
}

generateResponse();

Example: Streaming Response

Python
import shreyansh_cloud

# Initialize the client
client = shreyansh_cloud.ShreyAnshAI(api_key="YOUR_API_KEY")

# Create a streaming chat completion
response = client.chat.completions.create(
    model="shreyansh-1",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain quantum computing in simple terms."}
    ],
    stream=True
)

# Process the streaming response
for chunk in response:
    if chunk.choices[0].delta.content is not None:
        print(chunk.choices[0].delta.content, end="")

Handling Conversations

To maintain a conversation, include the entire conversation history in your API calls:

JavaScript
const conversation = [
  { role: 'system', content: 'You are a helpful assistant.' },
  { role: 'user', content: 'Hello, how are you?' },
  { role: 'assistant', content: 'I\'m doing well, thank you! How can I help you today?' },
  { role: 'user', content: 'Tell me about machine learning.' }
];

async function continueConversation() {
  const response = await shreyansh.chat.completions.create({
    model: 'shreyansh-1',
    messages: conversation,
    temperature: 0.7
  });

  const assistantResponse = response.choices[0].message;
  
  // Add the assistant's response to the conversation
  conversation.push(assistantResponse);
  
  console.log(assistantResponse.content);
}

continueConversation();