Skip to content

Chat / LLM

FOTOhub provides two chat completion endpoints supporting multiple LLM providers. The OpenAI-compatible endpoint follows the standard OpenAI chat completions format, making it a drop-in replacement for existing integrations. The Bedrock-native endpoint provides access to AWS Bedrock models with token-based billing for precise cost control.

Both endpoints support streaming via Server-Sent Events, multi-turn conversations, system prompts, and return detailed billing information in every response.

OpenAI SDK Compatible

The /v1/ai/chat/completions endpoint is fully compatible with the OpenAI Python and TypeScript SDKs. Simply change the base URL to https://apis.fotohub.app/v1/ai and use your FOTOhub API key.


OpenAI-Compatible Chat Completions

POST /v1/ai/chat/completions

Auth: API Key (Bearer token) | Billing: 1-2 credits per request

Standard chat completions endpoint compatible with OpenAI SDKs. Supports Google Gemini, OpenAI GPT, and Anthropic Claude models with credit-based billing.

Parameters

ParameterTypeRequiredDefaultDescription
modelstringNogemini-flashModel ID to use for completion. See pricing table below for available models.
messagesarrayYes--Array of message objects. Each message has a role (system, user, or assistant) and content (string). System messages set behavior, user messages are inputs, assistant messages are for multi-turn context.
temperaturenumberNo0.7Controls randomness/creativity of the output. Range 0-2. Lower values (0.1-0.3) produce focused, deterministic output. Higher values (1.0-2.0) produce more creative, varied responses.
max_tokensintegerNo2048Maximum number of tokens to generate in the response. Limits output length. Does not guarantee exact length -- model may stop earlier at a natural completion point.
streambooleanNofalseEnable Server-Sent Events streaming. When true, partial message deltas are sent as they become available. See Streaming section below for parsing details.

Available Models

FOTOhub supports 35+ LLM models from 12 providers. All accessible through the same /v1/ai/chat/completions endpoint.

FOTOhub

ModelIDDescription
FOTOhub AIfotohub-aiDefault model — fast, capable, balanced
FOTOhub Coderfotohub-coderOptimized for code generation

Anthropic Claude

ModelIDDescription
Claude Haiku 4.5claude-haiku-4-5Fast, cheap — good for simple tasks
Claude Sonnet 4.6claude-sonnet-4-6Intelligent + fast — best value
Claude Opus 4.5claude-opus-4-5Deep thinking, extended reasoning
Claude Opus 4.6claude-opus-4-6Maximum capabilities — latest

OpenAI

ModelIDDescription
GPT-5.4gpt-5.4Newest, fast, multimodal, versatile
GPT-5.4 Progpt-5.4-proPremium deep reasoning, complex analysis
GPT-5.1gpt-5.1Creative, multi-modal

xAI Grok

ModelIDDescription
Grok 4 Fastgrok-4-fast-reasoningFast reasoning, 2M context
Grok 4.1 Fastgrok-4-1-fast-reasoningLatest reasoning, 2M context
Grok 4.1 Fast NRgrok-4-1-fast-non-reasoningNo reasoning overhead

DeepSeek

ModelIDDescriptionTier
DeepSeek V3.2deepseek-v3.2Fast, cheap, general purpose (Bedrock native)Free
DeepSeek V4 Flashdeepseek-v4-flash-260425Fast reasoning, efficientStarter
DeepSeek V4 Prodeepseek-v4-pro-260425Deep reasoning, math, codeMedium
DeepSeek R1deepseek-r1Chain-of-thought reasoning specialistStarter

Alibaba Qwen

ModelIDDescriptionTier
Qwen Flashqwen-flashEfficient, cheapest QwenFree
Qwen Plusqwen-plusReasoning-focused, generalFree
Qwen 3 Maxqwen3-maxMaximum capabilities, multilingualMedium
Qwen3 Next 80Bqwen3-next-80bMoE 80B, strong reasoning, multilingualStarter
Qwen3 Coderqwen3-coderCode specialist MoE, generation + reviewStarter

Moonshot Kimi

