Chat Completions
Send message lists, read text and usage, and manage conversation history.
Send a text request
Select a model supporting Chat Completions, configure the key from the API overview, and replace <model-id> before running this Bash example.
curl --fail-with-body 'https://gateway.irouter.io/v1/chat/completions' \
-H "Authorization: Bearer $IROUTER_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"model":"<model-id>","messages":[{"role":"user","content":"Reply with a short greeting."}],"stream":false}'Core fields
Field | Meaning |
|---|---|
| Required complete model ID available to the key |
| Required ordered list of messages with roles and content |
| Enables SSE; this example is non-streaming |
| Optional tool definitions requiring model and line support |
Temperature, output limits, and reasoning options vary by model. Verify the basic request before adding them. Output-limit field names can differ; do not combine incompatible parameters.
Read and continue
Text is usually in choices[0].message.content. Inspect finish_reason: truncation or a tool request is not a complete text answer. Tool requests use tool_calls, and text may be empty.
Your application stores and resends relevant conversation history, including assistant messages and tool results. History consumes context and input tokens on subsequent requests. Usage usually appears in usage; see streaming for streaming usage.
See the OpenAI Chat Completions reference for protocol fields. Actual support depends on the selected iRouter model and line.