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