ModelIDDescriptionTier
Kimi K2.5kimi-k2.5Latest, intelligent, 1M contextStarter
Kimi K2 Thinkingkimi-k2-thinkingDeep reasoning, 1M context, chain-of-thoughtMedium

Amazon Nova

ModelIDDescriptionTier
Nova Micronova-microUltra fast, text-only, classificationFree
Nova Litenova-liteFast, vision, budgetFree
Nova 2 Litenova-2-liteNew gen, fast, visionFree
Nova Pronova-proBalanced, vision, reasoningStarter

Mistral AI

ModelIDDescriptionTier
Mistral Large 3mistral-large-3675B params, vision, max capabilitiesMedium
Devstral 2devstral-2123B code specialist, software engineeringStarter
Magistral Smallmagistral-smallReasoning specialist, vision, extended thinkingStarter

NVIDIA

ModelIDDescriptionTier
Nemotron 120Bnemotron-120bMoE (12B active), fast reasoning, cheapStarter

OpenAI (Bedrock)

ModelIDDescriptionTier
GPT-OSS 120Bgpt-oss-120bOpen-source 120B, general purposeStarter

MiniMax

ModelIDDescriptionTier
MiniMax M2.5minimax-m2.5Reasoning, creative, good valueStarter

Z.AI

ModelIDDescriptionTier
GLM 5glm-5Intelligent, balancedStarter
GLM 4.7glm-4.7Budget, fast, multilingualFree

Model Selection Guide

  • Free & ultra-cheap: fotohub-ai, nova-micro, deepseek-v3.2, glm-4.7, qwen-flash
  • Best balance: claude-sonnet-4-6, qwen3-next-80b, nemotron-120b, devstral-2
  • Maximum quality: claude-opus-4-6, gpt-5.4-pro, gpt-5.4, mistral-large-3, grok-4-1-fast-reasoning
  • Reasoning/thinking: deepseek-r1, kimi-k2-thinking, magistral-small, qwen3-next-80b, claude-opus-4-5
  • Code generation: fotohub-coder, devstral-2, qwen3-coder, claude-sonnet-4-6
  • Long context (1M+): kimi-k2.5, kimi-k2-thinking, grok-4-fast-reasoning

Response

json
{
  "id": "chatcmpl-fh-abc123",
  "object": "chat.completion",
  "created": 1719849600,
  "model": "gemini-flash",
  "credits_used": 1,
  "billing": {
    "method": "credits",
    "credits_used": 1,
    "pln_charged": 0.0375
  },
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The Eiffel Tower is a wrought-iron lattice tower located on the Champ de Mars in Paris, France. It was constructed from 1887 to 1889 as the centerpiece of the 1889 World's Fair."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 150,
    "total_tokens": 175
  }
}

Bedrock-Native Chat (Token-Based Billing)

POST /v1/ai/chat/bedrock

Auth: API Key (Bearer token) | Billing: token-based (per-token pricing)

Direct access to AWS Bedrock models including Claude (Anthropic) and Nova (Amazon) families. Uses precise token-based billing with per-token cost breakdowns.

Parameters

ParameterTypeRequiredDefaultDescription
modelstringYes--Bedrock model ID. Must be one of the supported models listed in the pricing table below. No default -- model must be explicitly specified.
messagesarrayYes--Array of message objects with role (user or assistant) and content (string). Note: system messages are passed via the separate system parameter for Bedrock models.
temperaturenumberNo0.7Controls randomness. Range 0-1 for Claude models, 0-2 for Nova models. Lower = more deterministic.
max_tokensintegerNo4096Maximum tokens to generate. Claude models support up to 8192. Nova models support up to 4096.
systemstringNo--System prompt that defines the assistant's behavior and persona. Passed separately from messages for Bedrock's native format. Supports multi-paragraph instructions.
streambooleanNofalseEnable SSE streaming for real-time token delivery. Same format as the OpenAI-compatible endpoint.

Bedrock Models (Token-Based Pricing)

All models below run natively on AWS Bedrock with per-token PLN billing. Prices shown are blended average (input + output).

