v171

latestOpenAPI 3.1.0raw.githubusercontent.com2026-08-0726249111.7 MB
Completions

Create completion

For sending requests to legacy completion models

post/v2/router/completions

Request body

modelstring required

ID of the model to use

promptstring required

The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.

echoboolean nullable

Echo back the prompt in addition to the completion

frequency_penaltynumber nullable

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

max_tokensnumber nullable

The maximum number of tokens that can be generated in the completion.

presence_penaltynumber nullable

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

seednumber nullable

If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.

temperaturenumber nullable

What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

top_pnumber nullable

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

nnumber nullable

How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota.

userstring

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.

namestring

The name to display on the trace. If not specified, the default system name will be used.

streamboolean

Example request

{
  "retry": {
    "count": 3,
    "on_codes": [
      429,
      500,
      502,
      503,
      504
    ]
  },
  "cache": {
    "ttl": 3600
  },
  "load_balancer": {
    "models": [
      {
        "model": "openai/gpt-4o",
        "weight": 0.7
      }
    ]
  },
  "timeout": {
    "call_timeout": 30000
  },
  "orq": {
    "retry": {
      "count": 3,
      "on_codes": [
        429,
        500,
        502
      ]
    },
    "fallbacks": [
      {
        "model": "openai/gpt-5"
      },
      {
        "model": "anthropic/claude-4-opus"
      }
    ],
    "identity": {
      "id": "identity_01ARZ3NDEKTSV4RRFFQ69G5FAV",
      "display_name": "Jane Doe",
      "email": "jane.doe@example.com"
    },
    "thread": {
      "id": "thread_01ARZ3NDEKTSV4RRFFQ69G5FAV",
      "tags": [
        "customer-support"
      ]
    },
    "inputs": {
      "customer_name": "John Smith",
      "issue_type": "billing"
    },
    "cache": {
      "ttl": 3600,
      "type": "exact_match"
    },
    "knowledge_bases": [
      {
        "knowledge_id": "knowledge_01ARZ3NDEKTSV4RRFFQ69G5FAV",
        "top_k": 5
      }
    ],
    "timeout": {
      "call_timeout": 30000
    },
    "security": {
      "mask": [
        "input",
        "system"
      ]
    }
  }
}

Response

Represents a completion response from the API.

idstring required

A unique identifier for the completion.

modelstring required

The model used for the chat completion.

system_fingerprintstring

This fingerprint represents the backend configuration that the model runs with.

objectstring required

The object type