IranRouter
Docs contents

Docs

Chat Completions

POST /v1/chat/completions — parameters, response shape and streaming.

POSThttps://iranrouter.com/v1/chat/completions

The main surface. OpenAI-compatible, so the request and response shapes are what SDKs already expect.

Parameters

NameTypeNotes
modelstringRequired. Model ID or alias.
messagesarrayRequired. Messages with role system / user / assistant / tool.
max_tokensintOutput ceiling. Directly drives the amount held from your wallet — set it realistically.
max_completion_tokensintThe newer clients' spelling of max_tokens; both are honoured.
streamboolSSE streaming response.
temperaturenumberSampling randomness.
top_pnumberNucleus sampling.
toolsarrayTool definitions. Their schemas count as input tokens.
tool_choicestring|objectForce or free the tool choice.
response_formatobjectStructured / JSON output.
stopstring|arrayStop sequences.
seedintFor reproducibility, where the model supports it.
Each model accepts its own subset. The exact supported-parameter list is on that model's page; unknown parameters are ignored rather than rejected.

Response

json
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1767000000,
  "model": "openai/gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "..." },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 108,
    "total_tokens": 132
  }
}

The non-streaming path returns tool_calls, logprobs, refusal and n>1 in full.

Full example

bash
curl https://iranrouter.com/v1/chat/completions \
  -H "Authorization: Bearer ir-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [
      {"role": "system", "content": "You answer in Persian."},
      {"role": "user", "content": "پایتخت ایران کجاست؟"}
    ],
    "max_tokens": 200,
    "temperature": 0.4
  }'

For streaming → · For tools →