Anthropic Claude

ModelIDInput ($/1M)Output ($/1M)CreditsFeatures
Claude Sonnet 4.6claude-sonnet-4-6$3$152Vision, 200K ctx, tool-use
Claude Opus 4.6claude-opus-4-6$15$755Vision, 200K ctx, deepest thinking
Claude Opus 4.5claude-opus-4-5$15$755Vision, 200K ctx, extended reasoning
Claude Haiku 4.5claude-haiku-4-5$1$51Vision, 200K ctx, fastest

Amazon Nova

ModelIDInput ($/1M)Output ($/1M)CreditsFeatures
Nova Pronova-pro$0.80$3.200.5Vision, reasoning
Nova Litenova-lite$0.06$0.240.01Vision, fast
Nova 2 Litenova-2-lite$0.04$0.160.01Vision, new gen
Nova Micronova-micro$0.035$0.140.01Text-only, cheapest

DeepSeek (Bedrock)

ModelIDInput ($/1M)Output ($/1M)CreditsFeatures
DeepSeek V3.2deepseek-v3.2$0.28$1.120.5128K ctx, general
DeepSeek R1deepseek-r1$0.45$1.801Reasoning, CoT

Mistral AI (Bedrock)

ModelIDInput ($/1M)Output ($/1M)CreditsFeatures
Mistral Large 3mistral-large-3$2.00$6.002675B, vision
Devstral 2devstral-2$0.20$0.801.5123B, code specialist
Magistral Smallmagistral-small$0.20$0.601Reasoning, vision

Qwen (Bedrock)

ModelIDInput ($/1M)Output ($/1M)CreditsFeatures
Qwen3 Next 80Bqwen3-next-80b$0.20$0.601MoE, reasoning
Qwen3 Coderqwen3-coder$0.12$0.321Code specialist

NVIDIA (Bedrock)

ModelIDInput ($/1M)Output ($/1M)CreditsFeatures
Nemotron 120Bnemotron-120b$0.19$0.480.8MoE 12B active, fast

Moonshot (Bedrock)

ModelIDInput ($/1M)Output ($/1M)CreditsFeatures
Kimi K2 Thinkingkimi-k2-thinking$0.20$0.8021M ctx, reasoning
Kimi K2.5kimi-k2.5$0.60$2.5011M ctx, vision

OpenAI (Bedrock)

ModelIDInput ($/1M)Output ($/1M)CreditsFeatures
GPT-OSS 120Bgpt-oss-120b$0.20$0.601.5Open-source, general

MiniMax (Bedrock)

ModelIDInput ($/1M)Output ($/1M)CreditsFeatures
MiniMax M2.5minimax-m2.5$1.00$4.001Reasoning, creative

Z.AI (Bedrock)

ModelIDInput ($/1M)Output ($/1M)CreditsFeatures
GLM 5glm-5$0.40$1.601Multilingual
GLM 4.7glm-4.7$0.08$0.200.3Budget, fast

Token-Based Billing

Bedrock models use token-based billing, meaning costs are calculated per-token after generation completes. The billing.cost_breakdown field in the response provides exact input/output token counts and the resulting PLN charge. Credits are also deducted as a minimum charge per request.

Response

json
{
  "id": "chatcmpl-bedrock-xyz789",
  "object": "chat.completion",
  "created": 1719849600,
  "model": "claude-sonnet-4.6",
  "billing": {
    "method": "tokens",
    "credits_used": 2,
    "pln_charged": 0.0945,
    "cost_breakdown": {
      "input_tokens": 150,
      "output_tokens": 500,
      "total_tokens": 650,
      "cost_pln": 0.0945
    }
  },
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here is a detailed analysis of the architectural patterns used in your codebase..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "input_tokens": 150,
    "output_tokens": 500,
    "total_tokens": 650
  }
}

Streaming

Both endpoints support streaming via Server-Sent Events (SSE). Set stream: true in your request to receive partial responses as they are generated. Each chunk contains a delta with the new content fragment. The stream ends with a [DONE] message.

SSE Format

