Model ID to generate the response (e.g., gpt-4o, o3). Choose based on capabilities, performance, and price.
Overview
Create model responses to chat-style prompts with rich, multi-modal messages, optional tool calls, streaming, web search, and structured outputs.
/chat/completions — Create chat completion/chat/completions — List stored completions (when store was true)Examples
{
"model": "gpt-4o",
"messages": [
{ "role": "user", "content": "Write a haiku about recursion." }
]
}
{
"model": "gpt-4o",
"messages": [
{ "role": "developer", "content": "If a city is mentioned, use the weather tool." },
{ "role": "user", "content": "What's the weather in Rome?" }
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather",
"parameters": {
"type": "object",
"properties": { "city": { "type": "string" } },
"required": ["city"]
}
}
}
],
"tool_choice": "auto",
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "Weather",
"schema": {
"type": "object",
"properties": { "answer": { "type": "string" } },
"required": ["answer"]
},
"strict": true
}
},
"stream": true,
"stream_options": { "include_usage": true }
}
Core (Required)
Conversation history and inputs. Supports text, images, and audio in user messages; tool and function messaging for tool use; and assistant messages for continued turns.
1
discriminator: role
Roles & shapes (expanded)
Jump to: developer · system · user · assistant · tool · function (deprecated)
Developer instructions the model should always follow (supersedes legacy system for certain models).
Text instructions. As an array, provide text parts only.
[
{ "type": "text", "text": "You are a careful and concise assistant." }
]Optional participant name for disambiguation.
End-user prompts and context. Supports text, images, audio, and file inputs (model-dependent).
As an array, include one or more of the parts below.
text content part
image_url content part
input_audio content part
Model messages in multi-turn flows. Provide content when continuing; omit it when including tool_calls or legacy function_call.
Reference a previous audio response from the model.
tool_calls (assistant → tool)
id, type, function{
"id": "toolcall_1",
"type": "function",
"function": { "name": "get_weather", "arguments": "{\"city\":\"Rome\"}" }
}id, type, custom{
"id": "toolcall_2",
"type": "custom",
"custom": { "name": "search", "input": "pizza near 94107" }
}Replaced by tool_calls.
Legacy function channel. Prefer tool messages.
content, nameBehavior & Output
Output types to generate. Text is default; some models can also produce audio.
["text"] or ["text","audio"]Guide response length: concise vs. detail. (gpt-5 + reasoning)
Constrain reasoning token budget (reasoning models).
Upper bound for generated tokens (includes reasoning tokens).
Control the format of the model's output.
Text
{"type":"text"} (default behavior)JSON schema (Structured Outputs)
JSON object (legacy JSON mode)
{"type":"json_object"}. Prefer json_schema when supported.Streaming, Storage & Stops
Store the output for distillation/evals. Supports text & image inputs (images > 8MB dropped).
Return events via Server-Sent Events as tokens are generated.
Up to 4 sequences where generation will stop. Not supported with latest reasoning models o3 and o4-mini.
<|endoftext|>Sampling & Tuning
0–2. Raise for randomness, lower for determinism.
Nucleus sampling (0–1). Consider tokens covering the top p probability mass.
-2 to 2. Reduce repetition proportional to token frequency so far.
-2 to 2. Encourage introducing new topics.
Adjust token selection logit biases. Large magnitudes approximate ban/force.
Number of choices to generate (1–128). Billing is proportional to total output tokens.
Include log probabilities for output tokens.
Top-K (0–20) alternatives per token. Requires logprobs: true.
Tools & Function Calling
Allow the model to call custom tools or function tools.
Function tool
nameparameters is a JSON Schema describing the call signature. strict enforces schema (subset supported).
Custom tool
Define a named tool with an input format: free-form text or a grammar (with definition and syntax = lark|regex).
Control tool use. Defaults to none if no tools; auto if tools present.
Allowed tools
Constrain to a pre-defined set with mode = auto or required, and tools = tool definitions.
Force a specific tool
Function: {"type":"function","function":{"name":"get_weather"}}
Custom: {"type":"custom","custom":{"name":"search"}}
Permit parallel function calling.
Prediction, Safety & Caching
Provide static predicted content to accelerate responses when large parts are known.
{
"type": "content",
"content": "Constant file text…"
}Stable, hashed identifier to help detect policy violations.
Used for prompt caching in place of legacy user.
Request processing tier. Response echoes the tier actually used.
Up to 16 key/value pairs (keys ≤ 64 chars; values ≤ 512 chars) for your own labeling and filtering.
Web Search
body.web_search_options.search_context_sizeDeprecated controls
Replaced by prompt_cache_key (caching) and used historically as a safety identifier.
Best-effort determinism (Beta). Use system_fingerprint in responses to detect backend changes.
Replaced by max_completion_tokens. Not supported by o‑series reasoning models.
Use tool_choice instead.
Replaced by tools.
GET /chat/completions — List stored completions
Returns only completions generated with store: true.
Filter by model ID.
Filter by metadata pairs. Example: metadata[key1]=v1&metadata[key2]=v2
Use the last completion ID from a previous page to paginate.
Sort by timestamp ascending or descending.
Full Parameter Index (A–Z by path)
Each item links to its definition above.
audioaudio.formataudio.voicefrequency_penaltyfunction_callfunctionslogit_biaslogprobsmax_completion_tokensmax_tokensmessagesmessages[developer]messages[developer].contentmessages[developer].namemessages[system]messages[system].contentmessages[system].namemessages[user]messages[user].contentmessages[user].content[].type = textmessages[user].content[].textmessages[user].content[].type = image_urlmessages[user].content[].image_url.urlmessages[user].content[].image_url.detailmessages[user].content[].type = input_audiomessages[user].content[].input_audio.datamessages[user].content[].input_audio.formatmessages[user].content[].type = filemessages[user].content[].file.filenamemessages[user].content[].file.file_datamessages[user].content[].file.file_idmessages[user].namemessages[assistant]messages[assistant].contentmessages[assistant].refusalmessages[assistant].audio.idmessages[assistant].tool_calls[]messages[assistant].tool_calls[].functionmessages[assistant].tool_calls[].custommessages[assistant].function_callmessages[tool]messages[tool].contentmessages[tool].tool_call_idmessages[function]metadatamodelmodalities
nparallel_tool_callspredictionpresence_penaltyprompt_cache_keyreasoning_effortresponse_formatresponse_format.json_schemaresponse_format.json_schema.nameresponse_format.json_schema.schemaresponse_format.json_schema.strictsafety_identifierseedservice_tierstopstorestreamstream_optionsstream_options.include_usagestream_options.include_obfuscationtemperaturetool_choicetoolstools[].functiontools[].customtop_logprobstop_pverbosityweb_search_optionsweb_search_options.user_locationweb_search_options.user_location.typeweb_search_options.user_location.approximate...approximate.country...approximate.region...approximate.city...approximate.timezoneweb_search_options.search_context_size