Quickstart documentation

Make a first request in minutes.

Use the production base URL and send your issued key as a Bearer token. Replace the key and model slug in the runnable command.

Base URL: https://api.diwakaryadav.com.np/v1
Header: Authorization: Bearer <your-issued-np-key>
First request with cURL
curl https://api.diwakaryadav.com.np/v1/chat/completions \
  -H "Authorization: Bearer <your-issued-np-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<allowed-model-slug>",
    "messages": [
      {"role": "user", "content": "Namaste from Nepal AI Gateway"}
    ]
  }'

Authentication

Send the key in the header.

Trim accidental whitespace and keep the key private. Do not paste it into public code or screenshots.

HTTP header
Authorization: Bearer <your-issued-np-key>
Keys are shown only when issued. The account portal checks access without showing the full key again.

OpenAI-compatible client

Use the SDK you already know.

Node.js
const OpenAI = require("openai");

const client = new OpenAI({
  apiKey: process.env.NAG_API_KEY,
  baseURL: "https://api.diwakaryadav.com.np/v1"
});

const response = await client.chat.completions.create({
  model: process.env.NAG_MODEL,
  messages: [{ role: "user", content: "Namaste" }]
});

console.log(response.choices[0].message.content);
Python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["NAG_API_KEY"],
    base_url="https://api.diwakaryadav.com.np/v1",
)

response = client.chat.completions.create(
    model=os.environ["NAG_MODEL"],
    messages=[{"role": "user", "content": "Namaste"}],
)

print(response.choices[0].message.content)

Response shape

Read the assistant message.

Example JSON
{
  "id": "chatcmpl_example",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Namaste! How can I help?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 8,
    "total_tokens": 18
  }
}

Model access

Choose from your live model catalog.

The model list endpoint is the single source of truth — it only ever shows models that are available to your key right now. Call it, pick a slug from the response, and start.

Free plan: free keys call diwakar — the stealth-routed model included at no cost. Pro plan: unlocks the broader catalog as providers are verified and wired; the same endpoint shows them the moment they come online. Premium flagship models spend quota faster per token than standard ones when available — the response's _meta and your account page keep you informed.

List models (public — no key needed)
# Public: returns the free-tier catalog, no key required and no quota used
curl https://api.diwakaryadav.com.np/v1/models

# With a key: returns your plan-filtered catalog (still quota-free)
curl https://api.diwakaryadav.com.np/v1/models \
  -H "Authorization: Bearer <your-issued-np-key>"

Rate limits and quota

Two limits can stop a request.

rate_limit_error

Short-window request limit

Wait before retrying. Your account page shows the requests-per-minute limit returned for your plan.

subscription_error

Hard quota exhausted

Do not retry continuously. Review remaining quota and the reset or renewal action in your account.

Free trial

Try the gateway with one key, no credit card.

Sign up at trial.html with Google. You get one gateway key, shown once at first issue, that works against the same /v1 endpoint as paid keys but is routed exclusively to verified-free models.

  • 1 key per identity — the full secret appears only at signup; sign in daily with Google to keep the key active.
  • 5,000,000 tokens daily, 10 requests/minute, 200K context window.
  • Expires at midnight UTC — sign in within the trial window to re-enable the same key.
  • No paid-provider fallback. Free requests never silently hit a paid upstream.

Trial requests are logged for operations, abuse prevention, analytics, and quality improvement. Prompt bodies are stored only in hashed form. When you upgrade, the same key keeps working.

diwakar — a private, stealth-routed multimodal model, available for a limited time. The upstream does not train on your data.

Error reference

Respond to the state, not just the status code.

400 invalid_request_error

Invalid API key format

The value does not match the expected gateway key shape. Remove spaces and check the copied value.

401 authentication_error

Key not accepted

The public response stays generic for unknown, revoked, expired, or inactive credentials. Check the account portal or contact support.

403 plan_expired

Plan expired

The account access window ended. Request a renewal review before making payment.

403 model_not_allowed

Model not allowed

Choose a model returned by GET /v1/models for this key.

403 subscription_error

Quota exhausted

The plan budget is spent. Check the account quota summary for the next action.

429 rate_limit_error

Too many requests

Pause and retry after the current rate-limit window.

502 provider_error

Model temporarily unavailable

Try another allowed model or retry later.

Service checks

Verify the surface you are using.

Websitehttps://ai.diwakaryadav.com.np
APIhttps://api.diwakaryadav.com.np
Healthhttps://api.diwakaryadav.com.np/health