Inference API
Create a text completion
Stream a text completion from a TokenChange model with POST /v1/completions, using the OpenAI legacy completions format with a prompt string.
POST
Streams a text completion for a prompt. The request and response follow the OpenAI completions format. For conversations, use chat completions.
Other OpenAI completion fields, such as
The values above are illustrative.
Request
string
required
Bearer ask_..., an inference key.string
required
A model slug from the catalog, or
<model-slug>/ep/<endpoint> to pin one endpoint.string
required
The text to complete.
boolean
required
Must be
true.integer
Maximum tokens to generate. At least
1.number
Sampling temperature, from
0 to 2.boolean
default:"false"
Set to
true to receive token usage in the final chunk.string
Requests with the same key are routed to the same endpoint. See Prompt caching.
object
Price options. See Price options.
top_p, stop and seed, are passed to the endpoint unchanged.
Response
A stream of server-sent events. Each event’sdata is a JSON completion chunk with object set to text_completion, and the stream ends with data: [DONE]. Each choice carries the new text and, in its last chunk, a finish_reason. Usage works as in chat completions.