Guides

Chat completions

OpenAI-shaped requests and responses, billed per 1M tokens in rupees.

Request

curl https://userouter.in/api/v1/chat/completions \
  -H "Authorization: Bearer $ROUTER_KEY" \
  -H "content-type: application/json" \
  -d '{"model": "deepseek/deepseek-v4.1-flash", "stream": true, "max_tokens": 1024,
       "messages": [{"role": "user", "content": "Explain UPI in two lines"}]}'

How it is billed

  • Before calling the model we hold the most the request could cost: the prompt's size as an upper bound on input tokens, plus max_tokens output tokens (default 4,096, up to 1,28,000).
  • After the answer we settle the tokens used and release the rest.
  • If a route fails before its first token, we try the next one. After the first token there is no fallback, and a stream that breaks mid-answer is free.
  • If you disconnect mid-stream, the tokens already generated are charged.

Usage and cost

Non-streaming responses carry x-cost-paise and usage.cost_paise. Streams end with one chunk with "choices": [] and the same usage, then data: [DONE].

"usage": {
  "prompt_tokens": 1240,
  "completion_tokens": 380,
  "cost_paise": 4,
  "router": {
    "rates_per_1m": { "input_inr": "[x]", "output_inr": "[y]" },
    "line_items_inr": { "input": "0.0124", "output": "0.0302" }
  }
}

Prompts are not stored. The model in every chunk is our model id.