Completion

POST

Send a completion request to a selected model (text-only format)

Request

This endpoint expects an object.
modelstringRequired

The model ID to use. If unspecified, the user’s default is used.

promptstringRequired

The text prompt to complete

streambooleanOptionalDefaults to false

Enable streaming of results.

max_tokensintegerOptional

Maximum number of tokens (range: [1, context_length)).

temperaturedoubleOptional

Sampling temperature (range: [0, 2]).

seedintegerOptional

Seed for deterministic outputs.

top_pdoubleOptional

Top-p sampling value (range: (0, 1]).

top_kintegerOptional

Top-k sampling value (range: [1, Infinity)).

frequency_penaltydoubleOptional

Frequency penalty (range: [-2, 2]).

presence_penaltydoubleOptional

Presence penalty (range: [-2, 2]).

repetition_penaltydoubleOptional

Repetition penalty (range: (0, 2]).

logit_biasmap from strings to doublesOptional

Mapping of token IDs to bias values.

top_logprobsintegerOptional

Number of top log probabilities to return.

min_pdoubleOptional

Minimum probability threshold (range: [0, 1]).

top_adoubleOptional

Alternate top sampling parameter (range: [0, 1]).

transformslist of stringsOptional

List of prompt transforms (OpenRouter-only).

modelslist of stringsOptional

Alternate list of models for routing overrides.

route"fallback"OptionalDefaults to fallback

Model routing strategy (OpenRouter-only).

providerobjectOptional

Preferences for provider routing.

reasoningobjectOptional

Configuration for model reasoning/thinking tokens

Response

Successful completion

idstringOptional
choiceslist of objectsOptional
Built with