Chat
Create a chat completion
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
post/chat/completions
Headers
X-OpenRouter-Metadata'disabled' | 'enabled'
Opt-in level for surfacing routing metadata on the response under openrouter_metadata.
Example:enabled
Opt-in to surface routing metadata on the response under openrouter_metadata. Defaults to disabled. The legacy header X-OpenRouter-Experimental-Metadata is also accepted for backward compatibility.
Request body
ChatRequest required— unresolved $ref
Response
Successful chat completion response
Example response
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "The capital of France is Paris.",
"role": "assistant"
}
}
],
"created": 1677652288,
"id": "chatcmpl-123",
"model": "openai/gpt-4",
"object": "chat.completion",
"system_fingerprint": "fp_44709d6fcb",
"usage": {
"completion_tokens": 15,
"prompt_tokens": 10,
"total_tokens": 25
}
}