Create chat completion

post/v1/chat/completions

Create a model response from a conversation history. Streaming and non-streaming responses are both supported.

Compatible with the OpenAI Chat Completions API.

Authentication

Send your OLETOKEN API key as a Bearer token. Keys are created on the API Keys page of the console.

Authorization: Bearer $OLETOKEN_API_KEY

Request body

Content-Type:application/json

FieldTypeRequiredDescription
modelstringModel ID
messagesMessage[]The conversation messages
rolestringsystemuserassistanttooldeveloperMessage role
contentstring | MessageContent[]Message content
typestringtextimage_urlinput_audiofilevideo_url——
textstring——
image_urlobject——
urlstring—Image URL or base64 data
detailstringlowhighauto——
input_audioobject——
datastring—Base64-encoded audio data
formatstringwavmp3——
fileobject——
filenamestring——
file_datastring——
file_idstring——
video_urlobject——
urlstring——
namestring—Sender name
tool_callsToolCall[]——
idstring——
typestring——
functionobject——
namestring——
argumentsstring——
tool_call_idstring—Tool call ID (for messages with the tool role)
reasoning_contentstring—Reasoning content
temperaturenumber0–2default: 1—Sampling temperature
top_pnumber0–1default: 1—Nucleus sampling parameter
ninteger≥ 1default: 1—Number of completions to generate
streambooleandefault: false—Whether to stream the response
stream_optionsobject——
include_usageboolean——
stopstring | string[]—Stop sequences
max_tokensinteger—Maximum number of tokens to generate
max_completion_tokensinteger—Maximum number of completion tokens
presence_penaltynumber-2–2default: 0——
frequency_penaltynumber-2–2default: 0——
logit_biasobject——
userstring——
toolsTool[]——
typestring——
functionobject——
namestring——
descriptionstring——
parametersobject—Parameter definitions in JSON Schema format
tool_choicestring | objectnoneautorequired——
typestring——
functionobject——
namestring——
response_formatResponseFormat——
typestringtextjson_objectjson_schema——
json_schemaobject—JSON Schema definition
seedinteger——
reasoning_effortstringlowmediumhigh—Reasoning effort (for models that support reasoning)
modalitiesstring[]——
audioobject——
voicestring——
formatstring——

Responses

200Response created

FieldTypeRequiredDescription
idstring——
objectstring——
createdinteger——
modelstring——
choicesobject[]——
indexinteger——
messageMessage——
rolestringsystemuserassistanttooldeveloperMessage role
contentstring | MessageContent[]Message content
typestringtextimage_urlinput_audiofilevideo_url——
textstring——
image_urlobject——
urlstring—Image URL or base64 data
detailstringlowhighauto——
input_audioobject——
datastring—Base64-encoded audio data
formatstringwavmp3——
fileobject——
filenamestring——
file_datastring——
file_idstring——
video_urlobject——
urlstring——
namestring—Sender name
tool_callsToolCall[]——
idstring——
typestring——
functionobject——
namestring——
argumentsstring——
tool_call_idstring—Tool call ID (for messages with the tool role)
reasoning_contentstring—Reasoning content
finish_reasonstringstoplengthtool_callscontent_filter——
usageUsage——
prompt_tokensinteger—Number of prompt tokens
completion_tokensinteger—Number of completion tokens
total_tokensinteger—Total number of tokens
prompt_tokens_detailsobject——
cached_tokensinteger——
text_tokensinteger——
audio_tokensinteger——
image_tokensinteger——
completion_tokens_detailsobject——
text_tokensinteger——
audio_tokensinteger——
reasoning_tokensinteger——
system_fingerprintstring——

400Invalid request parameters

FieldTypeRequiredDescription
errorobject——
messagestring—Error message
typestring—Error type
paramstring | null—The parameter involved
codestring | null—Error code

429Rate limit exceeded

FieldTypeRequiredDescription
errorobject——
messagestring—Error message
typestring—Error type
paramstring | null—The parameter involved
codestring | null—Error code

Example request

curl -X POST 'https://api.oletoken.ai/v1/chat/completions' \
  -H "Authorization: Bearer $OLETOKEN_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gpt-4",
    "messages": []
  }'