Pular para o conteúdo principal
POST
Create completion
Guia relacionado: guia de AI Gateway. Consulte o guia de AI Gateway para um passo a passo com exemplos.

Autorizações

Authorization
string
header
obrigatório

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Corpo

application/json
model
string
obrigatório

ID of the model to use

Exemplo:

"openai/gpt-3.5-turbo-instruct"

prompt
string
obrigatório

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

echo
boolean | null
padrão:false

Echo back the prompt in addition to the completion

frequency_penalty
number | null
padrão:0

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_tokens
integer | null
padrão:16

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

presence_penalty
number | null
padrão:0

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.

Intervalo obrigatório: -2 <= x <= 2
seed
integer | null

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.

stop

Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.

temperature
number | null
padrão:1

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_p
number | null
padrão:1

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.

n
integer | null
padrão:1

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

user
string

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

name
string

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

fallback_on_codes
integer[]

HTTP status codes that trigger fallback. Enter up to 20 unique integers from 400 to 599. When omitted or empty, defaults to [408, 429, 500, 502, 503, 504, 529].

Maximum array length: 20
Intervalo obrigatório: 400 <= x <= 599
fallbacks
object[]

Array of fallback models to use if primary model fails

retry
object

Retry configuration for the request

cache
object

Cache configuration for the request.

load_balancer
object

Load balancer configuration for the request.

timeout
object

Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured.

thinking
Thinking config disabled · object

Configuration for the thinking mode capability. Set type to adaptive for models that support adaptive thinking (e.g. Claude Opus 4.6, Sonnet 4.6), or enabled with budget_tokens for manual control.

plugins
PII redaction plugin · object[]

Request-scoped transforms applied to the text exchanged with the model. Currently supports pii_redaction, which replaces PII with placeholders before the provider sees it and restores the original values in the response.

orq
object
obsoleto

Leverage Toqan Router's intelligent routing capabilities to enhance your AI application with enterprise-grade reliability and observability. Toqan Router provides automatic request management including retries on failures, model fallbacks for high availability, identity-level analytics tracking, conversation threading, and dynamic prompt templating with variable substitution.

Exemplo:
stream
boolean
padrão:false

Resposta

Represents a completion response from the API.

id
string
obrigatório

A unique identifier for the completion.

choices
object[]
obrigatório

The list of completion choices the model generated for the input prompt.

model
string
obrigatório

The model used for the chat completion.

object
string
obrigatório

The object type

created

The Unix timestamp (in seconds) of when the chat completion was created.

system_fingerprint
string

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

usage
object

Usage statistics for the completion request.