API Reference

Create Chat Completion

Creates a chat completion for the provided messages. Supports streaming via `stream: true`. Compatible with the OpenAI Chat Completions API.

POST
/v1/chat/completions

Authorization

ApiKeyAuth
AuthorizationBearer <token>

Your Yolo Router API key. Format: Bearer sk-...

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

curl -X POST "https://api.yolorouter.com/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "model": "gpt-4o",    "messages": [      {        "role": "system",        "content": "You are a helpful assistant."      },      {        "role": "user",        "content": "Hello!"      }    ]  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 0,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "user",
        "content": "Hello!"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0
  }
}
{
  "error": {
    "type": "invalid_request_error",
    "code": "invalid_api_key",
    "message": "Invalid API key"
  }
}
{
  "error": {
    "type": "insufficient_quota",
    "code": "insufficient_quota",
    "message": "Quota exceeded"
  }
}
{
  "error": {
    "type": "string",
    "code": "string",
    "message": "string"
  }
}