Create Completion
Given a prompt, this method lets you retrieve one or more predicted completions along with the probabilities of alternative tokens at each position.
To leverage the newest models and features, you should consider using use the Chat Completions API instead.
This method is compatible with the OpenAI endpoint for creating a completion.
This method is subject to removal from the API in the future. Switch to using the Chat Completions API instead.
Show optional properties
{
"model": "model-to-use",
"prompt": "hello"
}
{
"n": 0,
"stop": [
"string"
],
"max_tokens": 0,
"max_completion_tokens": 0,
"stream": false,
"stream_options": {
"include_usage": false
},
"model": "string",
"response_format": {
"type": "string",
"json_schema": {}
},
"temperature": "number",
"top_p": "number",
"presence_penalty": "number",
"frequency_penalty": "number",
"top_k": 0,
"prompt": "string",
"seed": 0
}
n
stop
max_tokens
max_completion_tokens
stream
Options for streaming response. Only set this when you set stream: true.
ID of the completions model to use.
response_format
temperature
top_p
presence_penalty
frequency_penalty
top_k
prompt
Seed to propagate to the LLM for making repeated requests with the same seed as deterministic as possible. Note that this feature is in beta for most inference servers.
Successful Response
{
"choices": [
{
"finish_reason": "length",
"index": 0,
"text": "Hello! I am an AI Assistant!"
}
],
"created": 1589478378,
"id": "cmpl-123",
"model": "gpt-4",
"object": "text_completion",
"usage": {
"completion_tokens": 7,
"prompt_tokens": 5,
"total_tokens": 12
}
}
Invalid model endpoint specified or model endpoint not ready.
Unknown model endpoint requested.
Validation Error
{
"detail": [
{
"loc": [
{}
],
"msg": "string",
"type": "string",
"ctx": {}
}
]
}
detail
curl -X POST -H 'Authorization: <value>' -H 'Content-Type: application/json' -d '{"model":"string","prompt":"string"}' https://{api_host}/api/v1/compatibility/openai/v1/completions