Each event is prefixed with data: followed by a JSON object. The final event is data: [DONE]. Events are separated by two newlines. The billing field is included only in the final chunk before [DONE].

Stream Chunk Format

data: {"id":"chatcmpl-fh-abc123","object":"chat.completion.chunk","model":"gemini-flash","choices":[{"index":0,"delta":{"role":"assistant","content":"The"},"finish_reason":null}]}

data: {"id":"chatcmpl-fh-abc123","object":"chat.completion.chunk","model":"gemini-flash","choices":[{"index":0,"delta":{"content":" Eiffel"},"finish_reason":null}]}

data: {"id":"chatcmpl-fh-abc123","object":"chat.completion.chunk","model":"gemini-flash","choices":[{"index":0,"delta":{"content":" Tower"},"finish_reason":null}]}

data: {"id":"chatcmpl-fh-abc123","object":"chat.completion.chunk","model":"gemini-flash","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"billing":{"method":"credits","credits_used":1,"pln_charged":0.0375},"usage":{"prompt_tokens":25,"completion_tokens":48,"total_tokens":73}}

data: [DONE]

Streaming Example -- SSE Parsing

python
import requests
import json

url = "https://apis.fotohub.app/v1/ai/chat/completions"
headers = {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
}
payload = {
    "model": "gemini-flash",
    "messages": [{"role": "user", "content": "Explain quantum computing"}],
    "stream": True
}

response = requests.post(url, json=payload, headers=headers, stream=True)

full_content = ""
for line in response.iter_lines():
    if line:
        line = line.decode("utf-8")
        if line.startswith("data: "):
            data = line[6:]  # Remove "data: " prefix
            if data == "[DONE]":
                break
            chunk = json.loads(data)
            delta = chunk["choices"][0]["delta"]
            if "content" in delta:
                full_content += delta["content"]
                print(delta["content"], end="", flush=True)

print()  # Final newline
print(f"Total: {full_content}")
typescript
const response = await fetch("https://apis.fotohub.app/v1/ai/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "gemini-flash",
    messages: [{ role: "user", content: "Explain quantum computing" }],
    stream: true,
  }),
});

const reader = response.body!.getReader();
const decoder = new TextDecoder();
let fullContent = "";

while (true) {
  const { done, value } = await reader.read();
  if (done) break;

  const text = decoder.decode(value, { stream: true });
  const lines = text.split("\n");

  for (const line of lines) {
    if (line.startsWith("data: ")) {
      const data = line.slice(6);
      if (data === "[DONE]") break;

      const chunk = JSON.parse(data);
      const content = chunk.choices[0]?.delta?.content;
      if (content) {
        fullContent += content;
        process.stdout.write(content);
      }
    }
  }
}
bash
curl -X POST "https://apis.fotohub.app/v1/ai/chat/completions" \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -N \
  -d '{
    "model": "gemini-flash",
    "messages": [
      {"role": "user", "content": "Explain quantum computing"}
    ],
    "stream": true
  }'

Token Counting & Billing

Tokens are the fundamental unit of text processing for LLMs. A token is approximately 4 characters or 0.75 words in English. Both input (prompt) and output (completion) tokens are counted toward billing.

Credit-Based (OpenAI-Compatible Endpoint)

  • Fixed credit cost per request (1-2 credits)
  • PLN charge calculated from total tokens used
  • Credits deducted immediately on request start
  • If generation fails, credits are refunded
  • Token counts included in response for transparency

Token-Based (Bedrock Endpoint)

  • Per-token pricing (input + output separately)
  • Input tokens typically cheaper than output tokens
  • Exact cost shown in the cost_breakdown field
  • Minimum credit charge applies per request
  • Cost = (input_tokens x input_rate) + (output_tokens x output_rate)

Estimating Costs

A typical conversational exchange (100-word prompt, 200-word response) uses approximately 75 input tokens + 150 output tokens = 225 total tokens. With gemini-flash, this costs approximately 0.0001 PLN. With claude-sonnet-4.6 on Bedrock, approximately 0.012 PLN.


