AICredits logo
Getting Started

API Reference

Public developer API reference for AICredits endpoints — chat completions, responses, images, audio, embeddings, models, credits, and health checks.

Use this page with an AI assistant

Opens a new chat with this docs URL and the correct AICredits base URLs.

Base URL: https://api.aicredits.in

LLM endpoints use the /v1/ prefix and are OpenAI-compatible. Public platform metadata endpoints use /api/.


Endpoint Matrix

AreaMethodPathAuthNotes
ChatPOST/v1/chat/completionsAPI keyOpenAI-compatible chat completions, including streaming and tools
ResponsesPOST/v1/responsesAPI keyOpenAI-compatible responses endpoint where supported
ImagesPOST/v1/images/generationsAPI keyText-to-image generation
AudioPOST/v1/audio/speechAPI keyText-to-speech generation
AudioPOST/v1/audio/transcriptionsAPI keySpeech-to-text transcription
EmbeddingsPOST/v1/embeddingsAPI keyVector embeddings
CreditsGET/v1/creditsAPI keyCurrent API-key wallet balance
ModelsGET/api/modelsPublicPublic model catalog
HealthGET/healthPublicBasic service health
HealthGET/health/readyPublicDependency readiness

Authentication

All endpoints except GET /api/models and GET /health require a Bearer token:

Authorization: Bearer sk-your-key-here

API keys are created in Dashboard → API Keys. Keys follow the format sk-{64 hex chars}.

Dashboard session APIs are intentionally not part of the public developer API contract. Use the dashboard UI for sign-in, wallet top-ups, billing history, and API-key management.


Chat Completions

POST /v1/chat/completions

The core LLM proxy endpoint. OpenAI-compatible — works with any OpenAI SDK.

Request body:

FieldTypeRequiredDescription
modelstringYesModel ID, e.g. openai/gpt-4o-mini or anthropic/claude-sonnet-4.6
messagesarrayYesArray of {role, content} objects
streambooleanNoEnable SSE streaming (default: false)
temperaturenumberNo0–2, controls randomness
max_tokensintegerNoMaximum tokens to generate
response_formatobjectNo{"type": "json_object"} for JSON mode
toolsarrayNoFunction definitions for tool calling
tool_choicestring/objectNo"auto", "none", "required", or specific tool
cachebooleanNoEnable prompt caching for Claude models
no_cachebooleanNoBypass semantic cache for this request
from openai import OpenAI

client = OpenAI(
    base_url="https://api.aicredits.in/v1",
    api_key="sk-your-key-here",
)

response = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"},
    ],
)

print(response.choices[0].message.content)
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.aicredits.in/v1",
  apiKey: "sk-your-key-here",
});

const response = await client.chat.completions.create({
  model: "openai/gpt-4o-mini",
  messages: [{ role: "user", content: "Hello!" }],
});

console.log(response.choices[0].message.content);
curl https://api.aicredits.in/v1/chat/completions \
  -H "Authorization: Bearer sk-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Response:

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1709123456,
  "model": "gpt-4o-mini",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "Hello! How can I help you?" },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 19,
    "completion_tokens": 9,
    "total_tokens": 28
  }
}

Image Generation

POST /v1/images/generations

Generate images from text prompts. Compatible with the OpenAI Images API.

Request body:

FieldTypeRequiredDescription
modelstringNodall-e-3 (default) or dall-e-2
promptstringYesText description (max 4000 chars for DALL-E 3)
nintegerNoNumber of images (DALL-E 3: max 1)
sizestringNo1024x1024, 1792x1024, or 1024x1792
qualitystringNostandard or hd
response_formatstringNourl (default) or b64_json
curl https://api.aicredits.in/v1/images/generations \
  -H "Authorization: Bearer sk-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dall-e-3",
    "prompt": "A serene view of the Himalayas at sunrise",
    "size": "1024x1024"
  }'

Text-to-Speech

POST /v1/audio/speech

Convert text to speech. Returns raw audio bytes.

Request body:

FieldTypeRequiredDescription
modelstringYesopenai/tts-1, openai/tts-1-hd, or sarvam/bulbul-v2
inputstringYesText to synthesize (max 4096 chars)
voicestringYesalloy, echo, fable, onyx, nova, shimmer
response_formatstringNomp3 (default), opus, aac, flac

Transcription

POST /v1/audio/transcriptions

Transcribe audio to text.

Request body:

FieldTypeRequiredDescription
modelstringYesopenai/whisper-1 or sarvam/saarika-v2
input_audio.datastringYesBase64-encoded audio
input_audio.formatstringYesmp3, wav, m4a, webm, etc.
languagestringNoISO-639-1 code, auto-detected if omitted

Embeddings

POST /v1/embeddings

Generate vector embeddings for text.

Request body:

FieldTypeRequiredDescription
modelstringYese.g. openai/text-embedding-3-small
inputstring or arrayYesText(s) to embed
curl https://api.aicredits.in/v1/embeddings \
  -H "Authorization: Bearer sk-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/text-embedding-3-small",
    "input": "The quick brown fox"
  }'

Models

GET /api/models

List all available models. No authentication required.

curl https://api.aicredits.in/api/models

Response:

{
  "object": "list",
  "data": [
    {
      "id": "openai/gpt-4o-mini",
      "name": "GPT-4o Mini",
      "provider": "openai",
      "context_window": 128000,
      "input_cost_per_1m": 0.15,
      "output_cost_per_1m": 0.60
    }
  ]
}

Health

GET /health

Returns {"status": "ok"}. No authentication required. Used for uptime monitoring.

GET /health/ready

Returns {"status": "ready", "db": "ok", "redis": "ok"} when all dependencies are healthy.


Error Format

All errors follow the same structure:

{
  "error": {
    "message": "Human-readable description",
    "type": "error_type",
    "code": 400
  }
}

See Error Handling → for the full error code reference and retry guidance.

The credit balance check (GET /v1/credits) returns your current API-key wallet balance in INR with Bearer token authentication.

On this page