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

createdinteger required

Unix timestamp of creation

idstring required

Unique completion identifier

modelstring required

Model used for completion

object'chat.completion' required
service_tierstring nullable

The service tier used by the upstream provider for this request

system_fingerprintstring nullable required

System fingerprint

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 Respan enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new Respan enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new Respan enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new optional request property //

      new-optional-request-property

    • ○

      added the new ScaleDown enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new ScaleDown enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new ScaleDown enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new optional request property /

      new-optional-request-property

    • ○

      added switchyard-router discriminator mapping keys to the / request property

      request-property-discriminator-mapping-added

    • ○

      added to the / request property oneOf list

      request-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 Unbiased enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new Unbiased enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new Unbiased enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new TypeSafe enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new TypeSafe enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new TypeSafe enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new AssemblyAI enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new AssemblyAI enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new AssemblyAI enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new Near AI enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new Near AI enum value to the request property //////

      request-property-enum-value-added

    • ○

      added the new Near AI enum value to the request property //////

      request-property-enum-value-added

    • ▲

      removed the enum value NCompass of the request property //////

      request-property-enum-value-removed

    • ▲

      removed the enum value NCompass of the request property //////

      request-property-enum-value-removed

    • ▲

      removed the enum value NCompass of the request property //////

      request-property-enum-value-removed