Skip to navigation

Create a completion

OpenAI-compatible prompt completions for clients that send a raw prompt instead of chat messages. Every model that accepts POST /v1/chat/completions accepts this shape.

Send one text prompt per request: a list with more than one prompt, or a prompt given as token IDs, returns 400 with param set to prompt. Set echo to true to receive the prompt followed by the completion in text; a stream adds the prompt to the first text of each choice. A non-empty suffix, or a best_of above 1, returns 400 naming the parameter.

Streaming uses Server-Sent Events. usage arrives at the end of the stream on a chunk that also has choices. Set stream_options.include_usage to true to receive it the way OpenAI sends it, in its own chunk just before [DONE] whose choices is an empty list; some models still report it on a chunk with choices. Read usage from the last chunk that carries it. An error after the stream starts arrives as a data: event whose JSON is an error body, {"error": {"message", "type", "param", "code"}}, the same shape as an HTTP error.

Authentication

AuthorizationBearer

Pass your EmpirioLabs API key as a bearer token. The Anthropic-style x-api-key header is also accepted on every endpoint.

Request

This endpoint expects an object.
modelstringRequired
promptstring or list of stringsRequired

The prompt text, or a list holding one prompt. A list with more than one prompt, or a prompt given as token IDs, returns 400.

echobooleanOptionalDefaults to false

Return the prompt followed by the completion in each choice’s text.

suffixstringOptional

Not supported. A non-empty value returns 400; leave it out or send an empty string.

best_ofintegerOptional<=1

Only 1 is accepted. A larger value returns 400.

streambooleanOptionalDefaults to false
stream_optionsobjectOptional

Streaming options, used with stream: true. Without them, usage arrives at the end of the stream on a chunk that also has choices. Set include_usage to true to receive it the way OpenAI sends it: in its own chunk just before data: [DONE], whose choices is an empty list. Some models still report it on a chunk with choices.

temperaturedoubleOptional0-2
max_tokensintegerOptional
top_pdoubleOptional0-1
stopstring or list of stringsOptional
logit_biasmap from strings to doublesOptional
Bias token IDs by adding positive or negative values before sampling.

Response

Completion object or SSE stream when stream=true.

idstringOptional
objectstringOptional
createdintegerOptional
modelstringOptional
choiceslist of objectsOptional
usageobjectOptional

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
404
Not Found Error
429
Too Many Requests Error