Nirvani AI API

Base URL https://api.nirvani.ai/v1. Send your key as Authorization: Bearer nvk_... and POST chat requests to /chat/completions. The format is the standard chat-completions format, so existing code works after you change the base URL.

Quickstart

Three steps, about two minutes.

  1. Get a free test key. It arrives by email and is shown nowhere else.
  2. Save it as an environment variable: export NIRVANI_API_KEY=nvk_test_...
  3. Make a call:
curl https://api.nirvani.ai/v1/chat/completions \
  -H "Authorization: Bearer $NIRVANI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"nirvani-flash","messages":[{"role":"user","content":"Hello"}]}'

Authentication

Every request to /chat/completions and /usage needs a key in the Authorization header. Keys start with nvk_test_ (free tier) or nvk_live_ (production). A missing, unknown or turned-off key returns HTTP 401.

Keep keys on your server. Never ship a key inside browser or mobile app code.

Models

Pass the model ID in the model field. GET /v1/models returns the live list without a key.

Model IDBest forContextMax output
nirvani-flashFast, capable default for chat, support and agents1,000,0008,192
nirvani-flash-liteLowest cost for classification, routing and summaries1,000,0008,192
nirvani-proDeepest reasoning and writing quality200,0008,192
nirvani-openOpen-weights workloads128,0004,096

Chat completions

POST /v1/chat/completions generates the next assistant message.

Request body

FieldTypeNotes
modelstringRequired. A model ID from the table above.
messagesarrayRequired. Up to 200 items, each with role (system, user or assistant) and text content. Include at least one user message.
streambooleanDefault false. When true, tokens arrive as server-sent events.
max_tokensintegerCap on output tokens. Values above the model maximum are lowered to it.
temperaturenumber0 to 2. Lower is more focused.
top_pnumberGreater than 0, up to 1.
stopstring or arrayUp to 4 stop sequences.
stream_options.include_usagebooleanWith streaming, sends a final chunk carrying token usage.

Response

{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1793404800,
  "model": "nirvani-flash",
  "choices": [{ "index": 0, "message": { "role": "assistant", "content": "Hello! How can I help?" }, "finish_reason": "stop" }],
  "usage": { "prompt_tokens": 9, "completion_tokens": 7, "total_tokens": 16 }
}

finish_reason is stop when the model finished, length when it hit max_tokens, or content_filter when the request was blocked for safety.

Streaming

Set "stream": true. The response is text/event-stream: one data: line per chunk, ending with data: [DONE]. Each chunk carries new text in choices[0].delta.content.

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

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","model":"nirvani-flash","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]

If the model fails after streaming starts, you receive one chunk with an error object, then [DONE].

Usage

GET /v1/usage returns live numbers for the calling key: requests, tokens, average latency and error rate today, hourly counts for the last 24 hours, a breakdown by model, recent requests, and tokens used against your monthly quota. The console shows the same data.

curl https://api.nirvani.ai/v1/usage -H "Authorization: Bearer $NIRVANI_API_KEY"

Limits and quotas

KeyRequests per minuteTokens per month
Test (nvk_test_)20100,000
Live (nvk_live_)1205,000,000

Rate limits are applied per key at each edge location, so short bursts can briefly exceed them. Monthly quotas reset at 00:00 UTC on the first of each month. For higher limits, reply to your key email.

Errors

Errors return JSON: {"error": {"message": "...", "type": "...", "code": "..."}}. The message always says what happened and what to do.

StatusTypeMeaning
400invalid_request_errorThe body is malformed or a parameter is out of range.
401invalid_request_errorThe key is missing, unknown or turned off.
404invalid_request_errorThe model or endpoint does not exist.
413invalid_request_errorThe request body is larger than 512 KB.
429rate_limit_errorToo many requests per minute on this key. Retry after a short wait.
429quota_exceededThe key used its monthly tokens. Upgrade to a live key.
502upstream_errorThe model hit a snag. Retry with backoff.
503capacity or model_unavailableThe model is busy or not available. Retry or switch tiers.
504timeoutThe model took too long. Retry or lower max_tokens.

Using an existing SDK

Any client that speaks the chat-completions format works. Set two values:

  • Base URL: https://api.nirvani.ai/v1
  • API key: your nvk_ key

Then use a Nirvani model ID such as nirvani-flash. No other code changes are needed for text chat and streaming.

Key security

  • Your key is shown once, in the email that delivers it. Nirvani stores only a SHA-256 hash.
  • Each key has its own rate limit, quota and usage history, so one leaked key cannot affect another.
  • Lost a key or think it leaked? Reply to your key email and it will be turned off and replaced.