Create a chat completion
Sends a request for a model response for the given chat conversation. Supports both streaming and non-streaming modes.
Headers
Opt-in level for surfacing routing metadata on the response under openrouter_metadata.
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
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
}
}Changes
Changed in 69 of the 303 revisions of this API.10736183
- ○
added the new optional request property
//new-optional-request-property
- ○
added the new
Respanenum value to the request property//////request-property-enum-value-added
- ○
added the new
Respanenum value to the request property//////request-property-enum-value-added
- ○
added the new
Respanenum value to the request property//////request-property-enum-value-added
- ○
- ○
added the new optional request property
//new-optional-request-property
- ○
added the new
ScaleDownenum value to the request property//////request-property-enum-value-added
- ○
added the new
ScaleDownenum value to the request property//////request-property-enum-value-added
- ○
added the new
ScaleDownenum value to the request property//////request-property-enum-value-added
- ○
- ○
added the new optional request property
/new-optional-request-property
- ○
- ○
added
switchyard-routerdiscriminator mapping keys to the/request propertyrequest-property-discriminator-mapping-added
- ○
added to the
/request propertyoneOflistrequest-property-one-of-added
- ○
- ○
added the new optional request property
//////new-optional-request-property
- ○
added the new optional request property
///////new-optional-request-property
- ○
added the new optional request property
//////new-optional-request-property
- ○
added the new optional request property
///////new-optional-request-property
- ○
- ○
added the new
Unbiasedenum value to the request property//////request-property-enum-value-added
- ○
added the new
Unbiasedenum value to the request property//////request-property-enum-value-added
- ○
added the new
Unbiasedenum value to the request property//////request-property-enum-value-added
- ○
- ○
added the new
TypeSafeenum value to the request property//////request-property-enum-value-added
- ○
added the new
TypeSafeenum value to the request property//////request-property-enum-value-added
- ○
added the new
TypeSafeenum value to the request property//////request-property-enum-value-added
- ○
- ○
added the new
AssemblyAIenum value to the request property//////request-property-enum-value-added
- ○
added the new
AssemblyAIenum value to the request property//////request-property-enum-value-added
- ○
added the new
AssemblyAIenum value to the request property//////request-property-enum-value-added
- ○
- ○
added the new
Near AIenum value to the request property//////request-property-enum-value-added
- ○
added the new
Near AIenum value to the request property//////request-property-enum-value-added
- ○
added the new
Near AIenum value to the request property//////request-property-enum-value-added
- ○
- ▲
removed the enum value
NCompassof the request property//////request-property-enum-value-removed
- ▲
removed the enum value
NCompassof the request property//////request-property-enum-value-removed
- ▲
removed the enum value
NCompassof the request property//////request-property-enum-value-removed
- ▲