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
Authentication
All API requests require a Bearer token in the Authorization header. Create one in the dashboard.
Authorization: Bearer ns-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxChat 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/modelsNo auth required. Returns model IDs, capabilities, pricing, and context windows.
Available models
No models listed yet. Check back soon.