Chat Completions

Generate assistant replies from a conversation using the compatible chat API.

Send a request

Send messages to the chat completions endpoint. Replace YOUR_MODEL_ID with a model available to your key.

curl 'https://routerra.ai/v1/chat/completions' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Streaming

Set stream to true to receive server-sent events. Read data chunks incrementally until [DONE]. Supported request parameters depend on the selected model and upstream provider.

{
  "model": "YOUR_MODEL_ID",
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "stream": true
}

Troubleshooting

For authentication errors, check the key and its expiry. For quota errors, check your balance and key quota. If a model is unavailable, check its exact ID and group access. For rate limits, retry with backoff.