Documentation

API Documentation

A drop-in OpenAI & Anthropic compatible LLM API. Use any OpenAI or Anthropic SDK — just change the base URL and API key.

Quick start

1. Sign up
Create an account with email + password. Gmail users get $10 free credits.
2. Create API key
In /dashboard, click "New key" and copy it.
3. Make a request
Use the key as a Bearer token. See snippets below.

Authentication

All API requests require a Bearer token in the Authorization header. Create one in the dashboard.

Authorization: Bearer ns-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Chat Completions (OpenAI-compatible)

Drop-in replacement for POST /v1/chat/completions. Supports streaming, tools, JSON mode, vision — depending on the model.

curl https://api.namansoni.in/v1/chat/completions \
  -H "Authorization: Bearer ns-xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama-3.1-8b-instant",
    "messages": [{"role":"user","content":"Hello!"}],
    "stream": false
  }'

Streaming

Set "stream": true for Server-Sent Events (SSE) — OpenAI-compatible.

from openai import OpenAI

client = OpenAI(api_key="ns-xxxx", base_url="https://api.namansoni.in/v1")

stream = client.chat.completions.create(
    model="llama-3.1-8b-instant",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

Tool calling

Pass tools array — OpenAI-compatible format. Only models with the tools capability accept this.

curl https://api.namansoni.in/v1/chat/completions \
  -H "Authorization: Bearer ns-xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<tool-capable-model>",
    "messages": [{"role":"user","content":"What is the weather in Paris?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get current weather for a city",
        "parameters": {
          "type": "object",
          "properties": {"city": {"type":"string"}},
          "required": ["city"]
        }
      }
    }]
  }'

JSON mode

Force JSON-formatted output with response_format. Only models with the json_mode capability accept this.

curl https://api.namansoni.in/v1/chat/completions \
  -H "Authorization: Bearer ns-xxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<json-capable-model>",
    "messages": [{"role":"user","content":"List 3 fruits with colors."}],
    "response_format": {"type": "json_object"}
  }'

Anthropic-compatible (/v1/messages)

Use the official Anthropic SDK with our base URL. We translate Anthropic ↔ OpenAI internally.

import anthropic

client = anthropic.Anthropic(
    api_key="ns-xxxx",
    base_url="https://api.namansoni.in",
)

response = client.messages.create(
    model="llama-3.1-8b-instant",
    max_tokens=256,
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.content[0].text)

List models

curl https://api.namansoni.in/v1/models

No auth required. Returns model IDs, capabilities, pricing, and context windows.

Available models

No models listed yet. Check back soon.

Errors

401 Unauthorized
Missing or invalid API key.
402 Insufficient credits
You have 0 credits. Top up via email.
404 Model not found
Model is disabled or doesn't exist.
429 Rate limited
Per-user, per-model RPM/TPD limit hit. Retry after the wait.
502 Upstream error
All upstream provider keys failed.
503 Provider unconfigured
Server admin hasn't set the provider's API keys.

Next steps