gpt-4o-mini
openai/gpt-4o-mini — a llm model by OpenAI. Call it through the gateway’s standard OpenAI-compatible door using the catalog slug; the full parameter schema is reproduced in full below.
| Catalog slug | openai/gpt-4o-mini |
| Kind | llm |
| Vendor | OpenAI |
| Native model id | gpt-4o-mini |
How to call
Section titled “How to call”Through the Sociaro SDK / OpenAI-compatible door
Section titled “Through the Sociaro SDK / OpenAI-compatible door”from sociaro_ai import Sociaro
client = Sociaro(api_key="gw_live_...") # base_url defaults to https://api.sociaro.com
resp = client.chat.completions.create( model="openai/gpt-4o-mini", # always the catalog slug messages=[{"role": "user", "content": "Hello"}], # any parameter from the schema below is passed through unchanged)print(resp.choices[0].message.content)TypeScript: client.chat.completions.create({ model: "openai/gpt-4o-mini", messages: [...] }) — see the TypeScript SDK.
Through OpenAI’s native API (advanced)
Section titled “Through OpenAI’s native API (advanced)”Optional: send OpenAI’s native request to the /openai prefix, using the native model id gpt-4o-mini. The gateway injects the upstream OpenAI credential and forwards the body unchanged (catalog, pricing and entitlements still apply).
curl https://api.sociaro.com/openai/<native-path> \ -H "Authorization: Bearer $SOCIARO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini", ... }'The exact path, request body and response shape are documented in full in the schema below.
Parameters — full schema
Section titled “Parameters — full schema”The complete, one-to-one API schema for this model, transcribed from the official source. Nothing omitted. Examples in the schema may use a representative model of the family — for this model use the slug openai/gpt-4o-mini (or the native id gpt-4o-mini for the native API) as shown in How to call above.
Coverage map (models in this family)
Section titled “Coverage map (models in this family)”| author slug | reasoning model? | text | image input | audio input | audio output | web_search_options | notes |
|---|---|---|---|---|---|---|---|
openai/gpt-4o | no | yes | yes (image_url) | no | no | no | full sampling params (temperature/top_p/penalties/logit_bias/logprobs/n/stop) |
openai/gpt-4o-mini | no | yes | yes (image_url) | no | no | no | identical request/response shape to gpt-4o |
gpt-4o-2024-11-20, gpt-4o-2024-08-06, gpt-4o-2024-05-13 | no | yes | yes | no | no | no | dated gpt-4o snapshots; same contract |
gpt-4o-mini-2024-07-18 | no | yes | yes | no | no | no | dated gpt-4o-mini snapshot |
gpt-4o-audio-preview* | no | yes | yes | yes (input_audio) | yes (modalities:[“text”,“audio”] + audio param) | no | audio variant |
gpt-4o-mini-audio-preview* | no | yes | yes | yes | yes | no | audio variant |
gpt-4o-search-preview* | no | yes | yes | no | no | yes | search variant; emits message.annotations[url_citation] |
gpt-4o-mini-search-preview* | no | yes | yes | no | no | yes | search variant |
chatgpt-4o-latest | no | yes | yes | no | no | no | rolling alias |
All of the above slugs are part of the model enum of the create method. The same endpoint also serves gpt-4.1, gpt-4-turbo, gpt-3.5-turbo, the o1/o3/o4 reasoning models, and the gpt-5.x family.
Critical per-model differences (within openai-chat)
Section titled “Critical per-model differences (within openai-chat)”- Sampling params (
temperature,top_p,presence_penalty,frequency_penalty,logit_bias,logprobs/top_logprobs,max_tokens,stop,n) are fully supported by gpt-4o / gpt-4o-mini (non-reasoning).max_tokensis Deprecated in favor ofmax_completion_tokens(both work on gpt-4o;max_tokensis incompatible with o-series reasoning models). reasoning_effort,verbosityapply to reasoning / newer models; gpt-4o / gpt-4o-mini ignore them.reasoning_effortdefaults:mediumfor all models before gpt-5.1 (which do not supportnone);nonefor gpt-5.1 (gpt-5.1 supportsnone/low/medium/high);gpt-5-prodefaults to and only supportshigh;xhighis supported for all models aftergpt-5.1-codex-max.stopis NOT supported on the latest reasoning modelso3ando4-mini; works on gpt-4o (up to 4 sequences).- Audio output (
modalities:["text","audio"]+ theaudioparam) is supported ONLY bygpt-4o-audio-preview/gpt-4o-mini-audio-preview. Plain gpt-4o / gpt-4o-mini emit text only (image accepted on input viaimage_url). web_search_optionsis for*-search-previewvariants only.- Deprecations:
user→ replaced bysafety_identifier+prompt_cache_key;function_call/functions→ replaced bytool_choice/tools;seedis Beta and Deprecated;system_fingerprint(response) is Deprecated;max_tokensis Deprecated. prompt_cache_retentiondefault depends on org data-retention policy: orgs without ZDR default to24h, orgs with ZDR default toin_memory(when unspecified). Forgpt-5.5,gpt-5.5-pro, and future models only24his supported.
Gateway note
Section titled “Gateway note”In transparent mode the gateway passes the body through unchanged; this contract is what a client may send to openai/gpt-4o[-mini]. Server-behavior fields (store, metadata, service_tier, moderation) affect OpenAI-side behavior and may be irrelevant/inapplicable through the proxy.
Endpoint:
POST https://api.openai.com/v1/chat/completionsHeaders:Authorization: Bearer $OPENAI_API_KEY,Content-Type: application/jsonReturns: achat.completionobject (or a stream ofchat.completion.chunkobjects whenstream:true). Parameter support varies by model (see per-model differences above).
The Chat Completions resource also exposes stored-completion management methods (not generation): GET /chat/completions (list), GET /chat/completions/{completion_id} (retrieve), POST /chat/completions/{completion_id} (update), DELETE /chat/completions/{completion_id} (delete). These operate on completions stored via store:true and are not part of the create/generate flow. There is no async create/poll variant for this family — generation is synchronous (or streamed via SSE); the async pattern does not apply.
1. Request body — shape
Section titled “1. Request body — shape”{ "model": "gpt-4o", // required "messages": [ /* required */ ], // required, see §2.1 // --- optional generation / behavior params --- "audio": { "format": "...", "voice": "..." }, "frequency_penalty": 0, "logit_bias": { "<token_id>": 0 }, "logprobs": false, "max_completion_tokens": 0, "max_tokens": 0, // deprecated -> max_completion_tokens "metadata": { "<key>": "<value>" }, "modalities": ["text"], "moderation": { "model": "omni-moderation-latest" }, "n": 1, "parallel_tool_calls": true, "prediction": { "type": "content", "content": "..." }, "presence_penalty": 0, "prompt_cache_key": "...", "prompt_cache_retention": "in_memory" | "24h", "reasoning_effort": "...", // reasoning models "response_format": { "type": "text" | "json_object" | "json_schema", ... }, "safety_identifier": "...", "seed": 0, // beta/deprecated "service_tier": "auto", "stop": null, "store": false, "stream": false, "stream_options": { "include_usage": false, "include_obfuscation": true }, "temperature": 1, "tool_choice": "auto", "tools": [ /* see §3 */ ], "top_logprobs": 0, "top_p": 1, "user": "...", // deprecated "verbosity": "medium", // newer models "web_search_options": { ... }, // *-search-preview // deprecated "function_call": "none" | "auto" | { "name": "..." }, "functions": [ { "name": "...", "description": "...", "parameters": {...} } ]}2. Top-level request parameters (ALL)
Section titled “2. Top-level request parameters (ALL)”| name | type | required | default | allowed / range | description |
|---|---|---|---|---|---|
messages | array of message objects | yes | — | roles: developer, system, user, assistant, tool, function(deprecated) | List of conversation messages. Supported content types (text/image/audio/file) depend on the model. See §2.1. |
model | string (enum) | yes | — | incl. gpt-4o, gpt-4o-2024-11-20, gpt-4o-2024-08-06, gpt-4o-2024-05-13, gpt-4o-mini, gpt-4o-mini-2024-07-18, gpt-4o-audio-preview*, gpt-4o-mini-audio-preview*, gpt-4o-search-preview*, gpt-4o-mini-search-preview*, chatgpt-4o-latest, plus gpt-4.1, o1/o3/o4, gpt-5.x, gpt-4-turbo, gpt-3.5-turbo … | Model ID used to generate the response. |
audio | object {format, voice} (ChatCompletionAudioParam) | no | — | see §2.2 | Audio-output parameters. Required when audio output is requested via modalities:["audio"]. |
frequency_penalty | number | no | 0 | min -2.0, max 2.0 | Penalizes tokens by existing frequency in text so far, reducing verbatim repetition. |
function_call (Deprecated) | string | object | no | none if no functions, else auto | "none", "auto", or {"name": "my_function"} (ChatCompletionFunctionCallOption {name}) | Replaced by tool_choice. Controls which (if any) function is called. |
functions (Deprecated) | array of object {name, description, parameters} | no | — | name: a-z A-Z 0-9 _ -, maxLen 64 | Replaced by tools. List of functions the model may generate JSON inputs for. Omitting parameters = empty parameter list. |
logit_bias | map {token_id: number} | no | null | bias value -100..100 | Modifies likelihood of specified tokens. -1..1 nudge; -100/100 effectively ban / force. Effect varies per model. |
logprobs | boolean | no | false | true / false | Whether to return log probabilities of output tokens (in content of message). |
max_completion_tokens | number | no | — | integer > 0 | Upper bound on generated tokens, including visible output AND reasoning tokens. |
max_tokens (Deprecated) | number | no | — | integer > 0 | Max tokens generated in the chat completion. Replaced by max_completion_tokens; not compatible with o-series models. |
metadata | map (Metadata) | no | — | up to 16 pairs; key ≤64 chars, value ≤512 chars | Arbitrary key-value pairs for storing/querying extra info via API/dashboard. |
modalities | array of string | no | ["text"] | members: "text", "audio" | Output types the model should generate. ["text","audio"] for audio-capable models (e.g. gpt-4o-audio-preview). |
moderation | object {model} | no | — | model: e.g. omni-moderation-latest | Configuration for running moderation on the request input and generated output. |
n | number | no | 1 | min 1, max 128 | How many chat completion choices to generate per input. Billed across all choices; keep 1 to minimize cost. |
parallel_tool_calls | boolean | no | true | true / false | Whether to enable parallel function calling during tool use. |
prediction | object (ChatCompletionPredictionContent) {content, type} | no | — | type: "content" | Static predicted output (Predicted Outputs), e.g. content of a regenerated file. See §2.3. |
presence_penalty | number | no | 0 | min -2.0, max 2.0 | Penalizes tokens by whether they appear in text so far, increasing likelihood of new topics. |
prompt_cache_key | string | no | — | string | Used by OpenAI to cache responses for similar requests (optimizes cache-hit rate). Replaces the user field. |
prompt_cache_retention | string (enum) | no | depends on org ZDR policy (24h without ZDR; in_memory with ZDR) | "in_memory", "24h" | Prompt-cache retention policy. 24h = extended caching, prefixes kept active up to 24h. For gpt-5.5 / gpt-5.5-pro / future models only 24h is supported. |
reasoning_effort | string (enum) | no | model-dependent (medium pre-5.1; none for gpt-5.1; high for gpt-5-pro) | "none", "minimal", "low", "medium", "high", "xhigh" | Constrains reasoning effort (reasoning models). Less effort = faster / fewer reasoning tokens. (gpt-5.1 supports none/low/medium/high; xhigh only after gpt-5.1-codex-max.) |
response_format | object (oneOf) | no | { "type": "text" } | text | json_object | json_schema | Output format. json_schema = Structured Outputs. See §2.4. |
safety_identifier | string | no | — | maxLength 64 | Stable per-user ID to help detect policy violations. Recommend a hash of username/email. |
seed (Deprecated, Beta) | number | no | — | min -9223372036854775808, max 9223372036854775807 | Best-effort deterministic sampling for same seed+params. Determinism not guaranteed; monitor system_fingerprint. |
service_tier | string (enum) | no | "auto" | "auto", "default", "flex", "scale", "priority" | Processing type. When set, response echoes the service_tier actually used (may differ from the value sent). |
stop | string | array of string | no | null | up to 4 sequences | Stop sequences (excluded from output). NOT supported on latest reasoning models o3 and o4-mini. |
store | boolean | no | false | true / false | Whether to store output for model distillation / evals products. Supports text and image inputs (image inputs over 8MB are dropped). |
stream | boolean | no | false | true / false | Stream response data as server-sent events as generated. |
stream_options | object (ChatCompletionStreamOptions) {include_obfuscation, include_usage} | no | — | only set when stream:true | Streaming options. See §2.5. |
temperature | number | no | 1 | min 0, max 2 | Sampling temperature. Higher = more random, lower = more deterministic. Alter this OR top_p, not both. |
tool_choice | string | object (oneOf, ChatCompletionToolChoiceOption) | no | none if no tools, else auto | "none", "auto", "required"; allowed_tools; named function/custom | Controls which (if any) tool is called. See §3.2. |
tools | array (oneOf: function | custom, ChatCompletionTool) | no | — | function tools and/or custom tools | Tools the model may call. See §3.1. |
top_logprobs | number | no | — | integer min 0, max 20 | Number of most-likely tokens to return per position (each with logprob). Requires logprobs:true. |
top_p | number | no | 1 | min 0, max 1 | Nucleus sampling. 0.1 = only top-10% probability mass considered. Alter this OR temperature. |
user (Deprecated) | string | no | — | string | Stable end-user identifier. Being replaced by safety_identifier + prompt_cache_key (use prompt_cache_key for caching). |
verbosity | string (enum) | no | medium (newer models) | "low", "medium", "high" | Constrains response verbosity (newer models). Lower = more concise. |
web_search_options | object {search_context_size, user_location} | no | — | see §2.6 | Web-search tool for use in the response (*-search-preview models). |
2.1 messages[] — variants by role
Section titled “2.1 messages[] — variants by role”Developer message (ChatCompletionDeveloperMessageParam) {content, role:"developer", name?} — instructions the model follows regardless of the user (replaces system on o1+ models).
content: string | array ofChatCompletionContentPartText {text, type:"text"}(developer messages support onlytextparts).role:"developer"(required).name: optional string.
System message (ChatCompletionSystemMessageParam) {content, role:"system", name?} — same purpose as developer, for older models.
content: string | array of text parts (onlytext).role:"system".name: optional.
User message (ChatCompletionUserMessageParam) {content, role:"user", name?} — end-user content.
content: string | array of content parts. Part types:ChatCompletionContentPartText {text, type:"text"}ChatCompletionContentPartImage {image_url:{url, detail?}, type:"image_url"}—url: image URL or base64 (format: uri);detail:"auto"(default)|"low"|"high".ChatCompletionContentPartInputAudio {input_audio:{data, format}, type:"input_audio"}—data: base64;format:"wav"|"mp3".FileContentPart {file:{file_data?, file_id?, filename?}, type:"file"}—file_data: base64 file data;file_id: ID of an uploaded file;filename: name when passing as string.
role:"user".name: optional.
Assistant message (ChatCompletionAssistantMessageParam) {role:"assistant", audio?, content?, function_call?(deprecated), name?, refusal?, tool_calls?}
audio: optional{id}— reference to a previous audio response from the model.content: optional string | array of (ChatCompletionContentPartText {text, type:"text"}|ChatCompletionContentPartRefusal {refusal, type:"refusal"}). Can be one or moretext, or exactly onerefusal. Required unlesstool_callsorfunction_callis specified.function_call(deprecated):{arguments, name}.refusal: optional string.name: optional string.tool_calls: optional array of:- function tool call:
{id, function:{arguments, name}, type:"function"} - custom tool call:
{id, custom:{input, name}, type:"custom"}
- function tool call:
Tool message (ChatCompletionToolMessageParam) {content, role:"tool", tool_call_id}
content: string | array of text parts.role:"tool".tool_call_id: string (ID of the tool call this responds to).
Function message (Deprecated) (ChatCompletionFunctionMessageParam) {content, name, role:"function"}.
2.2 audio (ChatCompletionAudioParam — request, output config)
Section titled “2.2 audio (ChatCompletionAudioParam — request, output config)”| field | type | required | allowed |
|---|---|---|---|
format | string (enum) | yes (within object) | "wav", "aac", "mp3", "flac", "opus", "pcm16" |
voice | string | enum | object {id} | yes (within object) | built-in voices: alloy, ash, ballad, coral, echo, fable, nova, onyx, sage, shimmer, verse, marin, cedar; OR a custom voice object, e.g. { "id": "voice_1234" }. |
2.3 prediction (ChatCompletionPredictionContent)
Section titled “2.3 prediction (ChatCompletionPredictionContent)”| field | type | required | allowed |
|---|---|---|---|
content | string | array of ChatCompletionContentPartText {text, type:"text"} | yes | The content to match when generating; if generated tokens match, the response can be returned faster. |
type | string | yes | "content" (currently always content) |
2.4 response_format (oneOf)
Section titled “2.4 response_format (oneOf)”-
{ "type": "text" }(ResponseFormatText) — default, plain text response. -
{ "type": "json_object" }(ResponseFormatJSONObject) — older JSON mode; requires a system/user instruction to produce JSON. -
{ "type": "json_schema", "json_schema": {...} }(ResponseFormatJSONSchema) — Structured Outputs:field type required allowed namestring yes a-z A-Z 0-9 _-, maxLen 64descriptionstring no — schemamap (JSON Schema object) no JSON Schema object strictboolean no true= strict schema adherence; only a subset of JSON Schema supported whenstrictistruetypestring yes "json_schema"
2.5 stream_options (ChatCompletionStreamOptions)
Section titled “2.5 stream_options (ChatCompletionStreamOptions)”| field | type | required | default | description |
|---|---|---|---|---|
include_obfuscation | boolean | no | true (included by default) | Adds random chars to an obfuscation field on streaming delta events to normalize payload sizes (side-channel mitigation). Set false to optimize bandwidth on trusted links. |
include_usage | boolean | no | false | If set, an extra chunk is streamed before data: [DONE] whose usage field holds whole-request token stats and choices is []. All other chunks carry usage:null. If the stream is interrupted, the final usage chunk may not arrive. |
2.6 web_search_options
Section titled “2.6 web_search_options”| field | type | required | default | allowed |
|---|---|---|---|---|
search_context_size | string (enum) | no | medium | "low", "medium", "high" |
user_location | object {approximate, type:"approximate"} | no | — | approximate {city?, country?, region?, timezone?}; country = two-letter ISO; timezone = IANA (e.g. America/Los_Angeles); city/region free text; type always "approximate" |
3. tools / tool_choice
Section titled “3. tools / tool_choice”3.1 tools[] (oneOf, ChatCompletionTool)
Section titled “3.1 tools[] (oneOf, ChatCompletionTool)”Function tool (ChatCompletionFunctionTool) {type:"function", function:{name, description?, parameters?, strict?}}
| field | type | required | allowed |
|---|---|---|---|
function.name | string | yes | a-z A-Z 0-9 _ -, maxLen 64 |
function.description | string | no | — |
function.parameters | object (FunctionParameters / JSON Schema) | no | omitting = empty parameter list |
function.strict | boolean | no | true = strict schema adherence (Structured Outputs); only a subset of JSON Schema supported when strict |
type | string | yes | "function" (currently only function supported as a tool type here) |
Custom tool (ChatCompletionCustomTool) {type:"custom", custom:{name, description?, format?}}
custom.name: string (required) — identifies the tool in tool calls.custom.description: optional string.custom.format(oneOf, default = unconstrained text):TextFormat {type:"text"}— unconstrained free-form text.GrammarFormat {type:"grammar", grammar:{definition, syntax}}—definition: grammar definition string;syntax:"lark"|"regex".
3.2 tool_choice (oneOf, ChatCompletionToolChoiceOption)
Section titled “3.2 tool_choice (oneOf, ChatCompletionToolChoiceOption)”- ToolChoiceMode =
"none"|"auto"|"required". (none= no tool, generate a message;auto= model picks;required= must call ≥1 tool.) - Allowed tools (ChatCompletionAllowedToolChoice)
{type:"allowed_tools", allowed_tools:{mode, tools}}—mode:"auto"|"required";tools: array of tool definition maps, e.g.[{ "type":"function", "function":{ "name":"get_weather" } }]. - Named function (ChatCompletionNamedToolChoice)
{type:"function", function:{name}}. - Named custom (ChatCompletionNamedToolChoiceCustom)
{type:"custom", custom:{name}}.
Default: none when no tools present, auto when tools present.
4. Response — chat.completion object
Section titled “4. Response — chat.completion object”{ "id": "string", "object": "chat.completion", "created": 1741569952, // unix time "model": "gpt-4o-...", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "string|null", "refusal": "string|null", "annotations": [ { "type": "url_citation", "url_citation": {...} } ], "audio": { "id", "data", "expires_at", "transcript" }, // if audio output "tool_calls": [ ... ], "function_call": { "arguments", "name" } // deprecated }, "logprobs": { "content": [...], "refusal": [...] } | null, "finish_reason": "stop" } ], "usage": { ... }, "service_tier": "default", "system_fingerprint": "string", // deprecated "moderation": { "input": {...}, "output": {...} } // if moderated completions requested}4.1 Response fields
Section titled “4.1 Response fields”| field | type | description |
|---|---|---|
id | string | Unique identifier for the chat completion. |
choices | array | List of choices (>1 if n>1). |
choices[].finish_reason | enum | "stop", "length", "tool_calls", "content_filter", "function_call"(deprecated). |
choices[].index | number | Index of the choice in the list. |
choices[].logprobs | object | null | {content[], refusal[]}; each item is a ChatCompletionTokenLogprob {token, bytes[](nullable), logprob, top_logprobs[]}; top_logprobs[] entries are {token, bytes[], logprob}; logprob = -9999.0 if outside top-20. |
choices[].message.content | string | Message contents. |
choices[].message.refusal | string | Refusal message generated by the model. |
choices[].message.role | "assistant" | Role of the author. |
choices[].message.annotations | array | {type:"url_citation", url_citation:{end_index, start_index, title, url}} (present when using web search). |
choices[].message.audio | object | {id, data(base64), expires_at(unixtime), transcript} (if audio output modality requested). |
choices[].message.function_call (deprecated) | object | {arguments, name}. |
choices[].message.tool_calls | array | function: ChatCompletionMessageFunctionToolCall {id, function:{arguments, name}, type:"function"}; custom: ChatCompletionMessageCustomToolCall {id, custom:{input, name}, type:"custom"}. |
created | number | Unix timestamp (seconds) of creation. |
model | string | Model used for the completion. |
object | "chat.completion" | Object type (always chat.completion). |
service_tier | enum | Tier actually used: auto/default/flex/scale/priority. |
system_fingerprint (Deprecated) | string | Backend-configuration fingerprint (use with seed to detect backend changes). |
moderation | object | {input, output} (present if moderated completions were requested). Each side is ModerationResults {model, results[], type:"moderation_results"} OR Error {code, message, type:"error"}. Each entry in results[] is {categories(map[bool]), category_applied_input_types(map[array of "text"/"image"]), category_scores(map[number]), flagged(bool), model(string), type:"moderation_result"}. |
usage | object (CompletionUsage) | Token usage statistics; see §4.2. |
4.2 usage (CompletionUsage)
Section titled “4.2 usage (CompletionUsage)”| field | type | description |
|---|---|---|
completion_tokens | number | Tokens in the generated completion. |
prompt_tokens | number | Tokens in the prompt. |
total_tokens | number | Total = prompt + completion. |
completion_tokens_details | object | {accepted_prediction_tokens?, audio_tokens?, reasoning_tokens?, rejected_prediction_tokens?}. accepted_prediction_tokens / rejected_prediction_tokens = Predicted-Outputs hits/misses (rejected still billed); reasoning_tokens = tokens spent on reasoning; audio_tokens = audio tokens generated by the model. |
prompt_tokens_details | object | {audio_tokens?, cached_tokens?}. audio_tokens = audio input tokens in the prompt; cached_tokens = cached tokens in the prompt. |
4.3 Streaming chunk (chat.completion.chunk)
Section titled “4.3 Streaming chunk (chat.completion.chunk)”When stream:true, the response is a stream of chat.completion.chunk objects carrying choices[].delta (incremental) instead of choices[].message. With stream_options.include_usage:true, a final chunk before data: [DONE] carries the whole-request usage and choices = []; all other chunks carry usage: null.
5. MINIMAL example
Section titled “5. MINIMAL example”Request
curl https://api.openai.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ "model": "gpt-4o", "messages": [ { "role": "developer", "content": "You are a helpful assistant." }, { "role": "user", "content": "Hello!" } ] }'Response
{ "id": "chatcmpl-B9MBs8CjcvOU2jLn4n570S5qMJKcT", "object": "chat.completion", "created": 1741569952, "model": "gpt-4o", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello! How can I assist you today?", "refusal": null, "annotations": [] }, "logprobs": null, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 19, "completion_tokens": 10, "total_tokens": 29, "prompt_tokens_details": { "cached_tokens": 0, "audio_tokens": 0 }, "completion_tokens_details": { "reasoning_tokens": 0, "audio_tokens": 0, "accepted_prediction_tokens": 0, "rejected_prediction_tokens": 0 } }, "service_tier": "default"}Streaming (stream:true) — stream of chunks:
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]}{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]}{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-4o-mini","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]}6. FULL examples (vision + tools + structured-style options + audio)
Section titled “6. FULL examples (vision + tools + structured-style options + audio)”Vision (image input) — request
curl https://api.openai.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ "model": "gpt-4o", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "What is in this image?" }, { "type": "image_url", "image_url": { "url": "https://.../boardwalk.jpg", "detail": "auto" } } ] } ], "max_tokens": 300 }'Function calling — request
curl https://api.openai.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ "model": "gpt-4o", "messages": [ { "role": "user", "content": "What is the weather like in Boston today?" } ], "tools": [ { "type": "function", "function": { "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" }, "unit": { "type": "string", "enum": ["celsius", "fahrenheit"] } }, "required": ["location"] }, "strict": true } } ], "tool_choice": "auto", "parallel_tool_calls": true, "temperature": 0.7, "top_p": 1, "frequency_penalty": 0, "presence_penalty": 0, "n": 1, "stop": null, "max_completion_tokens": 512, "response_format": { "type": "text" }, "logprobs": true, "top_logprobs": 5, "seed": 42, "store": false, "metadata": { "session": "abc" }, "service_tier": "auto", "stream": false, "prompt_cache_key": "user-123" }'Function calling — response
{ "id": "chatcmpl-abc123", "object": "chat.completion", "created": 1699896916, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": { "role": "assistant", "content": null, "tool_calls": [ { "id": "call_abc123", "type": "function", "function": { "name": "get_current_weather", "arguments": "{\n\"location\": \"Boston, MA\"\n}" } } ] }, "logprobs": null, "finish_reason": "tool_calls" } ], "usage": { "prompt_tokens": 82, "completion_tokens": 17, "total_tokens": 99, "completion_tokens_details": { "reasoning_tokens": 0, "accepted_prediction_tokens": 0, "rejected_prediction_tokens": 0 } }}Structured Outputs — response_format with json_schema (request fragment)
"response_format": { "type": "json_schema", "json_schema": { "name": "weather", "description": "structured weather", "strict": true, "schema": { "type": "object", "properties": { "temp_c": { "type": "number" } }, "required": ["temp_c"], "additionalProperties": false } }}Audio output (audio variant model) — request fragment
{ "model": "gpt-4o-audio-preview", "modalities": ["text", "audio"], "audio": { "voice": "alloy", "format": "wav" }, "messages": [ { "role": "user", "content": "Is a golden retriever a good family dog?" } ]}Audio input (audio variant model) — user message content part
{ "role": "user", "content": [ { "type": "text", "text": "Transcribe and answer this." }, { "type": "input_audio", "input_audio": { "data": "<base64>", "format": "mp3" } } ]}