Completions
POST/v1/completions
Follows the exact same API spec as OpenAI's Completions API https://platform.openai.com/docs/api-reference/completions
Request
- application/json
Body
required
- MOD1
- MOD2
Array [
]
- MOD1
- MOD2
- MOD1
- MOD2
Array [
]
ID of the model to use
prompt
object
required
The prompt(s) to generate completions for
oneOf
string
string
Generates multiple completions server-side and returns the best one.
Possible values: >= 1
1Penalizes tokens based on their existing frequency in the text so far.
Possible values: >= -2 and <= 2
0logit_bias
object
nullable
Modify the likelihood of specified tokens appearing in the completion.
logprobs
object
Include log probabilities on the logprobs most likely output tokens.
oneOf
boolean
integer
The maximum number of tokens to generate.
Possible values: >= 1
16How many completions to generate for each prompt.
Possible values: >= 1
1Penalizes new tokens based on whether they appear in the text so far.
Possible values: >= -2 and <= 2
0Seed for deterministic sampling.
stop
object
Up to 4 sequences where the API will stop generating further tokens.
oneOf
string
string
Whether to stream back partial progress.
falsestream_options
object
nullable
Options for streaming responses.
Options for streaming responses.
Suffix that comes after a completion of inserted text.
Sampling temperature.
Possible values: <= 2
1Nucleus sampling parameter.
Possible values: <= 1
1Unique identifier representing the end user.
Responses
- 200
- 400
Successful Response
- application/json
- text/event-stream
- Schema
- Example (from schema)
Schema
Array [
]
A unique identifier for the completion
The object type
Possible values: [text_completion]
The Unix timestamp of when the completion was created
The model used for completion
choices
object[]
required
The list of completion choices
The generated text
The index of this choice
The reason the model stopped generating
Possible values: [stop, length]
usage
object
Dettaglio dei token (oggetto) oppure null se non disponibile.
Dettaglio dei token (oggetto) oppure null se non disponibile.
{
"id": "string",
"object": "text_completion",
"created": 0,
"model": "string",
"choices": [
{
"text": "string",
"index": 0,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0,
"prompt_tokens_details": {},
"completions_tokens_details": {}
}
}
- Schema
- Example (from schema)
- Stream
Schema
Array [
]
A unique identifier for the completion
The object type
Possible values: [text_completion]
The Unix timestamp of when the completion was created
The model used for completion
choices
object[]
required
A list of completion choice deltas. Empty array in the final usage-only chunk when stream_options.include_usage is true.
Incremental text fragment for this chunk
The reason the model stopped generating tokens. Null in every chunk except the last one for this choice.
Possible values: [stop, length]
usage
object
nullable
Present only in the final chunk, and only if stream_options.include_usage was true in the request. In that chunk, choices is an empty array.
{
"id": "string",
"object": "text_completion",
"created": 0,
"model": "string",
"choices": [
{
"text": "string",
"index": 0,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
data: {"id":"cmpl-8f9a3b1c2d","object":"text_completion","created":1717000000,"model":"gpt-oss-20b","choices":[{"text":"Once","index":0,"finish_reason":null}]}
data: {"id":"cmpl-8f9a3b1c2d","object":"text_completion","created":1717000000,"model":"gpt-oss-20b","choices":[{"text":" upon a time,","index":0,"finish_reason":null}]}
data: {"id":"cmpl-8f9a3b1c2d","object":"text_completion","created":1717000000,"model":"gpt-oss-20b","choices":[{"text":"","index":0,"finish_reason":"stop"}]}
data: {"id":"cmpl-8f9a3b1c2d","object":"text_completion","created":1717000000,"model":"gpt-oss-20b","choices":[],"usage":{"prompt_tokens":5,"completion_tokens":12,"total_tokens":17}}
data: [DONE]
Bad request Error when passing an invalid or non-existing model name or an invalid enum or an invalid type in a field
- application/json
- Schema
- Example (from schema)
Schema
error
object
required
Error returned as response for invalid or missing model name
{
"error": {
"message": "string",
"type": "string",
"param": "string",
"code": "string"
}
}