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
urlstringImage URL or base64 data
detailstringlowhighauto
input_audioobject
datastringBase64-encoded audio data
formatstringwavmp3
fileobject
filenamestring
file_datastring
file_idstring
video_urlobject
urlstring
namestringSender name
tool_callsToolCall[]
idstring
typestring
functionobject
namestring
argumentsstring
tool_call_idstringTool call ID (for messages with the tool role)
reasoning_contentstringReasoning content
temperaturenumber0–2default: 1Sampling temperature
top_pnumber0–1default: 1Nucleus sampling parameter
ninteger≥ 1default: 1Number of completions to generate
streambooleandefault: falseWhether to stream the response
stream_optionsobject
include_usageboolean
stopstring | string[]Stop sequences
max_tokensintegerMaximum number of tokens to generate
max_completion_tokensintegerMaximum number of completion tokens
presence_penaltynumber-2–2default: 0
frequency_penaltynumber-2–2default: 0
logit_biasobject
userstring
toolsTool[]
typestring
functionobject
namestring
descriptionstring
parametersobjectParameter definitions in JSON Schema format
tool_choicestring | objectnoneautorequired
typestring
functionobject
namestring
response_formatResponseFormat
typestringtextjson_objectjson_schema
json_schemaobjectJSON Schema definition
seedinteger
reasoning_effortstringlowmediumhighReasoning 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
urlstringImage URL or base64 data
detailstringlowhighauto
input_audioobject
datastringBase64-encoded audio data
formatstringwavmp3
fileobject
filenamestring
file_datastring
file_idstring
video_urlobject
urlstring
namestringSender name
tool_callsToolCall[]
idstring
typestring
functionobject
namestring
argumentsstring
tool_call_idstringTool call ID (for messages with the tool role)
reasoning_contentstringReasoning content
finish_reasonstringstoplengthtool_callscontent_filter
usageUsage
prompt_tokensintegerNumber of prompt tokens
completion_tokensintegerNumber of completion tokens
total_tokensintegerTotal 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
messagestringError message
typestringError type
paramstring | nullThe parameter involved
codestring | nullError code

429Rate limit exceeded

FieldTypeRequiredDescription
errorobject
messagestringError message
typestringError type
paramstring | nullThe parameter involved
codestring | nullError 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": []
  }'