cli/resources/chat/index.md +0 −4652 deleted
File Deleted View Diff
1# Chat
2
3# Completions
4
5## Create chat completion
6
7`$ openai chat:completions create`
8
9**post** `/chat/completions`
10
11**Starting a new project?** We recommend trying [Responses](https://platform.openai.com/docs/api-reference/responses)
12to take advantage of the latest OpenAI platform features. Compare
13[Chat Completions with Responses](https://platform.openai.com/docs/guides/responses-vs-chat-completions?api-mode=responses).
14
15
16Creates a model response for the given chat conversation. Learn more in the
17[text generation](https://platform.openai.com/docs/guides/text-generation), [vision](https://platform.openai.com/docs/guides/vision),
18and [audio](https://platform.openai.com/docs/guides/audio) guides.
19
20Parameter support can differ depending on the model used to generate the
21response, particularly for newer reasoning models. Parameters that are only
22supported for reasoning models are noted below. For the current state of
23unsupported parameters in reasoning models,
24[refer to the reasoning guide](https://platform.openai.com/docs/guides/reasoning).
25
26Returns a chat completion object, or a streamed sequence of chat completion
27chunk objects if the request is streamed.
28
29### Parameters
30
31- `--message: array of ChatCompletionMessageParam`
32
33 A list of messages comprising the conversation so far. Depending on the
34 [model](https://platform.openai.com/docs/models) you use, different message types (modalities) are
35 supported, like [text](https://platform.openai.com/docs/guides/text-generation),
36 [images](https://platform.openai.com/docs/guides/vision), and [audio](https://platform.openai.com/docs/guides/audio).
37
38- `--model: string or ChatModel`
39
40 Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI
41 offers a wide range of models with different capabilities, performance
42 characteristics, and price points. Refer to the [model guide](https://platform.openai.com/docs/models)
43 to browse and compare available models.
44
45- `--audio: optional object { format, voice }`
46
47 Parameters for audio output. Required when audio output is requested with
48 `modalities: ["audio"]`. [Learn more](https://platform.openai.com/docs/guides/audio).
49
50- `--frequency-penalty: optional number`
51
52 Number between -2.0 and 2.0. Positive values penalize new tokens based on
53 their existing frequency in the text so far, decreasing the model's
54 likelihood to repeat the same line verbatim.
55
56- `--function-call: optional "none" or "auto" or ChatCompletionFunctionCallOption`
57
58 Deprecated in favor of `tool_choice`.
59
60 Controls which (if any) function is called by the model.
61
62 `none` means the model will not call a function and instead generates a
63 message.
64
65 `auto` means the model can pick between generating a message or calling a
66 function.
67
68 Specifying a particular function via `{"name": "my_function"}` forces the
69 model to call that function.
70
71 `none` is the default when no functions are present. `auto` is the default
72 if functions are present.
73
74- `--function: optional array of object { name, description, parameters }`
75
76 Deprecated in favor of `tools`.
77
78 A list of functions the model may generate JSON inputs for.
79
80- `--logit-bias: optional map[number]`
81
82 Modify the likelihood of specified tokens appearing in the completion.
83
84 Accepts a JSON object that maps tokens (specified by their token ID in the
85 tokenizer) to an associated bias value from -100 to 100. Mathematically,
86 the bias is added to the logits generated by the model prior to sampling.
87 The exact effect will vary per model, but values between -1 and 1 should
88 decrease or increase likelihood of selection; values like -100 or 100
89 should result in a ban or exclusive selection of the relevant token.
90
91- `--logprobs: optional boolean`
92
93 Whether to return log probabilities of the output tokens or not. If true,
94 returns the log probabilities of each output token returned in the
95 `content` of `message`.
96
97- `--max-completion-tokens: optional number`
98
99 An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
100
101- `--max-tokens: optional number`
102
103 The maximum number of [tokens](/tokenizer) that can be generated in the
104 chat completion. This value can be used to control
105 [costs](https://openai.com/api/pricing/) for text generated via API.
106
107 This value is now deprecated in favor of `max_completion_tokens`, and is
108 not compatible with [o-series models](https://platform.openai.com/docs/guides/reasoning).
109
110- `--metadata: optional map[string]`
111
112 Set of 16 key-value pairs that can be attached to an object. This can be
113 useful for storing additional information about the object in a structured
114 format, and querying for objects via API or the dashboard.
115
116 Keys are strings with a maximum length of 64 characters. Values are strings
117 with a maximum length of 512 characters.
118
119- `--modality: optional array of "text" or "audio"`
120
121 Output types that you would like the model to generate.
122 Most models are capable of generating text, which is the default:
123
124 `["text"]`
125
126 The `gpt-4o-audio-preview` model can also be used to
127 [generate audio](https://platform.openai.com/docs/guides/audio). To request that this model generate
128 both text and audio responses, you can use:
129
130 `["text", "audio"]`
131
132- `--n: optional number`
133
134 How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs.
135
136- `--parallel-tool-calls: optional boolean`
137
138 Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.
139
140- `--prediction: optional object { content, type }`
141
142 Static predicted output content, such as the content of a text file that is
143 being regenerated.
144
145- `--presence-penalty: optional number`
146
147 Number between -2.0 and 2.0. Positive values penalize new tokens based on
148 whether they appear in the text so far, increasing the model's likelihood
149 to talk about new topics.
150
151- `--prompt-cache-key: optional string`
152
153 Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the `user` field. [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
154
155- `--prompt-cache-retention: optional "in_memory" or "24h"`
156
157 The retention policy for the prompt cache. Set to `24h` to enable extended prompt caching, which keeps cached prefixes active for longer, up to a maximum of 24 hours. [Learn more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
158
159- `--reasoning-effort: optional "none" or "minimal" or "low" or 3 more`
160
161 Constrains effort on reasoning for
162 [reasoning models](https://platform.openai.com/docs/guides/reasoning).
163 Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing
164 reasoning effort can result in faster responses and fewer tokens used
165 on reasoning in a response.
166
167 - `gpt-5.1` defaults to `none`, which does not perform reasoning. The supported reasoning values for `gpt-5.1` are `none`, `low`, `medium`, and `high`. Tool calls are supported for all reasoning values in gpt-5.1.
168 - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.
169 - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
170 - `xhigh` is supported for all models after `gpt-5.1-codex-max`.
171
172- `--response-format: optional ResponseFormatText or ResponseFormatJSONSchema or ResponseFormatJSONObject`
173
174 An object specifying the format that the model must output.
175
176 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables
177 Structured Outputs which ensures the model will match your supplied JSON
178 schema. Learn more in the [Structured Outputs
179 guide](https://platform.openai.com/docs/guides/structured-outputs).
180
181 Setting to `{ "type": "json_object" }` enables the older JSON mode, which
182 ensures the message the model generates is valid JSON. Using `json_schema`
183 is preferred for models that support it.
184
185- `--safety-identifier: optional string`
186
187 A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies.
188 The IDs should be a string that uniquely identifies each user, with a maximum length of 64 characters. We recommend hashing their username or email address, in order to avoid sending us any identifying information. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
189
190- `--seed: optional number`
191
192 This feature is in Beta.
193 If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.
194 Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.
195
196- `--service-tier: optional "auto" or "default" or "flex" or 2 more`
197
198 Specifies the processing type used for serving the request.
199
200 - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.
201 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.
202 - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or '[priority](https://openai.com/api-priority-processing/)', then the request will be processed with the corresponding service tier.
203 - When not set, the default behavior is 'auto'.
204
205 When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
206
207- `--stop: optional string or array of string`
208
209 Not supported with latest reasoning models `o3` and `o4-mini`.
210
211 Up to 4 sequences where the API will stop generating further tokens. The
212 returned text will not contain the stop sequence.
213
214- `--store: optional boolean`
215
216 Whether or not to store the output of this chat completion request for
217 use in our [model distillation](https://platform.openai.com/docs/guides/distillation) or
218 [evals](https://platform.openai.com/docs/guides/evals) products.
219
220 Supports text and image inputs. Note: image inputs over 8MB will be dropped.
221
222- `--stream-options: optional object { include_obfuscation, include_usage }`
223
224 Options for streaming response. Only set this when you set `stream: true`.
225
226- `--temperature: optional number`
227
228 What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
229 We generally recommend altering this or `top_p` but not both.
230
231- `--tool-choice: optional "none" or "auto" or "required" or ChatCompletionAllowedToolChoice or ChatCompletionNamedToolChoice or ChatCompletionNamedToolChoiceCustom`
232
233 Controls which (if any) tool is called by the model.
234 `none` means the model will not call any tool and instead generates a message.
235 `auto` means the model can pick between generating a message or calling one or more tools.
236 `required` means the model must call one or more tools.
237 Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.
238
239 `none` is the default when no tools are present. `auto` is the default if tools are present.
240
241- `--tool: optional array of ChatCompletionTool`
242
243 A list of tools the model may call. You can provide either
244 [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools) or
245 [function tools](https://platform.openai.com/docs/guides/function-calling).
246
247- `--top-logprobs: optional number`
248
249 An integer between 0 and 20 specifying the maximum number of most likely
250 tokens to return at each token position, each with an associated log
251 probability. In some cases, the number of returned tokens may be fewer than
252 requested.
253 `logprobs` must be set to `true` if this parameter is used.
254
255- `--top-p: optional number`
256
257 An alternative to sampling with temperature, called nucleus sampling,
258 where the model considers the results of the tokens with top_p probability
259 mass. So 0.1 means only the tokens comprising the top 10% probability mass
260 are considered.
261
262 We generally recommend altering this or `temperature` but not both.
263
264- `--user: optional string`
265
266 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.
267 A stable identifier for your end-users.
268 Used to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
269
270- `--verbosity: optional "low" or "medium" or "high"`
271
272 Constrains the verbosity of the model's response. Lower values will result in
273 more concise responses, while higher values will result in more verbose responses.
274 Currently supported values are `low`, `medium`, and `high`.
275
276- `--web-search-options: optional object { search_context_size, user_location }`
277
278 This tool searches the web for relevant results to use in a response.
279 Learn more about the [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
280
281### Returns
282
283- `chat_completion: object { id, choices, created, 5 more }`
284
285 Represents a chat completion response returned by model, based on the provided input.
286
287 - `id: string`
288
289 A unique identifier for the chat completion.
290
291 - `choices: array of object { finish_reason, index, logprobs, message }`
292
293 A list of chat completion choices. Can be more than one if `n` is greater than 1.
294
295 - `finish_reason: "stop" or "length" or "tool_calls" or 2 more`
296
297 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
298 `length` if the maximum number of tokens specified in the request was reached,
299 `content_filter` if content was omitted due to a flag from our content filters,
300 `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
301
302 - `"stop"`
303
304 - `"length"`
305
306 - `"tool_calls"`
307
308 - `"content_filter"`
309
310 - `"function_call"`
311
312 - `index: number`
313
314 The index of the choice in the list of choices.
315
316 - `logprobs: object { content, refusal }`
317
318 Log probability information for the choice.
319
320 - `content: array of ChatCompletionTokenLogprob`
321
322 A list of message content tokens with log probability information.
323
324 - `token: string`
325
326 The token.
327
328 - `bytes: array of number`
329
330 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
331
332 - `logprob: number`
333
334 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
335
336 - `top_logprobs: array of object { token, bytes, logprob }`
337
338 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
339
340 - `token: string`
341
342 The token.
343
344 - `bytes: array of number`
345
346 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
347
348 - `logprob: number`
349
350 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
351
352 - `refusal: array of ChatCompletionTokenLogprob`
353
354 A list of message refusal tokens with log probability information.
355
356 - `token: string`
357
358 The token.
359
360 - `bytes: array of number`
361
362 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
363
364 - `logprob: number`
365
366 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
367
368 - `top_logprobs: array of object { token, bytes, logprob }`
369
370 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
371
372 - `message: object { content, refusal, role, 4 more }`
373
374 A chat completion message generated by the model.
375
376 - `content: string`
377
378 The contents of the message.
379
380 - `refusal: string`
381
382 The refusal message generated by the model.
383
384 - `role: "assistant"`
385
386 The role of the author of this message.
387
388 - `annotations: optional array of object { type, url_citation }`
389
390 Annotations for the message, when applicable, as when using the
391 [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
392
393 - `type: "url_citation"`
394
395 The type of the URL citation. Always `url_citation`.
396
397 - `url_citation: object { end_index, start_index, title, url }`
398
399 A URL citation when using web search.
400
401 - `end_index: number`
402
403 The index of the last character of the URL citation in the message.
404
405 - `start_index: number`
406
407 The index of the first character of the URL citation in the message.
408
409 - `title: string`
410
411 The title of the web resource.
412
413 - `url: string`
414
415 The URL of the web resource.
416
417 - `audio: optional object { id, data, expires_at, transcript }`
418
419 If the audio output modality is requested, this object contains data
420 about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).
421
422 - `id: string`
423
424 Unique identifier for this audio response.
425
426 - `data: string`
427
428 Base64 encoded audio bytes generated by the model, in the format
429 specified in the request.
430
431 - `expires_at: number`
432
433 The Unix timestamp (in seconds) for when this audio response will
434 no longer be accessible on the server for use in multi-turn
435 conversations.
436
437 - `transcript: string`
438
439 Transcript of the audio generated by the model.
440
441 - `function_call: optional object { arguments, name }`
442
443 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
444
445 - `arguments: string`
446
447 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
448
449 - `name: string`
450
451 The name of the function to call.
452
453 - `tool_calls: optional array of ChatCompletionMessageToolCall`
454
455 The tool calls generated by the model, such as function calls.
456
457 - `chat_completion_message_function_tool_call: object { id, function, type }`
458
459 A call to a function tool created by the model.
460
461 - `id: string`
462
463 The ID of the tool call.
464
465 - `function: object { arguments, name }`
466
467 The function that the model called.
468
469 - `arguments: string`
470
471 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
472
473 - `name: string`
474
475 The name of the function to call.
476
477 - `type: "function"`
478
479 The type of the tool. Currently, only `function` is supported.
480
481 - `chat_completion_message_custom_tool_call: object { id, custom, type }`
482
483 A call to a custom tool created by the model.
484
485 - `id: string`
486
487 The ID of the tool call.
488
489 - `custom: object { input, name }`
490
491 The custom tool that the model called.
492
493 - `input: string`
494
495 The input for the custom tool call generated by the model.
496
497 - `name: string`
498
499 The name of the custom tool to call.
500
501 - `type: "custom"`
502
503 The type of the tool. Always `custom`.
504
505 - `created: number`
506
507 The Unix timestamp (in seconds) of when the chat completion was created.
508
509 - `model: string`
510
511 The model used for the chat completion.
512
513 - `object: "chat.completion"`
514
515 The object type, which is always `chat.completion`.
516
517 - `service_tier: optional "auto" or "default" or "flex" or 2 more`
518
519 Specifies the processing type used for serving the request.
520
521 - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.
522 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.
523 - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or '[priority](https://openai.com/api-priority-processing/)', then the request will be processed with the corresponding service tier.
524 - When not set, the default behavior is 'auto'.
525
526 When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
527
528 - `"auto"`
529
530 - `"default"`
531
532 - `"flex"`
533
534 - `"scale"`
535
536 - `"priority"`
537
538 - `system_fingerprint: optional string`
539
540 This fingerprint represents the backend configuration that the model runs with.
541
542 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
543
544 - `usage: optional object { completion_tokens, prompt_tokens, total_tokens, 2 more }`
545
546 Usage statistics for the completion request.
547
548 - `completion_tokens: number`
549
550 Number of tokens in the generated completion.
551
552 - `prompt_tokens: number`
553
554 Number of tokens in the prompt.
555
556 - `total_tokens: number`
557
558 Total number of tokens used in the request (prompt + completion).
559
560 - `completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, rejected_prediction_tokens }`
561
562 Breakdown of tokens used in a completion.
563
564 - `accepted_prediction_tokens: optional number`
565
566 When using Predicted Outputs, the number of tokens in the
567 prediction that appeared in the completion.
568
569 - `audio_tokens: optional number`
570
571 Audio input tokens generated by the model.
572
573 - `reasoning_tokens: optional number`
574
575 Tokens generated by the model for reasoning.
576
577 - `rejected_prediction_tokens: optional number`
578
579 When using Predicted Outputs, the number of tokens in the
580 prediction that did not appear in the completion. However, like
581 reasoning tokens, these tokens are still counted in the total
582 completion tokens for purposes of billing, output, and context window
583 limits.
584
585 - `prompt_tokens_details: optional object { audio_tokens, cached_tokens }`
586
587 Breakdown of tokens used in the prompt.
588
589 - `audio_tokens: optional number`
590
591 Audio input tokens present in the prompt.
592
593 - `cached_tokens: optional number`
594
595 Cached tokens present in the prompt.
596
597### Example
598
599```cli
600openai chat:completions create \
601 --api-key 'My API Key' \
602 --message '{content: string, role: developer}' \
603 --model gpt-5.4
604```
605
606#### Response
607
608```json
609{
610 "id": "id",
611 "choices": [
612 {
613 "finish_reason": "stop",
614 "index": 0,
615 "logprobs": {
616 "content": [
617 {
618 "token": "token",
619 "bytes": [
620 0
621 ],
622 "logprob": 0,
623 "top_logprobs": [
624 {
625 "token": "token",
626 "bytes": [
627 0
628 ],
629 "logprob": 0
630 }
631 ]
632 }
633 ],
634 "refusal": [
635 {
636 "token": "token",
637 "bytes": [
638 0
639 ],
640 "logprob": 0,
641 "top_logprobs": [
642 {
643 "token": "token",
644 "bytes": [
645 0
646 ],
647 "logprob": 0
648 }
649 ]
650 }
651 ]
652 },
653 "message": {
654 "content": "content",
655 "refusal": "refusal",
656 "role": "assistant",
657 "annotations": [
658 {
659 "type": "url_citation",
660 "url_citation": {
661 "end_index": 0,
662 "start_index": 0,
663 "title": "title",
664 "url": "https://example.com"
665 }
666 }
667 ],
668 "audio": {
669 "id": "id",
670 "data": "data",
671 "expires_at": 0,
672 "transcript": "transcript"
673 },
674 "function_call": {
675 "arguments": "arguments",
676 "name": "name"
677 },
678 "tool_calls": [
679 {
680 "id": "id",
681 "function": {
682 "arguments": "arguments",
683 "name": "name"
684 },
685 "type": "function"
686 }
687 ]
688 }
689 }
690 ],
691 "created": 0,
692 "model": "model",
693 "object": "chat.completion",
694 "service_tier": "auto",
695 "system_fingerprint": "system_fingerprint",
696 "usage": {
697 "completion_tokens": 0,
698 "prompt_tokens": 0,
699 "total_tokens": 0,
700 "completion_tokens_details": {
701 "accepted_prediction_tokens": 0,
702 "audio_tokens": 0,
703 "reasoning_tokens": 0,
704 "rejected_prediction_tokens": 0
705 },
706 "prompt_tokens_details": {
707 "audio_tokens": 0,
708 "cached_tokens": 0
709 }
710 }
711}
712```
713
714## List Chat Completions
715
716`$ openai chat:completions list`
717
718**get** `/chat/completions`
719
720List stored Chat Completions. Only Chat Completions that have been stored
721with the `store` parameter set to `true` will be returned.
722
723### Parameters
724
725- `--after: optional string`
726
727 Identifier for the last chat completion from the previous pagination request.
728
729- `--limit: optional number`
730
731 Number of Chat Completions to retrieve.
732
733- `--metadata: optional map[string]`
734
735 A list of metadata keys to filter the Chat Completions by. Example:
736
737 `metadata[key1]=value1&metadata[key2]=value2`
738
739- `--model: optional string`
740
741 The model used to generate the Chat Completions.
742
743- `--order: optional "asc" or "desc"`
744
745 Sort order for Chat Completions by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.
746
747### Returns
748
749- `ChatCompletionList: object { data, first_id, has_more, 2 more }`
750
751 An object representing a list of Chat Completions.
752
753 - `data: array of ChatCompletion`
754
755 An array of chat completion objects.
756
757 - `id: string`
758
759 A unique identifier for the chat completion.
760
761 - `choices: array of object { finish_reason, index, logprobs, message }`
762
763 A list of chat completion choices. Can be more than one if `n` is greater than 1.
764
765 - `finish_reason: "stop" or "length" or "tool_calls" or 2 more`
766
767 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
768 `length` if the maximum number of tokens specified in the request was reached,
769 `content_filter` if content was omitted due to a flag from our content filters,
770 `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
771
772 - `"stop"`
773
774 - `"length"`
775
776 - `"tool_calls"`
777
778 - `"content_filter"`
779
780 - `"function_call"`
781
782 - `index: number`
783
784 The index of the choice in the list of choices.
785
786 - `logprobs: object { content, refusal }`
787
788 Log probability information for the choice.
789
790 - `content: array of ChatCompletionTokenLogprob`
791
792 A list of message content tokens with log probability information.
793
794 - `token: string`
795
796 The token.
797
798 - `bytes: array of number`
799
800 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
801
802 - `logprob: number`
803
804 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
805
806 - `top_logprobs: array of object { token, bytes, logprob }`
807
808 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
809
810 - `token: string`
811
812 The token.
813
814 - `bytes: array of number`
815
816 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
817
818 - `logprob: number`
819
820 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
821
822 - `refusal: array of ChatCompletionTokenLogprob`
823
824 A list of message refusal tokens with log probability information.
825
826 - `token: string`
827
828 The token.
829
830 - `bytes: array of number`
831
832 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
833
834 - `logprob: number`
835
836 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
837
838 - `top_logprobs: array of object { token, bytes, logprob }`
839
840 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
841
842 - `message: object { content, refusal, role, 4 more }`
843
844 A chat completion message generated by the model.
845
846 - `content: string`
847
848 The contents of the message.
849
850 - `refusal: string`
851
852 The refusal message generated by the model.
853
854 - `role: "assistant"`
855
856 The role of the author of this message.
857
858 - `annotations: optional array of object { type, url_citation }`
859
860 Annotations for the message, when applicable, as when using the
861 [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
862
863 - `type: "url_citation"`
864
865 The type of the URL citation. Always `url_citation`.
866
867 - `url_citation: object { end_index, start_index, title, url }`
868
869 A URL citation when using web search.
870
871 - `end_index: number`
872
873 The index of the last character of the URL citation in the message.
874
875 - `start_index: number`
876
877 The index of the first character of the URL citation in the message.
878
879 - `title: string`
880
881 The title of the web resource.
882
883 - `url: string`
884
885 The URL of the web resource.
886
887 - `audio: optional object { id, data, expires_at, transcript }`
888
889 If the audio output modality is requested, this object contains data
890 about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).
891
892 - `id: string`
893
894 Unique identifier for this audio response.
895
896 - `data: string`
897
898 Base64 encoded audio bytes generated by the model, in the format
899 specified in the request.
900
901 - `expires_at: number`
902
903 The Unix timestamp (in seconds) for when this audio response will
904 no longer be accessible on the server for use in multi-turn
905 conversations.
906
907 - `transcript: string`
908
909 Transcript of the audio generated by the model.
910
911 - `function_call: optional object { arguments, name }`
912
913 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
914
915 - `arguments: string`
916
917 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
918
919 - `name: string`
920
921 The name of the function to call.
922
923 - `tool_calls: optional array of ChatCompletionMessageToolCall`
924
925 The tool calls generated by the model, such as function calls.
926
927 - `chat_completion_message_function_tool_call: object { id, function, type }`
928
929 A call to a function tool created by the model.
930
931 - `id: string`
932
933 The ID of the tool call.
934
935 - `function: object { arguments, name }`
936
937 The function that the model called.
938
939 - `arguments: string`
940
941 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
942
943 - `name: string`
944
945 The name of the function to call.
946
947 - `type: "function"`
948
949 The type of the tool. Currently, only `function` is supported.
950
951 - `chat_completion_message_custom_tool_call: object { id, custom, type }`
952
953 A call to a custom tool created by the model.
954
955 - `id: string`
956
957 The ID of the tool call.
958
959 - `custom: object { input, name }`
960
961 The custom tool that the model called.
962
963 - `input: string`
964
965 The input for the custom tool call generated by the model.
966
967 - `name: string`
968
969 The name of the custom tool to call.
970
971 - `type: "custom"`
972
973 The type of the tool. Always `custom`.
974
975 - `created: number`
976
977 The Unix timestamp (in seconds) of when the chat completion was created.
978
979 - `model: string`
980
981 The model used for the chat completion.
982
983 - `object: "chat.completion"`
984
985 The object type, which is always `chat.completion`.
986
987 - `service_tier: optional "auto" or "default" or "flex" or 2 more`
988
989 Specifies the processing type used for serving the request.
990
991 - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.
992 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.
993 - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or '[priority](https://openai.com/api-priority-processing/)', then the request will be processed with the corresponding service tier.
994 - When not set, the default behavior is 'auto'.
995
996 When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
997
998 - `"auto"`
999
1000 - `"default"`
1001
1002 - `"flex"`
1003
1004 - `"scale"`
1005
1006 - `"priority"`
1007
1008 - `system_fingerprint: optional string`
1009
1010 This fingerprint represents the backend configuration that the model runs with.
1011
1012 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
1013
1014 - `usage: optional object { completion_tokens, prompt_tokens, total_tokens, 2 more }`
1015
1016 Usage statistics for the completion request.
1017
1018 - `completion_tokens: number`
1019
1020 Number of tokens in the generated completion.
1021
1022 - `prompt_tokens: number`
1023
1024 Number of tokens in the prompt.
1025
1026 - `total_tokens: number`
1027
1028 Total number of tokens used in the request (prompt + completion).
1029
1030 - `completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, rejected_prediction_tokens }`
1031
1032 Breakdown of tokens used in a completion.
1033
1034 - `accepted_prediction_tokens: optional number`
1035
1036 When using Predicted Outputs, the number of tokens in the
1037 prediction that appeared in the completion.
1038
1039 - `audio_tokens: optional number`
1040
1041 Audio input tokens generated by the model.
1042
1043 - `reasoning_tokens: optional number`
1044
1045 Tokens generated by the model for reasoning.
1046
1047 - `rejected_prediction_tokens: optional number`
1048
1049 When using Predicted Outputs, the number of tokens in the
1050 prediction that did not appear in the completion. However, like
1051 reasoning tokens, these tokens are still counted in the total
1052 completion tokens for purposes of billing, output, and context window
1053 limits.
1054
1055 - `prompt_tokens_details: optional object { audio_tokens, cached_tokens }`
1056
1057 Breakdown of tokens used in the prompt.
1058
1059 - `audio_tokens: optional number`
1060
1061 Audio input tokens present in the prompt.
1062
1063 - `cached_tokens: optional number`
1064
1065 Cached tokens present in the prompt.
1066
1067 - `first_id: string`
1068
1069 The identifier of the first chat completion in the data array.
1070
1071 - `has_more: boolean`
1072
1073 Indicates whether there are more Chat Completions available.
1074
1075 - `last_id: string`
1076
1077 The identifier of the last chat completion in the data array.
1078
1079 - `object: "list"`
1080
1081 The type of this object. It is always set to "list".
1082
1083### Example
1084
1085```cli
1086openai chat:completions list \
1087 --api-key 'My API Key'
1088```
1089
1090#### Response
1091
1092```json
1093{
1094 "data": [
1095 {
1096 "id": "id",
1097 "choices": [
1098 {
1099 "finish_reason": "stop",
1100 "index": 0,
1101 "logprobs": {
1102 "content": [
1103 {
1104 "token": "token",
1105 "bytes": [
1106 0
1107 ],
1108 "logprob": 0,
1109 "top_logprobs": [
1110 {
1111 "token": "token",
1112 "bytes": [
1113 0
1114 ],
1115 "logprob": 0
1116 }
1117 ]
1118 }
1119 ],
1120 "refusal": [
1121 {
1122 "token": "token",
1123 "bytes": [
1124 0
1125 ],
1126 "logprob": 0,
1127 "top_logprobs": [
1128 {
1129 "token": "token",
1130 "bytes": [
1131 0
1132 ],
1133 "logprob": 0
1134 }
1135 ]
1136 }
1137 ]
1138 },
1139 "message": {
1140 "content": "content",
1141 "refusal": "refusal",
1142 "role": "assistant",
1143 "annotations": [
1144 {
1145 "type": "url_citation",
1146 "url_citation": {
1147 "end_index": 0,
1148 "start_index": 0,
1149 "title": "title",
1150 "url": "https://example.com"
1151 }
1152 }
1153 ],
1154 "audio": {
1155 "id": "id",
1156 "data": "data",
1157 "expires_at": 0,
1158 "transcript": "transcript"
1159 },
1160 "function_call": {
1161 "arguments": "arguments",
1162 "name": "name"
1163 },
1164 "tool_calls": [
1165 {
1166 "id": "id",
1167 "function": {
1168 "arguments": "arguments",
1169 "name": "name"
1170 },
1171 "type": "function"
1172 }
1173 ]
1174 }
1175 }
1176 ],
1177 "created": 0,
1178 "model": "model",
1179 "object": "chat.completion",
1180 "service_tier": "auto",
1181 "system_fingerprint": "system_fingerprint",
1182 "usage": {
1183 "completion_tokens": 0,
1184 "prompt_tokens": 0,
1185 "total_tokens": 0,
1186 "completion_tokens_details": {
1187 "accepted_prediction_tokens": 0,
1188 "audio_tokens": 0,
1189 "reasoning_tokens": 0,
1190 "rejected_prediction_tokens": 0
1191 },
1192 "prompt_tokens_details": {
1193 "audio_tokens": 0,
1194 "cached_tokens": 0
1195 }
1196 }
1197 }
1198 ],
1199 "first_id": "first_id",
1200 "has_more": true,
1201 "last_id": "last_id",
1202 "object": "list"
1203}
1204```
1205
1206## Get chat completion
1207
1208`$ openai chat:completions retrieve`
1209
1210**get** `/chat/completions/{completion_id}`
1211
1212Get a stored chat completion. Only Chat Completions that have been created
1213with the `store` parameter set to `true` will be returned.
1214
1215### Parameters
1216
1217- `--completion-id: string`
1218
1219 The ID of the chat completion to retrieve.
1220
1221### Returns
1222
1223- `chat_completion: object { id, choices, created, 5 more }`
1224
1225 Represents a chat completion response returned by model, based on the provided input.
1226
1227 - `id: string`
1228
1229 A unique identifier for the chat completion.
1230
1231 - `choices: array of object { finish_reason, index, logprobs, message }`
1232
1233 A list of chat completion choices. Can be more than one if `n` is greater than 1.
1234
1235 - `finish_reason: "stop" or "length" or "tool_calls" or 2 more`
1236
1237 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
1238 `length` if the maximum number of tokens specified in the request was reached,
1239 `content_filter` if content was omitted due to a flag from our content filters,
1240 `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
1241
1242 - `"stop"`
1243
1244 - `"length"`
1245
1246 - `"tool_calls"`
1247
1248 - `"content_filter"`
1249
1250 - `"function_call"`
1251
1252 - `index: number`
1253
1254 The index of the choice in the list of choices.
1255
1256 - `logprobs: object { content, refusal }`
1257
1258 Log probability information for the choice.
1259
1260 - `content: array of ChatCompletionTokenLogprob`
1261
1262 A list of message content tokens with log probability information.
1263
1264 - `token: string`
1265
1266 The token.
1267
1268 - `bytes: array of number`
1269
1270 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
1271
1272 - `logprob: number`
1273
1274 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
1275
1276 - `top_logprobs: array of object { token, bytes, logprob }`
1277
1278 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
1279
1280 - `token: string`
1281
1282 The token.
1283
1284 - `bytes: array of number`
1285
1286 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
1287
1288 - `logprob: number`
1289
1290 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
1291
1292 - `refusal: array of ChatCompletionTokenLogprob`
1293
1294 A list of message refusal tokens with log probability information.
1295
1296 - `token: string`
1297
1298 The token.
1299
1300 - `bytes: array of number`
1301
1302 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
1303
1304 - `logprob: number`
1305
1306 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
1307
1308 - `top_logprobs: array of object { token, bytes, logprob }`
1309
1310 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
1311
1312 - `message: object { content, refusal, role, 4 more }`
1313
1314 A chat completion message generated by the model.
1315
1316 - `content: string`
1317
1318 The contents of the message.
1319
1320 - `refusal: string`
1321
1322 The refusal message generated by the model.
1323
1324 - `role: "assistant"`
1325
1326 The role of the author of this message.
1327
1328 - `annotations: optional array of object { type, url_citation }`
1329
1330 Annotations for the message, when applicable, as when using the
1331 [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
1332
1333 - `type: "url_citation"`
1334
1335 The type of the URL citation. Always `url_citation`.
1336
1337 - `url_citation: object { end_index, start_index, title, url }`
1338
1339 A URL citation when using web search.
1340
1341 - `end_index: number`
1342
1343 The index of the last character of the URL citation in the message.
1344
1345 - `start_index: number`
1346
1347 The index of the first character of the URL citation in the message.
1348
1349 - `title: string`
1350
1351 The title of the web resource.
1352
1353 - `url: string`
1354
1355 The URL of the web resource.
1356
1357 - `audio: optional object { id, data, expires_at, transcript }`
1358
1359 If the audio output modality is requested, this object contains data
1360 about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).
1361
1362 - `id: string`
1363
1364 Unique identifier for this audio response.
1365
1366 - `data: string`
1367
1368 Base64 encoded audio bytes generated by the model, in the format
1369 specified in the request.
1370
1371 - `expires_at: number`
1372
1373 The Unix timestamp (in seconds) for when this audio response will
1374 no longer be accessible on the server for use in multi-turn
1375 conversations.
1376
1377 - `transcript: string`
1378
1379 Transcript of the audio generated by the model.
1380
1381 - `function_call: optional object { arguments, name }`
1382
1383 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
1384
1385 - `arguments: string`
1386
1387 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
1388
1389 - `name: string`
1390
1391 The name of the function to call.
1392
1393 - `tool_calls: optional array of ChatCompletionMessageToolCall`
1394
1395 The tool calls generated by the model, such as function calls.
1396
1397 - `chat_completion_message_function_tool_call: object { id, function, type }`
1398
1399 A call to a function tool created by the model.
1400
1401 - `id: string`
1402
1403 The ID of the tool call.
1404
1405 - `function: object { arguments, name }`
1406
1407 The function that the model called.
1408
1409 - `arguments: string`
1410
1411 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
1412
1413 - `name: string`
1414
1415 The name of the function to call.
1416
1417 - `type: "function"`
1418
1419 The type of the tool. Currently, only `function` is supported.
1420
1421 - `chat_completion_message_custom_tool_call: object { id, custom, type }`
1422
1423 A call to a custom tool created by the model.
1424
1425 - `id: string`
1426
1427 The ID of the tool call.
1428
1429 - `custom: object { input, name }`
1430
1431 The custom tool that the model called.
1432
1433 - `input: string`
1434
1435 The input for the custom tool call generated by the model.
1436
1437 - `name: string`
1438
1439 The name of the custom tool to call.
1440
1441 - `type: "custom"`
1442
1443 The type of the tool. Always `custom`.
1444
1445 - `created: number`
1446
1447 The Unix timestamp (in seconds) of when the chat completion was created.
1448
1449 - `model: string`
1450
1451 The model used for the chat completion.
1452
1453 - `object: "chat.completion"`
1454
1455 The object type, which is always `chat.completion`.
1456
1457 - `service_tier: optional "auto" or "default" or "flex" or 2 more`
1458
1459 Specifies the processing type used for serving the request.
1460
1461 - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.
1462 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.
1463 - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or '[priority](https://openai.com/api-priority-processing/)', then the request will be processed with the corresponding service tier.
1464 - When not set, the default behavior is 'auto'.
1465
1466 When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
1467
1468 - `"auto"`
1469
1470 - `"default"`
1471
1472 - `"flex"`
1473
1474 - `"scale"`
1475
1476 - `"priority"`
1477
1478 - `system_fingerprint: optional string`
1479
1480 This fingerprint represents the backend configuration that the model runs with.
1481
1482 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
1483
1484 - `usage: optional object { completion_tokens, prompt_tokens, total_tokens, 2 more }`
1485
1486 Usage statistics for the completion request.
1487
1488 - `completion_tokens: number`
1489
1490 Number of tokens in the generated completion.
1491
1492 - `prompt_tokens: number`
1493
1494 Number of tokens in the prompt.
1495
1496 - `total_tokens: number`
1497
1498 Total number of tokens used in the request (prompt + completion).
1499
1500 - `completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, rejected_prediction_tokens }`
1501
1502 Breakdown of tokens used in a completion.
1503
1504 - `accepted_prediction_tokens: optional number`
1505
1506 When using Predicted Outputs, the number of tokens in the
1507 prediction that appeared in the completion.
1508
1509 - `audio_tokens: optional number`
1510
1511 Audio input tokens generated by the model.
1512
1513 - `reasoning_tokens: optional number`
1514
1515 Tokens generated by the model for reasoning.
1516
1517 - `rejected_prediction_tokens: optional number`
1518
1519 When using Predicted Outputs, the number of tokens in the
1520 prediction that did not appear in the completion. However, like
1521 reasoning tokens, these tokens are still counted in the total
1522 completion tokens for purposes of billing, output, and context window
1523 limits.
1524
1525 - `prompt_tokens_details: optional object { audio_tokens, cached_tokens }`
1526
1527 Breakdown of tokens used in the prompt.
1528
1529 - `audio_tokens: optional number`
1530
1531 Audio input tokens present in the prompt.
1532
1533 - `cached_tokens: optional number`
1534
1535 Cached tokens present in the prompt.
1536
1537### Example
1538
1539```cli
1540openai chat:completions retrieve \
1541 --api-key 'My API Key' \
1542 --completion-id completion_id
1543```
1544
1545#### Response
1546
1547```json
1548{
1549 "id": "id",
1550 "choices": [
1551 {
1552 "finish_reason": "stop",
1553 "index": 0,
1554 "logprobs": {
1555 "content": [
1556 {
1557 "token": "token",
1558 "bytes": [
1559 0
1560 ],
1561 "logprob": 0,
1562 "top_logprobs": [
1563 {
1564 "token": "token",
1565 "bytes": [
1566 0
1567 ],
1568 "logprob": 0
1569 }
1570 ]
1571 }
1572 ],
1573 "refusal": [
1574 {
1575 "token": "token",
1576 "bytes": [
1577 0
1578 ],
1579 "logprob": 0,
1580 "top_logprobs": [
1581 {
1582 "token": "token",
1583 "bytes": [
1584 0
1585 ],
1586 "logprob": 0
1587 }
1588 ]
1589 }
1590 ]
1591 },
1592 "message": {
1593 "content": "content",
1594 "refusal": "refusal",
1595 "role": "assistant",
1596 "annotations": [
1597 {
1598 "type": "url_citation",
1599 "url_citation": {
1600 "end_index": 0,
1601 "start_index": 0,
1602 "title": "title",
1603 "url": "https://example.com"
1604 }
1605 }
1606 ],
1607 "audio": {
1608 "id": "id",
1609 "data": "data",
1610 "expires_at": 0,
1611 "transcript": "transcript"
1612 },
1613 "function_call": {
1614 "arguments": "arguments",
1615 "name": "name"
1616 },
1617 "tool_calls": [
1618 {
1619 "id": "id",
1620 "function": {
1621 "arguments": "arguments",
1622 "name": "name"
1623 },
1624 "type": "function"
1625 }
1626 ]
1627 }
1628 }
1629 ],
1630 "created": 0,
1631 "model": "model",
1632 "object": "chat.completion",
1633 "service_tier": "auto",
1634 "system_fingerprint": "system_fingerprint",
1635 "usage": {
1636 "completion_tokens": 0,
1637 "prompt_tokens": 0,
1638 "total_tokens": 0,
1639 "completion_tokens_details": {
1640 "accepted_prediction_tokens": 0,
1641 "audio_tokens": 0,
1642 "reasoning_tokens": 0,
1643 "rejected_prediction_tokens": 0
1644 },
1645 "prompt_tokens_details": {
1646 "audio_tokens": 0,
1647 "cached_tokens": 0
1648 }
1649 }
1650}
1651```
1652
1653## Update chat completion
1654
1655`$ openai chat:completions update`
1656
1657**post** `/chat/completions/{completion_id}`
1658
1659Modify a stored chat completion. Only Chat Completions that have been
1660created with the `store` parameter set to `true` can be modified. Currently,
1661the only supported modification is to update the `metadata` field.
1662
1663### Parameters
1664
1665- `--completion-id: string`
1666
1667 The ID of the chat completion to update.
1668
1669- `--metadata: map[string]`
1670
1671 Set of 16 key-value pairs that can be attached to an object. This can be
1672 useful for storing additional information about the object in a structured
1673 format, and querying for objects via API or the dashboard.
1674
1675 Keys are strings with a maximum length of 64 characters. Values are strings
1676 with a maximum length of 512 characters.
1677
1678### Returns
1679
1680- `chat_completion: object { id, choices, created, 5 more }`
1681
1682 Represents a chat completion response returned by model, based on the provided input.
1683
1684 - `id: string`
1685
1686 A unique identifier for the chat completion.
1687
1688 - `choices: array of object { finish_reason, index, logprobs, message }`
1689
1690 A list of chat completion choices. Can be more than one if `n` is greater than 1.
1691
1692 - `finish_reason: "stop" or "length" or "tool_calls" or 2 more`
1693
1694 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
1695 `length` if the maximum number of tokens specified in the request was reached,
1696 `content_filter` if content was omitted due to a flag from our content filters,
1697 `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
1698
1699 - `"stop"`
1700
1701 - `"length"`
1702
1703 - `"tool_calls"`
1704
1705 - `"content_filter"`
1706
1707 - `"function_call"`
1708
1709 - `index: number`
1710
1711 The index of the choice in the list of choices.
1712
1713 - `logprobs: object { content, refusal }`
1714
1715 Log probability information for the choice.
1716
1717 - `content: array of ChatCompletionTokenLogprob`
1718
1719 A list of message content tokens with log probability information.
1720
1721 - `token: string`
1722
1723 The token.
1724
1725 - `bytes: array of number`
1726
1727 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
1728
1729 - `logprob: number`
1730
1731 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
1732
1733 - `top_logprobs: array of object { token, bytes, logprob }`
1734
1735 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
1736
1737 - `token: string`
1738
1739 The token.
1740
1741 - `bytes: array of number`
1742
1743 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
1744
1745 - `logprob: number`
1746
1747 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
1748
1749 - `refusal: array of ChatCompletionTokenLogprob`
1750
1751 A list of message refusal tokens with log probability information.
1752
1753 - `token: string`
1754
1755 The token.
1756
1757 - `bytes: array of number`
1758
1759 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
1760
1761 - `logprob: number`
1762
1763 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
1764
1765 - `top_logprobs: array of object { token, bytes, logprob }`
1766
1767 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
1768
1769 - `message: object { content, refusal, role, 4 more }`
1770
1771 A chat completion message generated by the model.
1772
1773 - `content: string`
1774
1775 The contents of the message.
1776
1777 - `refusal: string`
1778
1779 The refusal message generated by the model.
1780
1781 - `role: "assistant"`
1782
1783 The role of the author of this message.
1784
1785 - `annotations: optional array of object { type, url_citation }`
1786
1787 Annotations for the message, when applicable, as when using the
1788 [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
1789
1790 - `type: "url_citation"`
1791
1792 The type of the URL citation. Always `url_citation`.
1793
1794 - `url_citation: object { end_index, start_index, title, url }`
1795
1796 A URL citation when using web search.
1797
1798 - `end_index: number`
1799
1800 The index of the last character of the URL citation in the message.
1801
1802 - `start_index: number`
1803
1804 The index of the first character of the URL citation in the message.
1805
1806 - `title: string`
1807
1808 The title of the web resource.
1809
1810 - `url: string`
1811
1812 The URL of the web resource.
1813
1814 - `audio: optional object { id, data, expires_at, transcript }`
1815
1816 If the audio output modality is requested, this object contains data
1817 about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).
1818
1819 - `id: string`
1820
1821 Unique identifier for this audio response.
1822
1823 - `data: string`
1824
1825 Base64 encoded audio bytes generated by the model, in the format
1826 specified in the request.
1827
1828 - `expires_at: number`
1829
1830 The Unix timestamp (in seconds) for when this audio response will
1831 no longer be accessible on the server for use in multi-turn
1832 conversations.
1833
1834 - `transcript: string`
1835
1836 Transcript of the audio generated by the model.
1837
1838 - `function_call: optional object { arguments, name }`
1839
1840 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
1841
1842 - `arguments: string`
1843
1844 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
1845
1846 - `name: string`
1847
1848 The name of the function to call.
1849
1850 - `tool_calls: optional array of ChatCompletionMessageToolCall`
1851
1852 The tool calls generated by the model, such as function calls.
1853
1854 - `chat_completion_message_function_tool_call: object { id, function, type }`
1855
1856 A call to a function tool created by the model.
1857
1858 - `id: string`
1859
1860 The ID of the tool call.
1861
1862 - `function: object { arguments, name }`
1863
1864 The function that the model called.
1865
1866 - `arguments: string`
1867
1868 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
1869
1870 - `name: string`
1871
1872 The name of the function to call.
1873
1874 - `type: "function"`
1875
1876 The type of the tool. Currently, only `function` is supported.
1877
1878 - `chat_completion_message_custom_tool_call: object { id, custom, type }`
1879
1880 A call to a custom tool created by the model.
1881
1882 - `id: string`
1883
1884 The ID of the tool call.
1885
1886 - `custom: object { input, name }`
1887
1888 The custom tool that the model called.
1889
1890 - `input: string`
1891
1892 The input for the custom tool call generated by the model.
1893
1894 - `name: string`
1895
1896 The name of the custom tool to call.
1897
1898 - `type: "custom"`
1899
1900 The type of the tool. Always `custom`.
1901
1902 - `created: number`
1903
1904 The Unix timestamp (in seconds) of when the chat completion was created.
1905
1906 - `model: string`
1907
1908 The model used for the chat completion.
1909
1910 - `object: "chat.completion"`
1911
1912 The object type, which is always `chat.completion`.
1913
1914 - `service_tier: optional "auto" or "default" or "flex" or 2 more`
1915
1916 Specifies the processing type used for serving the request.
1917
1918 - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.
1919 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.
1920 - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or '[priority](https://openai.com/api-priority-processing/)', then the request will be processed with the corresponding service tier.
1921 - When not set, the default behavior is 'auto'.
1922
1923 When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
1924
1925 - `"auto"`
1926
1927 - `"default"`
1928
1929 - `"flex"`
1930
1931 - `"scale"`
1932
1933 - `"priority"`
1934
1935 - `system_fingerprint: optional string`
1936
1937 This fingerprint represents the backend configuration that the model runs with.
1938
1939 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
1940
1941 - `usage: optional object { completion_tokens, prompt_tokens, total_tokens, 2 more }`
1942
1943 Usage statistics for the completion request.
1944
1945 - `completion_tokens: number`
1946
1947 Number of tokens in the generated completion.
1948
1949 - `prompt_tokens: number`
1950
1951 Number of tokens in the prompt.
1952
1953 - `total_tokens: number`
1954
1955 Total number of tokens used in the request (prompt + completion).
1956
1957 - `completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, rejected_prediction_tokens }`
1958
1959 Breakdown of tokens used in a completion.
1960
1961 - `accepted_prediction_tokens: optional number`
1962
1963 When using Predicted Outputs, the number of tokens in the
1964 prediction that appeared in the completion.
1965
1966 - `audio_tokens: optional number`
1967
1968 Audio input tokens generated by the model.
1969
1970 - `reasoning_tokens: optional number`
1971
1972 Tokens generated by the model for reasoning.
1973
1974 - `rejected_prediction_tokens: optional number`
1975
1976 When using Predicted Outputs, the number of tokens in the
1977 prediction that did not appear in the completion. However, like
1978 reasoning tokens, these tokens are still counted in the total
1979 completion tokens for purposes of billing, output, and context window
1980 limits.
1981
1982 - `prompt_tokens_details: optional object { audio_tokens, cached_tokens }`
1983
1984 Breakdown of tokens used in the prompt.
1985
1986 - `audio_tokens: optional number`
1987
1988 Audio input tokens present in the prompt.
1989
1990 - `cached_tokens: optional number`
1991
1992 Cached tokens present in the prompt.
1993
1994### Example
1995
1996```cli
1997openai chat:completions update \
1998 --api-key 'My API Key' \
1999 --completion-id completion_id \
2000 --metadata '{foo: string}'
2001```
2002
2003#### Response
2004
2005```json
2006{
2007 "id": "id",
2008 "choices": [
2009 {
2010 "finish_reason": "stop",
2011 "index": 0,
2012 "logprobs": {
2013 "content": [
2014 {
2015 "token": "token",
2016 "bytes": [
2017 0
2018 ],
2019 "logprob": 0,
2020 "top_logprobs": [
2021 {
2022 "token": "token",
2023 "bytes": [
2024 0
2025 ],
2026 "logprob": 0
2027 }
2028 ]
2029 }
2030 ],
2031 "refusal": [
2032 {
2033 "token": "token",
2034 "bytes": [
2035 0
2036 ],
2037 "logprob": 0,
2038 "top_logprobs": [
2039 {
2040 "token": "token",
2041 "bytes": [
2042 0
2043 ],
2044 "logprob": 0
2045 }
2046 ]
2047 }
2048 ]
2049 },
2050 "message": {
2051 "content": "content",
2052 "refusal": "refusal",
2053 "role": "assistant",
2054 "annotations": [
2055 {
2056 "type": "url_citation",
2057 "url_citation": {
2058 "end_index": 0,
2059 "start_index": 0,
2060 "title": "title",
2061 "url": "https://example.com"
2062 }
2063 }
2064 ],
2065 "audio": {
2066 "id": "id",
2067 "data": "data",
2068 "expires_at": 0,
2069 "transcript": "transcript"
2070 },
2071 "function_call": {
2072 "arguments": "arguments",
2073 "name": "name"
2074 },
2075 "tool_calls": [
2076 {
2077 "id": "id",
2078 "function": {
2079 "arguments": "arguments",
2080 "name": "name"
2081 },
2082 "type": "function"
2083 }
2084 ]
2085 }
2086 }
2087 ],
2088 "created": 0,
2089 "model": "model",
2090 "object": "chat.completion",
2091 "service_tier": "auto",
2092 "system_fingerprint": "system_fingerprint",
2093 "usage": {
2094 "completion_tokens": 0,
2095 "prompt_tokens": 0,
2096 "total_tokens": 0,
2097 "completion_tokens_details": {
2098 "accepted_prediction_tokens": 0,
2099 "audio_tokens": 0,
2100 "reasoning_tokens": 0,
2101 "rejected_prediction_tokens": 0
2102 },
2103 "prompt_tokens_details": {
2104 "audio_tokens": 0,
2105 "cached_tokens": 0
2106 }
2107 }
2108}
2109```
2110
2111## Delete chat completion
2112
2113`$ openai chat:completions delete`
2114
2115**delete** `/chat/completions/{completion_id}`
2116
2117Delete a stored chat completion. Only Chat Completions that have been
2118created with the `store` parameter set to `true` can be deleted.
2119
2120### Parameters
2121
2122- `--completion-id: string`
2123
2124 The ID of the chat completion to delete.
2125
2126### Returns
2127
2128- `chat_completion_deleted: object { id, deleted, object }`
2129
2130 - `id: string`
2131
2132 The ID of the chat completion that was deleted.
2133
2134 - `deleted: boolean`
2135
2136 Whether the chat completion was deleted.
2137
2138 - `object: "chat.completion.deleted"`
2139
2140 The type of object being deleted.
2141
2142### Example
2143
2144```cli
2145openai chat:completions delete \
2146 --api-key 'My API Key' \
2147 --completion-id completion_id
2148```
2149
2150#### Response
2151
2152```json
2153{
2154 "id": "id",
2155 "deleted": true,
2156 "object": "chat.completion.deleted"
2157}
2158```
2159
2160## Domain Types
2161
2162### Chat Completion
2163
2164- `chat_completion: object { id, choices, created, 5 more }`
2165
2166 Represents a chat completion response returned by model, based on the provided input.
2167
2168 - `id: string`
2169
2170 A unique identifier for the chat completion.
2171
2172 - `choices: array of object { finish_reason, index, logprobs, message }`
2173
2174 A list of chat completion choices. Can be more than one if `n` is greater than 1.
2175
2176 - `finish_reason: "stop" or "length" or "tool_calls" or 2 more`
2177
2178 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
2179 `length` if the maximum number of tokens specified in the request was reached,
2180 `content_filter` if content was omitted due to a flag from our content filters,
2181 `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
2182
2183 - `"stop"`
2184
2185 - `"length"`
2186
2187 - `"tool_calls"`
2188
2189 - `"content_filter"`
2190
2191 - `"function_call"`
2192
2193 - `index: number`
2194
2195 The index of the choice in the list of choices.
2196
2197 - `logprobs: object { content, refusal }`
2198
2199 Log probability information for the choice.
2200
2201 - `content: array of ChatCompletionTokenLogprob`
2202
2203 A list of message content tokens with log probability information.
2204
2205 - `token: string`
2206
2207 The token.
2208
2209 - `bytes: array of number`
2210
2211 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
2212
2213 - `logprob: number`
2214
2215 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
2216
2217 - `top_logprobs: array of object { token, bytes, logprob }`
2218
2219 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
2220
2221 - `token: string`
2222
2223 The token.
2224
2225 - `bytes: array of number`
2226
2227 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
2228
2229 - `logprob: number`
2230
2231 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
2232
2233 - `refusal: array of ChatCompletionTokenLogprob`
2234
2235 A list of message refusal tokens with log probability information.
2236
2237 - `token: string`
2238
2239 The token.
2240
2241 - `bytes: array of number`
2242
2243 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
2244
2245 - `logprob: number`
2246
2247 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
2248
2249 - `top_logprobs: array of object { token, bytes, logprob }`
2250
2251 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
2252
2253 - `message: object { content, refusal, role, 4 more }`
2254
2255 A chat completion message generated by the model.
2256
2257 - `content: string`
2258
2259 The contents of the message.
2260
2261 - `refusal: string`
2262
2263 The refusal message generated by the model.
2264
2265 - `role: "assistant"`
2266
2267 The role of the author of this message.
2268
2269 - `annotations: optional array of object { type, url_citation }`
2270
2271 Annotations for the message, when applicable, as when using the
2272 [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
2273
2274 - `type: "url_citation"`
2275
2276 The type of the URL citation. Always `url_citation`.
2277
2278 - `url_citation: object { end_index, start_index, title, url }`
2279
2280 A URL citation when using web search.
2281
2282 - `end_index: number`
2283
2284 The index of the last character of the URL citation in the message.
2285
2286 - `start_index: number`
2287
2288 The index of the first character of the URL citation in the message.
2289
2290 - `title: string`
2291
2292 The title of the web resource.
2293
2294 - `url: string`
2295
2296 The URL of the web resource.
2297
2298 - `audio: optional object { id, data, expires_at, transcript }`
2299
2300 If the audio output modality is requested, this object contains data
2301 about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).
2302
2303 - `id: string`
2304
2305 Unique identifier for this audio response.
2306
2307 - `data: string`
2308
2309 Base64 encoded audio bytes generated by the model, in the format
2310 specified in the request.
2311
2312 - `expires_at: number`
2313
2314 The Unix timestamp (in seconds) for when this audio response will
2315 no longer be accessible on the server for use in multi-turn
2316 conversations.
2317
2318 - `transcript: string`
2319
2320 Transcript of the audio generated by the model.
2321
2322 - `function_call: optional object { arguments, name }`
2323
2324 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
2325
2326 - `arguments: string`
2327
2328 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
2329
2330 - `name: string`
2331
2332 The name of the function to call.
2333
2334 - `tool_calls: optional array of ChatCompletionMessageToolCall`
2335
2336 The tool calls generated by the model, such as function calls.
2337
2338 - `chat_completion_message_function_tool_call: object { id, function, type }`
2339
2340 A call to a function tool created by the model.
2341
2342 - `id: string`
2343
2344 The ID of the tool call.
2345
2346 - `function: object { arguments, name }`
2347
2348 The function that the model called.
2349
2350 - `arguments: string`
2351
2352 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
2353
2354 - `name: string`
2355
2356 The name of the function to call.
2357
2358 - `type: "function"`
2359
2360 The type of the tool. Currently, only `function` is supported.
2361
2362 - `chat_completion_message_custom_tool_call: object { id, custom, type }`
2363
2364 A call to a custom tool created by the model.
2365
2366 - `id: string`
2367
2368 The ID of the tool call.
2369
2370 - `custom: object { input, name }`
2371
2372 The custom tool that the model called.
2373
2374 - `input: string`
2375
2376 The input for the custom tool call generated by the model.
2377
2378 - `name: string`
2379
2380 The name of the custom tool to call.
2381
2382 - `type: "custom"`
2383
2384 The type of the tool. Always `custom`.
2385
2386 - `created: number`
2387
2388 The Unix timestamp (in seconds) of when the chat completion was created.
2389
2390 - `model: string`
2391
2392 The model used for the chat completion.
2393
2394 - `object: "chat.completion"`
2395
2396 The object type, which is always `chat.completion`.
2397
2398 - `service_tier: optional "auto" or "default" or "flex" or 2 more`
2399
2400 Specifies the processing type used for serving the request.
2401
2402 - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.
2403 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.
2404 - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or '[priority](https://openai.com/api-priority-processing/)', then the request will be processed with the corresponding service tier.
2405 - When not set, the default behavior is 'auto'.
2406
2407 When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
2408
2409 - `"auto"`
2410
2411 - `"default"`
2412
2413 - `"flex"`
2414
2415 - `"scale"`
2416
2417 - `"priority"`
2418
2419 - `system_fingerprint: optional string`
2420
2421 This fingerprint represents the backend configuration that the model runs with.
2422
2423 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
2424
2425 - `usage: optional object { completion_tokens, prompt_tokens, total_tokens, 2 more }`
2426
2427 Usage statistics for the completion request.
2428
2429 - `completion_tokens: number`
2430
2431 Number of tokens in the generated completion.
2432
2433 - `prompt_tokens: number`
2434
2435 Number of tokens in the prompt.
2436
2437 - `total_tokens: number`
2438
2439 Total number of tokens used in the request (prompt + completion).
2440
2441 - `completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, rejected_prediction_tokens }`
2442
2443 Breakdown of tokens used in a completion.
2444
2445 - `accepted_prediction_tokens: optional number`
2446
2447 When using Predicted Outputs, the number of tokens in the
2448 prediction that appeared in the completion.
2449
2450 - `audio_tokens: optional number`
2451
2452 Audio input tokens generated by the model.
2453
2454 - `reasoning_tokens: optional number`
2455
2456 Tokens generated by the model for reasoning.
2457
2458 - `rejected_prediction_tokens: optional number`
2459
2460 When using Predicted Outputs, the number of tokens in the
2461 prediction that did not appear in the completion. However, like
2462 reasoning tokens, these tokens are still counted in the total
2463 completion tokens for purposes of billing, output, and context window
2464 limits.
2465
2466 - `prompt_tokens_details: optional object { audio_tokens, cached_tokens }`
2467
2468 Breakdown of tokens used in the prompt.
2469
2470 - `audio_tokens: optional number`
2471
2472 Audio input tokens present in the prompt.
2473
2474 - `cached_tokens: optional number`
2475
2476 Cached tokens present in the prompt.
2477
2478### Chat Completion Allowed Tool Choice
2479
2480- `chat_completion_allowed_tool_choice: object { allowed_tools, type }`
2481
2482 Constrains the tools available to the model to a pre-defined set.
2483
2484 - `allowed_tools: object { mode, tools }`
2485
2486 Constrains the tools available to the model to a pre-defined set.
2487
2488 - `mode: "auto" or "required"`
2489
2490 Constrains the tools available to the model to a pre-defined set.
2491
2492 `auto` allows the model to pick from among the allowed tools and generate a
2493 message.
2494
2495 `required` requires the model to call one or more of the allowed tools.
2496
2497 - `"auto"`
2498
2499 - `"required"`
2500
2501 - `tools: array of map[unknown]`
2502
2503 A list of tool definitions that the model should be allowed to call.
2504
2505 For the Chat Completions API, the list of tool definitions might look like:
2506
2507 ```json
2508 [
2509 { "type": "function", "function": { "name": "get_weather" } },
2510 { "type": "function", "function": { "name": "get_time" } }
2511 ]
2512 ```
2513
2514 - `type: "allowed_tools"`
2515
2516 Allowed tool configuration type. Always `allowed_tools`.
2517
2518### Chat Completion Assistant Message Param
2519
2520- `chat_completion_assistant_message_param: object { role, audio, content, 4 more }`
2521
2522 Messages sent by the model in response to user messages.
2523
2524 - `role: "assistant"`
2525
2526 The role of the messages author, in this case `assistant`.
2527
2528 - `audio: optional object { id }`
2529
2530 Data about a previous audio response from the model.
2531 [Learn more](https://platform.openai.com/docs/guides/audio).
2532
2533 - `id: string`
2534
2535 Unique identifier for a previous audio response from the model.
2536
2537 - `content: optional string or array of ChatCompletionContentPartText or ChatCompletionContentPartRefusal`
2538
2539 The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.
2540
2541 - `Text content: string`
2542
2543 The contents of the assistant message.
2544
2545 - `Array of content parts: array of ChatCompletionContentPartText or ChatCompletionContentPartRefusal`
2546
2547 An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.
2548
2549 - `chat_completion_content_part_text: object { text, type }`
2550
2551 Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
2552
2553 - `text: string`
2554
2555 The text content.
2556
2557 - `type: "text"`
2558
2559 The type of the content part.
2560
2561 - `chat_completion_content_part_refusal: object { refusal, type }`
2562
2563 - `refusal: string`
2564
2565 The refusal message generated by the model.
2566
2567 - `type: "refusal"`
2568
2569 The type of the content part.
2570
2571 - `function_call: optional object { arguments, name }`
2572
2573 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
2574
2575 - `arguments: string`
2576
2577 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
2578
2579 - `name: string`
2580
2581 The name of the function to call.
2582
2583 - `name: optional string`
2584
2585 An optional name for the participant. Provides the model information to differentiate between participants of the same role.
2586
2587 - `refusal: optional string`
2588
2589 The refusal message by the assistant.
2590
2591 - `tool_calls: optional array of ChatCompletionMessageToolCall`
2592
2593 The tool calls generated by the model, such as function calls.
2594
2595 - `chat_completion_message_function_tool_call: object { id, function, type }`
2596
2597 A call to a function tool created by the model.
2598
2599 - `id: string`
2600
2601 The ID of the tool call.
2602
2603 - `function: object { arguments, name }`
2604
2605 The function that the model called.
2606
2607 - `arguments: string`
2608
2609 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
2610
2611 - `name: string`
2612
2613 The name of the function to call.
2614
2615 - `type: "function"`
2616
2617 The type of the tool. Currently, only `function` is supported.
2618
2619 - `chat_completion_message_custom_tool_call: object { id, custom, type }`
2620
2621 A call to a custom tool created by the model.
2622
2623 - `id: string`
2624
2625 The ID of the tool call.
2626
2627 - `custom: object { input, name }`
2628
2629 The custom tool that the model called.
2630
2631 - `input: string`
2632
2633 The input for the custom tool call generated by the model.
2634
2635 - `name: string`
2636
2637 The name of the custom tool to call.
2638
2639 - `type: "custom"`
2640
2641 The type of the tool. Always `custom`.
2642
2643### Chat Completion Audio
2644
2645- `chat_completion_audio: object { id, data, expires_at, transcript }`
2646
2647 If the audio output modality is requested, this object contains data
2648 about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).
2649
2650 - `id: string`
2651
2652 Unique identifier for this audio response.
2653
2654 - `data: string`
2655
2656 Base64 encoded audio bytes generated by the model, in the format
2657 specified in the request.
2658
2659 - `expires_at: number`
2660
2661 The Unix timestamp (in seconds) for when this audio response will
2662 no longer be accessible on the server for use in multi-turn
2663 conversations.
2664
2665 - `transcript: string`
2666
2667 Transcript of the audio generated by the model.
2668
2669### Chat Completion Audio Param
2670
2671- `chat_completion_audio_param: object { format, voice }`
2672
2673 Parameters for audio output. Required when audio output is requested with
2674 `modalities: ["audio"]`. [Learn more](https://platform.openai.com/docs/guides/audio).
2675
2676 - `format: "wav" or "aac" or "mp3" or 3 more`
2677
2678 Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`,
2679 `opus`, or `pcm16`.
2680
2681 - `"wav"`
2682
2683 - `"aac"`
2684
2685 - `"mp3"`
2686
2687 - `"flac"`
2688
2689 - `"opus"`
2690
2691 - `"pcm16"`
2692
2693 - `voice: string or "alloy" or "ash" or "ballad" or 7 more or object { id }`
2694
2695 The voice the model uses to respond. Supported built-in voices are
2696 `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`,
2697 `sage`, `shimmer`, `marin`, and `cedar`. You may also provide a
2698 custom voice object with an `id`, for example `{ "id": "voice_1234" }`.
2699
2700 - `union_member_0: string`
2701
2702 - `union_member_1: "alloy" or "ash" or "ballad" or 7 more`
2703
2704 - `"alloy"`
2705
2706 - `"ash"`
2707
2708 - `"ballad"`
2709
2710 - `"coral"`
2711
2712 - `"echo"`
2713
2714 - `"sage"`
2715
2716 - `"shimmer"`
2717
2718 - `"verse"`
2719
2720 - `"marin"`
2721
2722 - `"cedar"`
2723
2724 - `id: object { id }`
2725
2726 Custom voice reference.
2727
2728 - `id: string`
2729
2730 The custom voice ID, e.g. `voice_1234`.
2731
2732### Chat Completion Chunk
2733
2734- `chat_completion_chunk: object { id, choices, created, 5 more }`
2735
2736 Represents a streamed chunk of a chat completion response returned
2737 by the model, based on the provided input.
2738 [Learn more](https://platform.openai.com/docs/guides/streaming-responses).
2739
2740 - `id: string`
2741
2742 A unique identifier for the chat completion. Each chunk has the same ID.
2743
2744 - `choices: array of object { delta, finish_reason, index, logprobs }`
2745
2746 A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the
2747 last chunk if you set `stream_options: {"include_usage": true}`.
2748
2749 - `delta: object { content, function_call, refusal, 2 more }`
2750
2751 A chat completion delta generated by streamed model responses.
2752
2753 - `content: optional string`
2754
2755 The contents of the chunk message.
2756
2757 - `function_call: optional object { arguments, name }`
2758
2759 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
2760
2761 - `arguments: optional string`
2762
2763 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
2764
2765 - `name: optional string`
2766
2767 The name of the function to call.
2768
2769 - `refusal: optional string`
2770
2771 The refusal message generated by the model.
2772
2773 - `role: optional "developer" or "system" or "user" or 2 more`
2774
2775 The role of the author of this message.
2776
2777 - `"developer"`
2778
2779 - `"system"`
2780
2781 - `"user"`
2782
2783 - `"assistant"`
2784
2785 - `"tool"`
2786
2787 - `tool_calls: optional array of object { index, id, function, type }`
2788
2789 - `index: number`
2790
2791 - `id: optional string`
2792
2793 The ID of the tool call.
2794
2795 - `function: optional object { arguments, name }`
2796
2797 - `arguments: optional string`
2798
2799 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
2800
2801 - `name: optional string`
2802
2803 The name of the function to call.
2804
2805 - `type: optional "function"`
2806
2807 The type of the tool. Currently, only `function` is supported.
2808
2809 - `"function"`
2810
2811 - `finish_reason: "stop" or "length" or "tool_calls" or 2 more`
2812
2813 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,
2814 `length` if the maximum number of tokens specified in the request was reached,
2815 `content_filter` if content was omitted due to a flag from our content filters,
2816 `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
2817
2818 - `"stop"`
2819
2820 - `"length"`
2821
2822 - `"tool_calls"`
2823
2824 - `"content_filter"`
2825
2826 - `"function_call"`
2827
2828 - `index: number`
2829
2830 The index of the choice in the list of choices.
2831
2832 - `logprobs: optional object { content, refusal }`
2833
2834 Log probability information for the choice.
2835
2836 - `content: array of ChatCompletionTokenLogprob`
2837
2838 A list of message content tokens with log probability information.
2839
2840 - `token: string`
2841
2842 The token.
2843
2844 - `bytes: array of number`
2845
2846 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
2847
2848 - `logprob: number`
2849
2850 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
2851
2852 - `top_logprobs: array of object { token, bytes, logprob }`
2853
2854 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
2855
2856 - `token: string`
2857
2858 The token.
2859
2860 - `bytes: array of number`
2861
2862 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
2863
2864 - `logprob: number`
2865
2866 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
2867
2868 - `refusal: array of ChatCompletionTokenLogprob`
2869
2870 A list of message refusal tokens with log probability information.
2871
2872 - `token: string`
2873
2874 The token.
2875
2876 - `bytes: array of number`
2877
2878 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
2879
2880 - `logprob: number`
2881
2882 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
2883
2884 - `top_logprobs: array of object { token, bytes, logprob }`
2885
2886 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
2887
2888 - `created: number`
2889
2890 The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp.
2891
2892 - `model: string`
2893
2894 The model to generate the completion.
2895
2896 - `object: "chat.completion.chunk"`
2897
2898 The object type, which is always `chat.completion.chunk`.
2899
2900 - `service_tier: optional "auto" or "default" or "flex" or 2 more`
2901
2902 Specifies the processing type used for serving the request.
2903
2904 - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.
2905 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.
2906 - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or '[priority](https://openai.com/api-priority-processing/)', then the request will be processed with the corresponding service tier.
2907 - When not set, the default behavior is 'auto'.
2908
2909 When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
2910
2911 - `"auto"`
2912
2913 - `"default"`
2914
2915 - `"flex"`
2916
2917 - `"scale"`
2918
2919 - `"priority"`
2920
2921 - `system_fingerprint: optional string`
2922
2923 This fingerprint represents the backend configuration that the model runs with.
2924 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
2925
2926 - `usage: optional object { completion_tokens, prompt_tokens, total_tokens, 2 more }`
2927
2928 An optional field that will only be present when you set
2929 `stream_options: {"include_usage": true}` in your request. When present, it
2930 contains a null value **except for the last chunk** which contains the
2931 token usage statistics for the entire request.
2932
2933 **NOTE:** If the stream is interrupted or cancelled, you may not
2934 receive the final usage chunk which contains the total token usage for
2935 the request.
2936
2937 - `completion_tokens: number`
2938
2939 Number of tokens in the generated completion.
2940
2941 - `prompt_tokens: number`
2942
2943 Number of tokens in the prompt.
2944
2945 - `total_tokens: number`
2946
2947 Total number of tokens used in the request (prompt + completion).
2948
2949 - `completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, rejected_prediction_tokens }`
2950
2951 Breakdown of tokens used in a completion.
2952
2953 - `accepted_prediction_tokens: optional number`
2954
2955 When using Predicted Outputs, the number of tokens in the
2956 prediction that appeared in the completion.
2957
2958 - `audio_tokens: optional number`
2959
2960 Audio input tokens generated by the model.
2961
2962 - `reasoning_tokens: optional number`
2963
2964 Tokens generated by the model for reasoning.
2965
2966 - `rejected_prediction_tokens: optional number`
2967
2968 When using Predicted Outputs, the number of tokens in the
2969 prediction that did not appear in the completion. However, like
2970 reasoning tokens, these tokens are still counted in the total
2971 completion tokens for purposes of billing, output, and context window
2972 limits.
2973
2974 - `prompt_tokens_details: optional object { audio_tokens, cached_tokens }`
2975
2976 Breakdown of tokens used in the prompt.
2977
2978 - `audio_tokens: optional number`
2979
2980 Audio input tokens present in the prompt.
2981
2982 - `cached_tokens: optional number`
2983
2984 Cached tokens present in the prompt.
2985
2986### Chat Completion Content Part
2987
2988- `chat_completion_content_part: ChatCompletionContentPartText or ChatCompletionContentPartImage or ChatCompletionContentPartInputAudio or object { file, type }`
2989
2990 Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
2991
2992 - `chat_completion_content_part_text: object { text, type }`
2993
2994 Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
2995
2996 - `text: string`
2997
2998 The text content.
2999
3000 - `type: "text"`
3001
3002 The type of the content part.
3003
3004 - `chat_completion_content_part_image: object { image_url, type }`
3005
3006 Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
3007
3008 - `image_url: object { url, detail }`
3009
3010 - `url: string`
3011
3012 Either a URL of the image or the base64 encoded image data.
3013
3014 - `detail: optional "auto" or "low" or "high"`
3015
3016 Specifies the detail level of the image. Learn more in the [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding).
3017
3018 - `"auto"`
3019
3020 - `"low"`
3021
3022 - `"high"`
3023
3024 - `type: "image_url"`
3025
3026 The type of the content part.
3027
3028 - `chat_completion_content_part_input_audio: object { input_audio, type }`
3029
3030 Learn about [audio inputs](https://platform.openai.com/docs/guides/audio).
3031
3032 - `input_audio: object { data, format }`
3033
3034 - `data: string`
3035
3036 Base64 encoded audio data.
3037
3038 - `format: "wav" or "mp3"`
3039
3040 The format of the encoded audio data. Currently supports "wav" and "mp3".
3041
3042 - `"wav"`
3043
3044 - `"mp3"`
3045
3046 - `type: "input_audio"`
3047
3048 The type of the content part. Always `input_audio`.
3049
3050 - `file: object { file, type }`
3051
3052 Learn about [file inputs](https://platform.openai.com/docs/guides/text) for text generation.
3053
3054 - `file: object { file_data, file_id, filename }`
3055
3056 - `file_data: optional string`
3057
3058 The base64 encoded file data, used when passing the file to the model
3059 as a string.
3060
3061 - `file_id: optional string`
3062
3063 The ID of an uploaded file to use as input.
3064
3065 - `filename: optional string`
3066
3067 The name of the file, used when passing the file to the model as a
3068 string.
3069
3070 - `type: "file"`
3071
3072 The type of the content part. Always `file`.
3073
3074### Chat Completion Content Part Image
3075
3076- `chat_completion_content_part_image: object { image_url, type }`
3077
3078 Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
3079
3080 - `image_url: object { url, detail }`
3081
3082 - `url: string`
3083
3084 Either a URL of the image or the base64 encoded image data.
3085
3086 - `detail: optional "auto" or "low" or "high"`
3087
3088 Specifies the detail level of the image. Learn more in the [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding).
3089
3090 - `"auto"`
3091
3092 - `"low"`
3093
3094 - `"high"`
3095
3096 - `type: "image_url"`
3097
3098 The type of the content part.
3099
3100### Chat Completion Content Part Input Audio
3101
3102- `chat_completion_content_part_input_audio: object { input_audio, type }`
3103
3104 Learn about [audio inputs](https://platform.openai.com/docs/guides/audio).
3105
3106 - `input_audio: object { data, format }`
3107
3108 - `data: string`
3109
3110 Base64 encoded audio data.
3111
3112 - `format: "wav" or "mp3"`
3113
3114 The format of the encoded audio data. Currently supports "wav" and "mp3".
3115
3116 - `"wav"`
3117
3118 - `"mp3"`
3119
3120 - `type: "input_audio"`
3121
3122 The type of the content part. Always `input_audio`.
3123
3124### Chat Completion Content Part Refusal
3125
3126- `chat_completion_content_part_refusal: object { refusal, type }`
3127
3128 - `refusal: string`
3129
3130 The refusal message generated by the model.
3131
3132 - `type: "refusal"`
3133
3134 The type of the content part.
3135
3136### Chat Completion Content Part Text
3137
3138- `chat_completion_content_part_text: object { text, type }`
3139
3140 Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
3141
3142 - `text: string`
3143
3144 The text content.
3145
3146 - `type: "text"`
3147
3148 The type of the content part.
3149
3150### Chat Completion Custom Tool
3151
3152- `chat_completion_custom_tool: object { custom, type }`
3153
3154 A custom tool that processes input using a specified format.
3155
3156 - `custom: object { name, description, format }`
3157
3158 Properties of the custom tool.
3159
3160 - `name: string`
3161
3162 The name of the custom tool, used to identify it in tool calls.
3163
3164 - `description: optional string`
3165
3166 Optional description of the custom tool, used to provide more context.
3167
3168 - `format: optional object { type } or object { grammar, type }`
3169
3170 The input format for the custom tool. Default is unconstrained text.
3171
3172 - `text: object { type }`
3173
3174 Unconstrained free-form text.
3175
3176 - `grammar: object { grammar, type }`
3177
3178 A grammar defined by the user.
3179
3180 - `grammar: object { definition, syntax }`
3181
3182 Your chosen grammar.
3183
3184 - `definition: string`
3185
3186 The grammar definition.
3187
3188 - `syntax: "lark" or "regex"`
3189
3190 The syntax of the grammar definition. One of `lark` or `regex`.
3191
3192 - `"lark"`
3193
3194 - `"regex"`
3195
3196 - `type: "grammar"`
3197
3198 Grammar format. Always `grammar`.
3199
3200 - `type: "custom"`
3201
3202 The type of the custom tool. Always `custom`.
3203
3204### Chat Completion Deleted
3205
3206- `chat_completion_deleted: object { id, deleted, object }`
3207
3208 - `id: string`
3209
3210 The ID of the chat completion that was deleted.
3211
3212 - `deleted: boolean`
3213
3214 Whether the chat completion was deleted.
3215
3216 - `object: "chat.completion.deleted"`
3217
3218 The type of object being deleted.
3219
3220### Chat Completion Developer Message Param
3221
3222- `chat_completion_developer_message_param: object { content, role, name }`
3223
3224 Developer-provided instructions that the model should follow, regardless of
3225 messages sent by the user. With o1 models and newer, `developer` messages
3226 replace the previous `system` messages.
3227
3228 - `content: string or array of ChatCompletionContentPartText`
3229
3230 The contents of the developer message.
3231
3232 - `Text content: string`
3233
3234 The contents of the developer message.
3235
3236 - `Array of content parts: array of ChatCompletionContentPartText`
3237
3238 An array of content parts with a defined type. For developer messages, only type `text` is supported.
3239
3240 - `text: string`
3241
3242 The text content.
3243
3244 - `type: "text"`
3245
3246 The type of the content part.
3247
3248 - `role: "developer"`
3249
3250 The role of the messages author, in this case `developer`.
3251
3252 - `name: optional string`
3253
3254 An optional name for the participant. Provides the model information to differentiate between participants of the same role.
3255
3256### Chat Completion Function Call Option
3257
3258- `chat_completion_function_call_option: object { name }`
3259
3260 Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.
3261
3262 - `name: string`
3263
3264 The name of the function to call.
3265
3266### Chat Completion Function Message Param
3267
3268- `chat_completion_function_message_param: object { content, name, role }`
3269
3270 - `content: string`
3271
3272 The contents of the function message.
3273
3274 - `name: string`
3275
3276 The name of the function to call.
3277
3278 - `role: "function"`
3279
3280 The role of the messages author, in this case `function`.
3281
3282### Chat Completion Function Tool
3283
3284- `chat_completion_function_tool: object { function, type }`
3285
3286 A function tool that can be used to generate a response.
3287
3288 - `function: object { name, description, parameters, strict }`
3289
3290 - `name: string`
3291
3292 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
3293
3294 - `description: optional string`
3295
3296 A description of what the function does, used by the model to choose when and how to call the function.
3297
3298 - `parameters: optional map[unknown]`
3299
3300 The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.
3301
3302 Omitting `parameters` defines a function with an empty parameter list.
3303
3304 - `strict: optional boolean`
3305
3306 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](https://platform.openai.com/docs/guides/function-calling).
3307
3308 - `type: "function"`
3309
3310 The type of the tool. Currently, only `function` is supported.
3311
3312### Chat Completion Message
3313
3314- `chat_completion_message: object { content, refusal, role, 4 more }`
3315
3316 A chat completion message generated by the model.
3317
3318 - `content: string`
3319
3320 The contents of the message.
3321
3322 - `refusal: string`
3323
3324 The refusal message generated by the model.
3325
3326 - `role: "assistant"`
3327
3328 The role of the author of this message.
3329
3330 - `annotations: optional array of object { type, url_citation }`
3331
3332 Annotations for the message, when applicable, as when using the
3333 [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
3334
3335 - `type: "url_citation"`
3336
3337 The type of the URL citation. Always `url_citation`.
3338
3339 - `url_citation: object { end_index, start_index, title, url }`
3340
3341 A URL citation when using web search.
3342
3343 - `end_index: number`
3344
3345 The index of the last character of the URL citation in the message.
3346
3347 - `start_index: number`
3348
3349 The index of the first character of the URL citation in the message.
3350
3351 - `title: string`
3352
3353 The title of the web resource.
3354
3355 - `url: string`
3356
3357 The URL of the web resource.
3358
3359 - `audio: optional object { id, data, expires_at, transcript }`
3360
3361 If the audio output modality is requested, this object contains data
3362 about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).
3363
3364 - `id: string`
3365
3366 Unique identifier for this audio response.
3367
3368 - `data: string`
3369
3370 Base64 encoded audio bytes generated by the model, in the format
3371 specified in the request.
3372
3373 - `expires_at: number`
3374
3375 The Unix timestamp (in seconds) for when this audio response will
3376 no longer be accessible on the server for use in multi-turn
3377 conversations.
3378
3379 - `transcript: string`
3380
3381 Transcript of the audio generated by the model.
3382
3383 - `function_call: optional object { arguments, name }`
3384
3385 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
3386
3387 - `arguments: string`
3388
3389 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
3390
3391 - `name: string`
3392
3393 The name of the function to call.
3394
3395 - `tool_calls: optional array of ChatCompletionMessageToolCall`
3396
3397 The tool calls generated by the model, such as function calls.
3398
3399 - `chat_completion_message_function_tool_call: object { id, function, type }`
3400
3401 A call to a function tool created by the model.
3402
3403 - `id: string`
3404
3405 The ID of the tool call.
3406
3407 - `function: object { arguments, name }`
3408
3409 The function that the model called.
3410
3411 - `arguments: string`
3412
3413 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
3414
3415 - `name: string`
3416
3417 The name of the function to call.
3418
3419 - `type: "function"`
3420
3421 The type of the tool. Currently, only `function` is supported.
3422
3423 - `chat_completion_message_custom_tool_call: object { id, custom, type }`
3424
3425 A call to a custom tool created by the model.
3426
3427 - `id: string`
3428
3429 The ID of the tool call.
3430
3431 - `custom: object { input, name }`
3432
3433 The custom tool that the model called.
3434
3435 - `input: string`
3436
3437 The input for the custom tool call generated by the model.
3438
3439 - `name: string`
3440
3441 The name of the custom tool to call.
3442
3443 - `type: "custom"`
3444
3445 The type of the tool. Always `custom`.
3446
3447### Chat Completion Message Custom Tool Call
3448
3449- `chat_completion_message_custom_tool_call: object { id, custom, type }`
3450
3451 A call to a custom tool created by the model.
3452
3453 - `id: string`
3454
3455 The ID of the tool call.
3456
3457 - `custom: object { input, name }`
3458
3459 The custom tool that the model called.
3460
3461 - `input: string`
3462
3463 The input for the custom tool call generated by the model.
3464
3465 - `name: string`
3466
3467 The name of the custom tool to call.
3468
3469 - `type: "custom"`
3470
3471 The type of the tool. Always `custom`.
3472
3473### Chat Completion Message Function Tool Call
3474
3475- `chat_completion_message_function_tool_call: object { id, function, type }`
3476
3477 A call to a function tool created by the model.
3478
3479 - `id: string`
3480
3481 The ID of the tool call.
3482
3483 - `function: object { arguments, name }`
3484
3485 The function that the model called.
3486
3487 - `arguments: string`
3488
3489 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
3490
3491 - `name: string`
3492
3493 The name of the function to call.
3494
3495 - `type: "function"`
3496
3497 The type of the tool. Currently, only `function` is supported.
3498
3499### Chat Completion Message Param
3500
3501- `chat_completion_message_param: ChatCompletionDeveloperMessageParam or ChatCompletionSystemMessageParam or ChatCompletionUserMessageParam or 3 more`
3502
3503 Developer-provided instructions that the model should follow, regardless of
3504 messages sent by the user. With o1 models and newer, `developer` messages
3505 replace the previous `system` messages.
3506
3507 - `chat_completion_developer_message_param: object { content, role, name }`
3508
3509 Developer-provided instructions that the model should follow, regardless of
3510 messages sent by the user. With o1 models and newer, `developer` messages
3511 replace the previous `system` messages.
3512
3513 - `content: string or array of ChatCompletionContentPartText`
3514
3515 The contents of the developer message.
3516
3517 - `Text content: string`
3518
3519 The contents of the developer message.
3520
3521 - `Array of content parts: array of ChatCompletionContentPartText`
3522
3523 An array of content parts with a defined type. For developer messages, only type `text` is supported.
3524
3525 - `text: string`
3526
3527 The text content.
3528
3529 - `type: "text"`
3530
3531 The type of the content part.
3532
3533 - `role: "developer"`
3534
3535 The role of the messages author, in this case `developer`.
3536
3537 - `name: optional string`
3538
3539 An optional name for the participant. Provides the model information to differentiate between participants of the same role.
3540
3541 - `chat_completion_system_message_param: object { content, role, name }`
3542
3543 Developer-provided instructions that the model should follow, regardless of
3544 messages sent by the user. With o1 models and newer, use `developer` messages
3545 for this purpose instead.
3546
3547 - `content: string or array of ChatCompletionContentPartText`
3548
3549 The contents of the system message.
3550
3551 - `Text content: string`
3552
3553 The contents of the system message.
3554
3555 - `Array of content parts: array of ChatCompletionContentPartText`
3556
3557 An array of content parts with a defined type. For system messages, only type `text` is supported.
3558
3559 - `text: string`
3560
3561 The text content.
3562
3563 - `type: "text"`
3564
3565 The type of the content part.
3566
3567 - `role: "system"`
3568
3569 The role of the messages author, in this case `system`.
3570
3571 - `name: optional string`
3572
3573 An optional name for the participant. Provides the model information to differentiate between participants of the same role.
3574
3575 - `chat_completion_user_message_param: object { content, role, name }`
3576
3577 Messages sent by an end user, containing prompts or additional context
3578 information.
3579
3580 - `content: string or array of ChatCompletionContentPart`
3581
3582 The contents of the user message.
3583
3584 - `Text content: string`
3585
3586 The text contents of the message.
3587
3588 - `Array of content parts: array of ChatCompletionContentPart`
3589
3590 An array of content parts with a defined type. Supported options differ based on the [model](https://platform.openai.com/docs/models) being used to generate the response. Can contain text, image, or audio inputs.
3591
3592 - `chat_completion_content_part_text: object { text, type }`
3593
3594 Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
3595
3596 - `text: string`
3597
3598 The text content.
3599
3600 - `type: "text"`
3601
3602 The type of the content part.
3603
3604 - `chat_completion_content_part_image: object { image_url, type }`
3605
3606 Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
3607
3608 - `image_url: object { url, detail }`
3609
3610 - `url: string`
3611
3612 Either a URL of the image or the base64 encoded image data.
3613
3614 - `detail: optional "auto" or "low" or "high"`
3615
3616 Specifies the detail level of the image. Learn more in the [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding).
3617
3618 - `"auto"`
3619
3620 - `"low"`
3621
3622 - `"high"`
3623
3624 - `type: "image_url"`
3625
3626 The type of the content part.
3627
3628 - `chat_completion_content_part_input_audio: object { input_audio, type }`
3629
3630 Learn about [audio inputs](https://platform.openai.com/docs/guides/audio).
3631
3632 - `input_audio: object { data, format }`
3633
3634 - `data: string`
3635
3636 Base64 encoded audio data.
3637
3638 - `format: "wav" or "mp3"`
3639
3640 The format of the encoded audio data. Currently supports "wav" and "mp3".
3641
3642 - `"wav"`
3643
3644 - `"mp3"`
3645
3646 - `type: "input_audio"`
3647
3648 The type of the content part. Always `input_audio`.
3649
3650 - `file: object { file, type }`
3651
3652 Learn about [file inputs](https://platform.openai.com/docs/guides/text) for text generation.
3653
3654 - `file: object { file_data, file_id, filename }`
3655
3656 - `file_data: optional string`
3657
3658 The base64 encoded file data, used when passing the file to the model
3659 as a string.
3660
3661 - `file_id: optional string`
3662
3663 The ID of an uploaded file to use as input.
3664
3665 - `filename: optional string`
3666
3667 The name of the file, used when passing the file to the model as a
3668 string.
3669
3670 - `type: "file"`
3671
3672 The type of the content part. Always `file`.
3673
3674 - `role: "user"`
3675
3676 The role of the messages author, in this case `user`.
3677
3678 - `name: optional string`
3679
3680 An optional name for the participant. Provides the model information to differentiate between participants of the same role.
3681
3682 - `chat_completion_assistant_message_param: object { role, audio, content, 4 more }`
3683
3684 Messages sent by the model in response to user messages.
3685
3686 - `role: "assistant"`
3687
3688 The role of the messages author, in this case `assistant`.
3689
3690 - `audio: optional object { id }`
3691
3692 Data about a previous audio response from the model.
3693 [Learn more](https://platform.openai.com/docs/guides/audio).
3694
3695 - `id: string`
3696
3697 Unique identifier for a previous audio response from the model.
3698
3699 - `content: optional string or array of ChatCompletionContentPartText or ChatCompletionContentPartRefusal`
3700
3701 The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.
3702
3703 - `Text content: string`
3704
3705 The contents of the assistant message.
3706
3707 - `Array of content parts: array of ChatCompletionContentPartText or ChatCompletionContentPartRefusal`
3708
3709 An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.
3710
3711 - `chat_completion_content_part_text: object { text, type }`
3712
3713 Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
3714
3715 - `text: string`
3716
3717 The text content.
3718
3719 - `type: "text"`
3720
3721 The type of the content part.
3722
3723 - `chat_completion_content_part_refusal: object { refusal, type }`
3724
3725 - `refusal: string`
3726
3727 The refusal message generated by the model.
3728
3729 - `type: "refusal"`
3730
3731 The type of the content part.
3732
3733 - `function_call: optional object { arguments, name }`
3734
3735 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
3736
3737 - `arguments: string`
3738
3739 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
3740
3741 - `name: string`
3742
3743 The name of the function to call.
3744
3745 - `name: optional string`
3746
3747 An optional name for the participant. Provides the model information to differentiate between participants of the same role.
3748
3749 - `refusal: optional string`
3750
3751 The refusal message by the assistant.
3752
3753 - `tool_calls: optional array of ChatCompletionMessageToolCall`
3754
3755 The tool calls generated by the model, such as function calls.
3756
3757 - `chat_completion_message_function_tool_call: object { id, function, type }`
3758
3759 A call to a function tool created by the model.
3760
3761 - `id: string`
3762
3763 The ID of the tool call.
3764
3765 - `function: object { arguments, name }`
3766
3767 The function that the model called.
3768
3769 - `arguments: string`
3770
3771 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
3772
3773 - `name: string`
3774
3775 The name of the function to call.
3776
3777 - `type: "function"`
3778
3779 The type of the tool. Currently, only `function` is supported.
3780
3781 - `chat_completion_message_custom_tool_call: object { id, custom, type }`
3782
3783 A call to a custom tool created by the model.
3784
3785 - `id: string`
3786
3787 The ID of the tool call.
3788
3789 - `custom: object { input, name }`
3790
3791 The custom tool that the model called.
3792
3793 - `input: string`
3794
3795 The input for the custom tool call generated by the model.
3796
3797 - `name: string`
3798
3799 The name of the custom tool to call.
3800
3801 - `type: "custom"`
3802
3803 The type of the tool. Always `custom`.
3804
3805 - `chat_completion_tool_message_param: object { content, role, tool_call_id }`
3806
3807 - `content: string or array of ChatCompletionContentPartText`
3808
3809 The contents of the tool message.
3810
3811 - `Text content: string`
3812
3813 The contents of the tool message.
3814
3815 - `Array of content parts: array of ChatCompletionContentPartText`
3816
3817 An array of content parts with a defined type. For tool messages, only type `text` is supported.
3818
3819 - `text: string`
3820
3821 The text content.
3822
3823 - `type: "text"`
3824
3825 The type of the content part.
3826
3827 - `role: "tool"`
3828
3829 The role of the messages author, in this case `tool`.
3830
3831 - `tool_call_id: string`
3832
3833 Tool call that this message is responding to.
3834
3835 - `chat_completion_function_message_param: object { content, name, role }`
3836
3837 - `content: string`
3838
3839 The contents of the function message.
3840
3841 - `name: string`
3842
3843 The name of the function to call.
3844
3845 - `role: "function"`
3846
3847 The role of the messages author, in this case `function`.
3848
3849### Chat Completion Message Tool Call
3850
3851- `chat_completion_message_tool_call: ChatCompletionMessageFunctionToolCall or ChatCompletionMessageCustomToolCall`
3852
3853 A call to a function tool created by the model.
3854
3855 - `chat_completion_message_function_tool_call: object { id, function, type }`
3856
3857 A call to a function tool created by the model.
3858
3859 - `id: string`
3860
3861 The ID of the tool call.
3862
3863 - `function: object { arguments, name }`
3864
3865 The function that the model called.
3866
3867 - `arguments: string`
3868
3869 The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
3870
3871 - `name: string`
3872
3873 The name of the function to call.
3874
3875 - `type: "function"`
3876
3877 The type of the tool. Currently, only `function` is supported.
3878
3879 - `chat_completion_message_custom_tool_call: object { id, custom, type }`
3880
3881 A call to a custom tool created by the model.
3882
3883 - `id: string`
3884
3885 The ID of the tool call.
3886
3887 - `custom: object { input, name }`
3888
3889 The custom tool that the model called.
3890
3891 - `input: string`
3892
3893 The input for the custom tool call generated by the model.
3894
3895 - `name: string`
3896
3897 The name of the custom tool to call.
3898
3899 - `type: "custom"`
3900
3901 The type of the tool. Always `custom`.
3902
3903### Chat Completion Modality
3904
3905- `chat_completion_modality: "text" or "audio"`
3906
3907 - `"text"`
3908
3909 - `"audio"`
3910
3911### Chat Completion Named Tool Choice
3912
3913- `chat_completion_named_tool_choice: object { function, type }`
3914
3915 Specifies a tool the model should use. Use to force the model to call a specific function.
3916
3917 - `function: object { name }`
3918
3919 - `name: string`
3920
3921 The name of the function to call.
3922
3923 - `type: "function"`
3924
3925 For function calling, the type is always `function`.
3926
3927### Chat Completion Named Tool Choice Custom
3928
3929- `chat_completion_named_tool_choice_custom: object { custom, type }`
3930
3931 Specifies a tool the model should use. Use to force the model to call a specific custom tool.
3932
3933 - `custom: object { name }`
3934
3935 - `name: string`
3936
3937 The name of the custom tool to call.
3938
3939 - `type: "custom"`
3940
3941 For custom tool calling, the type is always `custom`.
3942
3943### Chat Completion Prediction Content
3944
3945- `chat_completion_prediction_content: object { content, type }`
3946
3947 Static predicted output content, such as the content of a text file that is
3948 being regenerated.
3949
3950 - `content: string or array of ChatCompletionContentPartText`
3951
3952 The content that should be matched when generating a model response.
3953 If generated tokens would match this content, the entire model response
3954 can be returned much more quickly.
3955
3956 - `Text content: string`
3957
3958 The content used for a Predicted Output. This is often the
3959 text of a file you are regenerating with minor changes.
3960
3961 - `Array of content parts: array of ChatCompletionContentPartText`
3962
3963 An array of content parts with a defined type. Supported options differ based on the [model](https://platform.openai.com/docs/models) being used to generate the response. Can contain text inputs.
3964
3965 - `text: string`
3966
3967 The text content.
3968
3969 - `type: "text"`
3970
3971 The type of the content part.
3972
3973 - `type: "content"`
3974
3975 The type of the predicted content you want to provide. This type is
3976 currently always `content`.
3977
3978### Chat Completion Role
3979
3980- `chat_completion_role: "developer" or "system" or "user" or 3 more`
3981
3982 The role of the author of a message
3983
3984 - `"developer"`
3985
3986 - `"system"`
3987
3988 - `"user"`
3989
3990 - `"assistant"`
3991
3992 - `"tool"`
3993
3994 - `"function"`
3995
3996### Chat Completion Store Message
3997
3998- `chat_completion_store_message: ChatCompletionMessage`
3999
4000 A chat completion message generated by the model.
4001
4002 - `id: string`
4003
4004 The identifier of the chat message.
4005
4006 - `content_parts: optional array of ChatCompletionContentPartText or ChatCompletionContentPartImage`
4007
4008 If a content parts array was provided, this is an array of `text` and `image_url` parts.
4009 Otherwise, null.
4010
4011 - `chat_completion_content_part_text: object { text, type }`
4012
4013 Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
4014
4015 - `text: string`
4016
4017 The text content.
4018
4019 - `type: "text"`
4020
4021 The type of the content part.
4022
4023 - `chat_completion_content_part_image: object { image_url, type }`
4024
4025 Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
4026
4027 - `image_url: object { url, detail }`
4028
4029 - `url: string`
4030
4031 Either a URL of the image or the base64 encoded image data.
4032
4033 - `detail: optional "auto" or "low" or "high"`
4034
4035 Specifies the detail level of the image. Learn more in the [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding).
4036
4037 - `"auto"`
4038
4039 - `"low"`
4040
4041 - `"high"`
4042
4043 - `type: "image_url"`
4044
4045 The type of the content part.
4046
4047### Chat Completion Stream Options
4048
4049- `chat_completion_stream_options: object { include_obfuscation, include_usage }`
4050
4051 Options for streaming response. Only set this when you set `stream: true`.
4052
4053 - `include_obfuscation: optional boolean`
4054
4055 When true, stream obfuscation will be enabled. Stream obfuscation adds
4056 random characters to an `obfuscation` field on streaming delta events to
4057 normalize payload sizes as a mitigation to certain side-channel attacks.
4058 These obfuscation fields are included by default, but add a small amount
4059 of overhead to the data stream. You can set `include_obfuscation` to
4060 false to optimize for bandwidth if you trust the network links between
4061 your application and the OpenAI API.
4062
4063 - `include_usage: optional boolean`
4064
4065 If set, an additional chunk will be streamed before the `data: [DONE]`
4066 message. The `usage` field on this chunk shows the token usage statistics
4067 for the entire request, and the `choices` field will always be an empty
4068 array.
4069
4070 All other chunks will also include a `usage` field, but with a null
4071 value. **NOTE:** If the stream is interrupted, you may not receive the
4072 final usage chunk which contains the total token usage for the request.
4073
4074### Chat Completion System Message Param
4075
4076- `chat_completion_system_message_param: object { content, role, name }`
4077
4078 Developer-provided instructions that the model should follow, regardless of
4079 messages sent by the user. With o1 models and newer, use `developer` messages
4080 for this purpose instead.
4081
4082 - `content: string or array of ChatCompletionContentPartText`
4083
4084 The contents of the system message.
4085
4086 - `Text content: string`
4087
4088 The contents of the system message.
4089
4090 - `Array of content parts: array of ChatCompletionContentPartText`
4091
4092 An array of content parts with a defined type. For system messages, only type `text` is supported.
4093
4094 - `text: string`
4095
4096 The text content.
4097
4098 - `type: "text"`
4099
4100 The type of the content part.
4101
4102 - `role: "system"`
4103
4104 The role of the messages author, in this case `system`.
4105
4106 - `name: optional string`
4107
4108 An optional name for the participant. Provides the model information to differentiate between participants of the same role.
4109
4110### Chat Completion Token Logprob
4111
4112- `chat_completion_token_logprob: object { token, bytes, logprob, top_logprobs }`
4113
4114 - `token: string`
4115
4116 The token.
4117
4118 - `bytes: array of number`
4119
4120 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
4121
4122 - `logprob: number`
4123
4124 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
4125
4126 - `top_logprobs: array of object { token, bytes, logprob }`
4127
4128 List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.
4129
4130 - `token: string`
4131
4132 The token.
4133
4134 - `bytes: array of number`
4135
4136 A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
4137
4138 - `logprob: number`
4139
4140 The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely.
4141
4142### Chat Completion Tool
4143
4144- `chat_completion_tool: ChatCompletionFunctionTool or ChatCompletionCustomTool`
4145
4146 A function tool that can be used to generate a response.
4147
4148 - `chat_completion_function_tool: object { function, type }`
4149
4150 A function tool that can be used to generate a response.
4151
4152 - `function: object { name, description, parameters, strict }`
4153
4154 - `name: string`
4155
4156 The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
4157
4158 - `description: optional string`
4159
4160 A description of what the function does, used by the model to choose when and how to call the function.
4161
4162 - `parameters: optional map[unknown]`
4163
4164 The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.
4165
4166 Omitting `parameters` defines a function with an empty parameter list.
4167
4168 - `strict: optional boolean`
4169
4170 Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](https://platform.openai.com/docs/guides/function-calling).
4171
4172 - `type: "function"`
4173
4174 The type of the tool. Currently, only `function` is supported.
4175
4176 - `chat_completion_custom_tool: object { custom, type }`
4177
4178 A custom tool that processes input using a specified format.
4179
4180 - `custom: object { name, description, format }`
4181
4182 Properties of the custom tool.
4183
4184 - `name: string`
4185
4186 The name of the custom tool, used to identify it in tool calls.
4187
4188 - `description: optional string`
4189
4190 Optional description of the custom tool, used to provide more context.
4191
4192 - `format: optional object { type } or object { grammar, type }`
4193
4194 The input format for the custom tool. Default is unconstrained text.
4195
4196 - `text: object { type }`
4197
4198 Unconstrained free-form text.
4199
4200 - `grammar: object { grammar, type }`
4201
4202 A grammar defined by the user.
4203
4204 - `grammar: object { definition, syntax }`
4205
4206 Your chosen grammar.
4207
4208 - `definition: string`
4209
4210 The grammar definition.
4211
4212 - `syntax: "lark" or "regex"`
4213
4214 The syntax of the grammar definition. One of `lark` or `regex`.
4215
4216 - `"lark"`
4217
4218 - `"regex"`
4219
4220 - `type: "grammar"`
4221
4222 Grammar format. Always `grammar`.
4223
4224 - `type: "custom"`
4225
4226 The type of the custom tool. Always `custom`.
4227
4228### Chat Completion Tool Choice Option
4229
4230- `chat_completion_tool_choice_option: "none" or "auto" or "required" or ChatCompletionAllowedToolChoice or ChatCompletionNamedToolChoice or ChatCompletionNamedToolChoiceCustom`
4231
4232 Controls which (if any) tool is called by the model.
4233 `none` means the model will not call any tool and instead generates a message.
4234 `auto` means the model can pick between generating a message or calling one or more tools.
4235 `required` means the model must call one or more tools.
4236 Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.
4237
4238 `none` is the default when no tools are present. `auto` is the default if tools are present.
4239
4240 - `Auto: "none" or "auto" or "required"`
4241
4242 `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools.
4243
4244 - `"none"`
4245
4246 - `"auto"`
4247
4248 - `"required"`
4249
4250 - `chat_completion_allowed_tool_choice: object { allowed_tools, type }`
4251
4252 Constrains the tools available to the model to a pre-defined set.
4253
4254 - `allowed_tools: object { mode, tools }`
4255
4256 Constrains the tools available to the model to a pre-defined set.
4257
4258 - `mode: "auto" or "required"`
4259
4260 Constrains the tools available to the model to a pre-defined set.
4261
4262 `auto` allows the model to pick from among the allowed tools and generate a
4263 message.
4264
4265 `required` requires the model to call one or more of the allowed tools.
4266
4267 - `"auto"`
4268
4269 - `"required"`
4270
4271 - `tools: array of map[unknown]`
4272
4273 A list of tool definitions that the model should be allowed to call.
4274
4275 For the Chat Completions API, the list of tool definitions might look like:
4276
4277 ```json
4278 [
4279 { "type": "function", "function": { "name": "get_weather" } },
4280 { "type": "function", "function": { "name": "get_time" } }
4281 ]
4282 ```
4283
4284 - `type: "allowed_tools"`
4285
4286 Allowed tool configuration type. Always `allowed_tools`.
4287
4288 - `chat_completion_named_tool_choice: object { function, type }`
4289
4290 Specifies a tool the model should use. Use to force the model to call a specific function.
4291
4292 - `function: object { name }`
4293
4294 - `name: string`
4295
4296 The name of the function to call.
4297
4298 - `type: "function"`
4299
4300 For function calling, the type is always `function`.
4301
4302 - `chat_completion_named_tool_choice_custom: object { custom, type }`
4303
4304 Specifies a tool the model should use. Use to force the model to call a specific custom tool.
4305
4306 - `custom: object { name }`
4307
4308 - `name: string`
4309
4310 The name of the custom tool to call.
4311
4312 - `type: "custom"`
4313
4314 For custom tool calling, the type is always `custom`.
4315
4316### Chat Completion Tool Message Param
4317
4318- `chat_completion_tool_message_param: object { content, role, tool_call_id }`
4319
4320 - `content: string or array of ChatCompletionContentPartText`
4321
4322 The contents of the tool message.
4323
4324 - `Text content: string`
4325
4326 The contents of the tool message.
4327
4328 - `Array of content parts: array of ChatCompletionContentPartText`
4329
4330 An array of content parts with a defined type. For tool messages, only type `text` is supported.
4331
4332 - `text: string`
4333
4334 The text content.
4335
4336 - `type: "text"`
4337
4338 The type of the content part.
4339
4340 - `role: "tool"`
4341
4342 The role of the messages author, in this case `tool`.
4343
4344 - `tool_call_id: string`
4345
4346 Tool call that this message is responding to.
4347
4348### Chat Completion User Message Param
4349
4350- `chat_completion_user_message_param: object { content, role, name }`
4351
4352 Messages sent by an end user, containing prompts or additional context
4353 information.
4354
4355 - `content: string or array of ChatCompletionContentPart`
4356
4357 The contents of the user message.
4358
4359 - `Text content: string`
4360
4361 The text contents of the message.
4362
4363 - `Array of content parts: array of ChatCompletionContentPart`
4364
4365 An array of content parts with a defined type. Supported options differ based on the [model](https://platform.openai.com/docs/models) being used to generate the response. Can contain text, image, or audio inputs.
4366
4367 - `chat_completion_content_part_text: object { text, type }`
4368
4369 Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
4370
4371 - `text: string`
4372
4373 The text content.
4374
4375 - `type: "text"`
4376
4377 The type of the content part.
4378
4379 - `chat_completion_content_part_image: object { image_url, type }`
4380
4381 Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
4382
4383 - `image_url: object { url, detail }`
4384
4385 - `url: string`
4386
4387 Either a URL of the image or the base64 encoded image data.
4388
4389 - `detail: optional "auto" or "low" or "high"`
4390
4391 Specifies the detail level of the image. Learn more in the [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding).
4392
4393 - `"auto"`
4394
4395 - `"low"`
4396
4397 - `"high"`
4398
4399 - `type: "image_url"`
4400
4401 The type of the content part.
4402
4403 - `chat_completion_content_part_input_audio: object { input_audio, type }`
4404
4405 Learn about [audio inputs](https://platform.openai.com/docs/guides/audio).
4406
4407 - `input_audio: object { data, format }`
4408
4409 - `data: string`
4410
4411 Base64 encoded audio data.
4412
4413 - `format: "wav" or "mp3"`
4414
4415 The format of the encoded audio data. Currently supports "wav" and "mp3".
4416
4417 - `"wav"`
4418
4419 - `"mp3"`
4420
4421 - `type: "input_audio"`
4422
4423 The type of the content part. Always `input_audio`.
4424
4425 - `file: object { file, type }`
4426
4427 Learn about [file inputs](https://platform.openai.com/docs/guides/text) for text generation.
4428
4429 - `file: object { file_data, file_id, filename }`
4430
4431 - `file_data: optional string`
4432
4433 The base64 encoded file data, used when passing the file to the model
4434 as a string.
4435
4436 - `file_id: optional string`
4437
4438 The ID of an uploaded file to use as input.
4439
4440 - `filename: optional string`
4441
4442 The name of the file, used when passing the file to the model as a
4443 string.
4444
4445 - `type: "file"`
4446
4447 The type of the content part. Always `file`.
4448
4449 - `role: "user"`
4450
4451 The role of the messages author, in this case `user`.
4452
4453 - `name: optional string`
4454
4455 An optional name for the participant. Provides the model information to differentiate between participants of the same role.
4456
4457### Chat Completion Allowed Tools
4458
4459- `ChatCompletionAllowedTools: object { mode, tools }`
4460
4461 Constrains the tools available to the model to a pre-defined set.
4462
4463 - `mode: "auto" or "required"`
4464
4465 Constrains the tools available to the model to a pre-defined set.
4466
4467 `auto` allows the model to pick from among the allowed tools and generate a
4468 message.
4469
4470 `required` requires the model to call one or more of the allowed tools.
4471
4472 - `"auto"`
4473
4474 - `"required"`
4475
4476 - `tools: array of map[unknown]`
4477
4478 A list of tool definitions that the model should be allowed to call.
4479
4480 For the Chat Completions API, the list of tool definitions might look like:
4481
4482 ```json
4483 [
4484 { "type": "function", "function": { "name": "get_weather" } },
4485 { "type": "function", "function": { "name": "get_time" } }
4486 ]
4487 ```
4488
4489# Messages
4490
4491## Get chat messages
4492
4493`$ openai chat:completions:messages list`
4494
4495**get** `/chat/completions/{completion_id}/messages`
4496
4497Get the messages in a stored chat completion. Only Chat Completions that
4498have been created with the `store` parameter set to `true` will be
4499returned.
4500
4501### Parameters
4502
4503- `--completion-id: string`
4504
4505 The ID of the chat completion to retrieve messages from.
4506
4507- `--after: optional string`
4508
4509 Identifier for the last message from the previous pagination request.
4510
4511- `--limit: optional number`
4512
4513 Number of messages to retrieve.
4514
4515- `--order: optional "asc" or "desc"`
4516
4517 Sort order for messages by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.
4518
4519### Returns
4520
4521- `ChatCompletionMessageList: object { data, first_id, has_more, 2 more }`
4522
4523 An object representing a list of chat completion messages.
4524
4525 - `data: array of ChatCompletionStoreMessage`
4526
4527 An array of chat completion message objects.
4528
4529 - `id: string`
4530
4531 The identifier of the chat message.
4532
4533 - `content_parts: optional array of ChatCompletionContentPartText or ChatCompletionContentPartImage`
4534
4535 If a content parts array was provided, this is an array of `text` and `image_url` parts.
4536 Otherwise, null.
4537
4538 - `chat_completion_content_part_text: object { text, type }`
4539
4540 Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
4541
4542 - `text: string`
4543
4544 The text content.
4545
4546 - `type: "text"`
4547
4548 The type of the content part.
4549
4550 - `chat_completion_content_part_image: object { image_url, type }`
4551
4552 Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
4553
4554 - `image_url: object { url, detail }`
4555
4556 - `url: string`
4557
4558 Either a URL of the image or the base64 encoded image data.
4559
4560 - `detail: optional "auto" or "low" or "high"`
4561
4562 Specifies the detail level of the image. Learn more in the [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding).
4563
4564 - `"auto"`
4565
4566 - `"low"`
4567
4568 - `"high"`
4569
4570 - `type: "image_url"`
4571
4572 The type of the content part.
4573
4574 - `first_id: string`
4575
4576 The identifier of the first chat message in the data array.
4577
4578 - `has_more: boolean`
4579
4580 Indicates whether there are more chat messages available.
4581
4582 - `last_id: string`
4583
4584 The identifier of the last chat message in the data array.
4585
4586 - `object: "list"`
4587
4588 The type of this object. It is always set to "list".
4589
4590### Example
4591
4592```cli
4593openai chat:completions:messages list \
4594 --api-key 'My API Key' \
4595 --completion-id completion_id
4596```
4597
4598#### Response
4599
4600```json
4601{
4602 "data": [
4603 {
4604 "content": "content",
4605 "refusal": "refusal",
4606 "role": "assistant",
4607 "annotations": [
4608 {
4609 "type": "url_citation",
4610 "url_citation": {
4611 "end_index": 0,
4612 "start_index": 0,
4613 "title": "title",
4614 "url": "https://example.com"
4615 }
4616 }
4617 ],
4618 "audio": {
4619 "id": "id",
4620 "data": "data",
4621 "expires_at": 0,
4622 "transcript": "transcript"
4623 },
4624 "function_call": {
4625 "arguments": "arguments",
4626 "name": "name"
4627 },
4628 "tool_calls": [
4629 {
4630 "id": "id",
4631 "function": {
4632 "arguments": "arguments",
4633 "name": "name"
4634 },
4635 "type": "function"
4636 }
4637 ],
4638 "id": "id",
4639 "content_parts": [
4640 {
4641 "text": "text",
4642 "type": "text"
4643 }
4644 ]
4645 }
4646 ],
4647 "first_id": "first_id",
4648 "has_more": true,
4649 "last_id": "last_id",
4650 "object": "list"
4651}
4652```