Skip to main content
POST
Create a text completion

Authorizations

Authorization
string
header
required

A workspace API key in an Authorization: Bearer header. A missing header, a scheme other than Bearer, a key of the wrong shape, and a key we reject are all 401.

Body

application/json

An OpenAI text completion request. Fields beyond the ones named here are forwarded to the provider unchanged rather than refused for being unfamiliar.

model
string
required

A model id in provider/model form, or profile/{identifier} for one of your workspace's routing profiles. A bare model id is refused with 400 and the code model_id_not_pinned. The catalog must list the model for completions. List what you can call with GET /v1/models.

Example:

"openai/gpt-4o-mini"

prompt
required

What to complete: a string, an array of strings, an array of token ids, or an array of token id arrays.

stream
boolean
default:false

Return the reply as server-sent events instead of one JSON body.

max_tokens
integer

The most output tokens you will accept. Sending it also lowers the credit held for the request while it runs. Omit it and the model's published maximum output is held instead.

Required range: x >= 1

Response

The completion, in OpenAI's text completion format as the provider produced it. A response that is not streamed carries the provider's token counts in its own usage object.

When stream is true the body is text/event-stream instead, in OpenAI's own chunk format, ending with data: [DONE].

An OpenAI text completion, as the provider produced it.

id
string
object
string
Example:

"text_completion"

created
integer
model
string
choices
object[]
usage
object