POST /v1/completions
Generates a text completion for a given prompt string. This is the legacy completions endpoint, distinct from the chat completions endpoint. It is maintained for compatibility with older OpenAI integrations and providers that expose acomplete endpoint.
For most use cases, prefer chat completions. Modern models such as GPT-4o and Claude are optimized for the chat format.
Request headers
The provider to route the request to (e.g.
openai). Required when not using a config.Your provider API key.
A JSON config object or config ID that defines routing, fallbacks, retries, and more.
A virtual key ID from Portkey Cloud that maps to a stored provider credential.
Request body
The model to use for completion (e.g.
gpt-3.5-turbo-instruct).The prompt to generate a completion for. Accepts a string or an array of strings for batched input.
Sampling temperature between
0 and 2. Higher values produce more varied output.The maximum number of tokens to generate in the completion.
When
true, partial results are streamed as server-sent events and the stream ends with data: [DONE].Nucleus sampling threshold. Only tokens within the top
top_p probability mass are considered.Number between
-2.0 and 2.0. Positive values reduce repeated tokens.Number between
-2.0 and 2.0. Positive values encourage new topics.The number of completions to generate for each prompt.
One or more sequences at which to stop generating. The stop sequence is not included in the output.
Include the log probabilities of the
logprobs most likely tokens at each position.When
true, echo the prompt back in the response along with the completion.Generate
best_of completions server-side and return the best. Incurs higher token cost.A map of token IDs to bias values from
-100 to 100. Adjusts the likelihood of specific tokens appearing.A seed for deterministic sampling.
A unique identifier for the end user, used for monitoring.
Response
A unique identifier for this completion.
Always
text_completion.Unix timestamp of when the completion was created.
The model used for the completion.
An array of completion choices.
Token usage for this request.