API Documentation

The AIsathi API is OpenAI-compatible. Anything that speaks the OpenAI chat-completions format — SDKs, LangChain, your existing code — works by changing two lines: the base URL and the key.

Base URLhttps://aisathi.io/api/v1AuthAuthorization: Bearer np-… — create keys on your account pageBillingPer token, in NPR, deducted from your prepaid balance. Every response includes a nepalai.cost_npr field.StreamingStandard SSE — pass "stream": true. The final chunk carries the cost.

Chat completion (curl)

curl https://aisathi.io/api/v1/chat/completions \
  -H "Authorization: Bearer np-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [{"role": "user", "content": "नमस्ते!"}]
  }'

Python (OpenAI SDK)

Your existing OpenAI code works — change the base_url and key.

from openai import OpenAI

client = OpenAI(
    base_url="https://aisathi.io/api/v1",
    api_key="np-your-key",
)

resp = client.chat.completions.create(
    model="anthropic/claude-sonnet-5",
    messages=[{"role": "user", "content": "Explain recursion simply"}],
)
print(resp.choices[0].message.content)

JavaScript / TypeScript

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://aisathi.io/api/v1",
  apiKey: "np-your-key",
});

const stream = await client.chat.completions.create({
  model: "openai/gpt-4o-mini",
  messages: [{ role: "user", content: "Write a haiku about Kathmandu" }],
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Image generation

Use an image-output model (marked as image-capable in the catalog) and ask for image output. Images come back as base64 data URLs.

curl https://aisathi.io/api/v1/chat/completions \
  -H "Authorization: Bearer np-your-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-3.1-flash-image",
    "messages": [{"role": "user", "content": "A rhino in front of Everest, flat logo style"}],
    "modalities": ["image", "text"]
  }'

List models with NPR prices

curl https://aisathi.io/api/v1/models

Check your balance & usage

curl https://aisathi.io/api/v1/me -H "Authorization: Bearer np-your-key"

Errors

401Invalid or revoked API keyCheck the key, or create a new one on your account page.
402Insufficient creditsThe response includes estimated_cost_npr. Top up, or use a free model.
429Rate limit (60 req/min per key)Wait for the Retry-After header, then retry.
502Upstream model errorUsually temporary — retry, or switch models.

Good to know

  • • Completion length is capped at 8,192 tokens per request.
  • • Vision input works on image-capable models — send OpenAI-style image_url content parts (base64 data URLs are most reliable).
  • • Your balance must cover the worst-case cost of a request before it starts — the 402 error tells you the estimate.
  • • Keys are shown once at creation and stored hashed. Revoke any key instantly from your account page.

Questions? Contact us — or try everything in the playground first.