Code Examples

Basic Chat Completion

python
import requests

url = "https://apis.fotohub.app/v1/ai/chat/completions"
headers = {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
}

response = requests.post(url, json={
    "model": "gemini-flash",
    "messages": [
        {"role": "user", "content": "What is the capital of France?"}
    ],
    "temperature": 0.3,
    "max_tokens": 256
}, headers=headers)

data = response.json()
print(data["choices"][0]["message"]["content"])
print(f"Tokens used: {data['usage']['total_tokens']}")
print(f"Credits used: {data['credits_used']}")
typescript
const response = await fetch("https://apis.fotohub.app/v1/ai/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "gemini-flash",
    messages: [
      { role: "user", content: "What is the capital of France?" }
    ],
    temperature: 0.3,
    max_tokens: 256,
  }),
});

const data = await response.json();
console.log(data.choices[0].message.content);
console.log(`Tokens used: ${data.usage.total_tokens}`);
console.log(`Credits used: ${data.credits_used}`);
bash
curl -X POST "https://apis.fotohub.app/v1/ai/chat/completions" \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-flash",
    "messages": [
      {"role": "user", "content": "What is the capital of France?"}
    ],
    "temperature": 0.3,
    "max_tokens": 256
  }'

Multi-Turn Conversation

python
import requests

url = "https://apis.fotohub.app/v1/ai/chat/completions"
headers = {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
}

# Build conversation history
messages = [
    {"role": "system", "content": "You are a helpful coding assistant. Be concise."},
    {"role": "user", "content": "How do I read a file in Python?"},
    {"role": "assistant", "content": "Use open() with a context manager:\n\nwith open('file.txt', 'r') as f:\n    content = f.read()"},
    {"role": "user", "content": "What about reading it line by line?"}
]

response = requests.post(url, json={
    "model": "gemini-pro",
    "messages": messages,
    "temperature": 0.5,
    "max_tokens": 512
}, headers=headers)

data = response.json()
print(data["choices"][0]["message"]["content"])

# Append assistant response for next turn
messages.append(data["choices"][0]["message"])
typescript
interface Message {
  role: "system" | "user" | "assistant";
  content: string;
}

const messages: Message[] = [
  { role: "system", content: "You are a helpful coding assistant. Be concise." },
  { role: "user", content: "How do I read a file in Python?" },
  { role: "assistant", content: "Use open() with a context manager:\n\nwith open('file.txt', 'r') as f:\n    content = f.read()" },
  { role: "user", content: "What about reading it line by line?" },
];

const response = await fetch("https://apis.fotohub.app/v1/ai/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "gemini-pro",
    messages,
    temperature: 0.5,
    max_tokens: 512,
  }),
});

const data = await response.json();
console.log(data.choices[0].message.content);

// Append for next turn
messages.push(data.choices[0].message);
bash
curl -X POST "https://apis.fotohub.app/v1/ai/chat/completions" \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-pro",
    "messages": [
      {"role": "system", "content": "You are a helpful coding assistant."},
      {"role": "user", "content": "How do I read a file in Python?"},
      {"role": "assistant", "content": "Use open() with a context manager."},
      {"role": "user", "content": "What about reading it line by line?"}
    ],
    "temperature": 0.5,
    "max_tokens": 512
  }'

Bedrock with System Prompt

python
import requests

url = "https://apis.fotohub.app/v1/ai/chat/bedrock"
headers = {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
}

response = requests.post(url, json={
    "model": "claude-sonnet-4.6",
    "system": """You are a senior software architect. Provide detailed,
production-ready advice. Include code examples when relevant.
Consider scalability, maintainability, and security in all recommendations.""",
    "messages": [
        {"role": "user", "content": "Design a rate limiting system for a REST API that handles 10K req/s"}
    ],
    "temperature": 0.4,
    "max_tokens": 4096
}, headers=headers)

data = response.json()
content = data["choices"][0]["message"]["content"]
billing = data["billing"]

