Create a text completion

Completes a text prompt. Set stream to true to receive JSON chunks as server-sent events; the stream ends with data: [DONE].

Authentication

AuthorizationBearer
Mixlayer API key or console user session supplied as a Bearer token.

Request

Completion parameters
modelstringRequired
Model identifier to use for generation.
promptstringRequired
Text prompt to complete.
max_tokensinteger or nullOptional>=0
Maximum number of tokens to generate.
stoplist of strings or nullOptional
Strings that stop generation when encountered.
streambooleanOptionalDefaults to false

When true, return server-sent events and terminate with data: [DONE].

stream_optionsobject or nullOptional
temperaturedouble or nullOptional
Sampling temperature. Higher values make output more random.
top_kinteger or nullOptional

Restricts sampling to the highest-probability tokens.

Response

A complete response or a stream of completion chunks, selected by the request’s stream field

choiceslist of objects
Generated completion choices.
createdlong>=0
Unix timestamp when the completion was created.
idstring
Unique identifier for the completion.
modelstring
Model used to generate the completion.
objectenum

Object type, always text_completion.

usageobject
Token usage for the request.

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
429
Too Many Requests Error
500
Internal Server Error