Create Chat Completion

POST/v1/chat

Send a chat completion request. Provider is selected by model prefix or provider_preference. Automatic fallback on failure — the response includes provider_used and model to indicate which served the request. The built-in Chat UI shows an amber warning banner when a fallback provider was used.

Request Body

ParameterTypeDescription
modelRequiredstringModel ID, e.g. "groq/llama-3.3-70b-versatile"
messagesRequiredarrayArray of {role, content} objects (max 100)
streambooleandefault: falseEnable SSE streaming
provider_preferencestringForce provider: groq, openrouter, gemini, openai, claude, or huggingface

Response

Returns the generated content along with which model and provider were actually used.

{
  "id": "req_abc123...",
  "provider_used": "groq",
  "model": "llama-3.3-70b-versatile",
  "content": "The meaning of life is a philosophical question...",
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 45,
    "total_tokens": 57
  },
  "cost_usd": 0.000034
}