print(content)
print(f"\n--- Billing ---")
print(f"Method: {billing['method']}")
print(f"Input tokens: {billing['cost_breakdown']['input_tokens']}")
print(f"Output tokens: {billing['cost_breakdown']['output_tokens']}")
print(f"Total cost: {billing['pln_charged']} PLN")
typescript
const response = await fetch("https://apis.fotohub.app/v1/ai/chat/bedrock", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "claude-sonnet-4.6",
    system: `You are a senior software architect. Provide detailed,
production-ready advice. Include code examples when relevant.
Consider scalability, maintainability, and security.`,
    messages: [
      { role: "user", content: "Design a rate limiting system for a REST API that handles 10K req/s" }
    ],
    temperature: 0.4,
    max_tokens: 4096,
  }),
});

const data = await response.json();
const content = data.choices[0].message.content;
const billing = data.billing;

console.log(content);
console.log("\n--- Billing ---");
console.log(`Method: ${billing.method}`);
console.log(`Input tokens: ${billing.cost_breakdown.input_tokens}`);
console.log(`Output tokens: ${billing.cost_breakdown.output_tokens}`);
console.log(`Total cost: ${billing.pln_charged} PLN`);
bash
curl -X POST "https://apis.fotohub.app/v1/ai/chat/bedrock" \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4.6",
    "system": "You are a senior software architect. Provide production-ready advice.",
    "messages": [
      {"role": "user", "content": "Design a rate limiting system for a REST API"}
    ],
    "temperature": 0.4,
    "max_tokens": 4096
  }'

Budget-Friendly with Nova

python
import requests

url = "https://apis.fotohub.app/v1/ai/chat/bedrock"
headers = {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json"
}

# Nova Micro — ultra-budget option for simple tasks
# At 0.000525 PLN/1K tokens, process 1M tokens for ~0.53 PLN
response = requests.post(url, json={
    "model": "nova-micro",
    "messages": [
        {"role": "user", "content": "Classify this review as positive/negative: 'Great product, fast shipping!'"}
    ],
    "temperature": 0.1,  # Low temp for classification
    "max_tokens": 10
}, headers=headers)

data = response.json()
print(data["choices"][0]["message"]["content"])  # "positive"
print(f"Cost: {data['billing']['pln_charged']} PLN")  # ~0.000005 PLN
typescript
// Nova Micro — ultra-budget for classification, extraction, simple tasks
const response = await fetch("https://apis.fotohub.app/v1/ai/chat/bedrock", {
  method: "POST",
  headers: {
    "Authorization": "Bearer fh_live_your_api_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "nova-micro",
    messages: [
      { role: "user", content: "Classify this review as positive/negative: 'Great product, fast shipping!'" }
    ],
    temperature: 0.1,
    max_tokens: 10,
  }),
});

const data = await response.json();
console.log(data.choices[0].message.content); // "positive"
console.log(`Cost: ${data.billing.pln_charged} PLN`);
bash
curl -X POST "https://apis.fotohub.app/v1/ai/chat/bedrock" \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nova-micro",
    "messages": [
      {"role": "user", "content": "Classify: positive or negative? Great product!"}
    ],
    "temperature": 0.1,
    "max_tokens": 10
  }'

Error Responses

400 -- Invalid Request

json
{
  "error": {
    "type": "invalid_request",
    "message": "messages array is required and must contain at least one message",
    "code": "missing_messages"
  }
}

402 -- Insufficient Credits

json
{
  "error": {
    "type": "billing_error",
    "message": "Insufficient credits. Required: 2, available: 0",
    "code": "insufficient_credits",
    "credits_required": 2,
    "credits_available": 0
  }
}

429 -- Rate Limited

json
{
  "error": {
    "type": "rate_limit",
    "message": "Rate limit exceeded. Please retry after 2 seconds.",
    "code": "rate_limited",
    "retry_after": 2
  }
}

Rate Limits

Rate Limits by Tier

  • Free tier: 10 requests/minute, 100 requests/day
  • Pro tier: 60 requests/minute, 5,000 requests/day
  • Enterprise: Custom limits -- contact support
  • Streaming requests count as 1 request regardless of duration