SpyBara
Go Premium

Reference 2026-06-10 15:48 UTC to 2026-06-12 00:01 UTC

82 files changed +28,379 −165. View all changes and history on the product overview
2026
Fri 26 17:57 Wed 17 18:02 Tue 16 21:57 Fri 12 00:01 Wed 10 15:48 Tue 9 06:34 Fri 5 06:45 Thu 4 06:52 Tue 2 06:51
Details

1## Create speech

2 

3`$ openai audio:speech create`

4 

5**post** `/audio/speech`

6 

7Generates audio from the input text.

8 

9Returns the audio file content, or a stream of audio events.

10 

11### Parameters

12 

13- `--input: string`

14 

15 The text to generate audio for. The maximum length is 4096 characters.

16 

17- `--model: string or SpeechModel`

18 

19 One of the available [TTS models](https://platform.openai.com/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.

20 

21- `--voice: string or "alloy" or "ash" or "ballad" or 7 more or object { id }`

22 

23 The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ "id": "voice_1234" }`. Previews of the voices are available in the [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).

24 

25- `--instructions: optional string`

26 

27 Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.

28 

29- `--response-format: optional "mp3" or "opus" or "aac" or 3 more`

30 

31 The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.

32 

33- `--speed: optional number`

34 

35 The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.

36 

37- `--stream-format: optional "sse" or "audio"`

38 

39 The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.

40 

41### Returns

42 

43- `unnamed_schema_2: file path`

44 

45### Example

46 

47```cli

48openai audio:speech create \

49 --api-key 'My API Key' \

50 --input input \

51 --model tts-1 \

52 --voice alloy

53```

Details

1## Create client secret

2 

3`$ openai realtime:client-secrets create`

4 

5**post** `/realtime/client_secrets`

6 

7Create a Realtime client secret with an associated session configuration.

8 

9Client secrets are short-lived tokens that can be passed to a client app,

10such as a web frontend or mobile client, which grants access to the Realtime API without

11leaking your main API key. You can configure a custom TTL for each client secret.

12 

13You can also attach session configuration options to the client secret, which will be

14applied to any sessions created using that client secret, but these can also be overridden

15by the client connection.

16 

17[Learn more about authentication with client secrets over WebRTC](https://platform.openai.com/docs/guides/realtime-webrtc).

18 

19Returns the created client secret and the effective session object. The client secret is a string that looks like `ek_1234`.

20 

21### Parameters

22 

23- `--expires-after: optional object { anchor, seconds }`

24 

25 Configuration for the client secret expiration. Expiration refers to the time after which

26 a client secret will no longer be valid for creating sessions. The session itself may

27 continue after that time once started. A secret can be used to create multiple sessions

28 until it expires.

29 

30- `--session: optional RealtimeSessionCreateRequest or RealtimeTranscriptionSessionCreateRequest`

31 

32 Session configuration to use for the client secret. Choose either a realtime

33 session or a transcription session.

34 

35### Returns

36 

37- `ClientSecretNewResponse: object { expires_at, session, value }`

38 

39 Response from creating a session and client secret for the Realtime API.

40 

41 - `expires_at: number`

42 

43 Expiration timestamp for the client secret, in seconds since epoch.

44 

45 - `session: RealtimeSessionCreateResponse or RealtimeTranscriptionSessionCreateResponse`

46 

47 The session configuration for either a realtime or transcription session.

48 

49 - `realtime_session_create_response: object { id, object, type, 13 more }`

50 

51 A Realtime session configuration object.

52 

53 - `id: string`

54 

55 Unique identifier for the session that looks like `sess_1234567890abcdef`.

56 

57 - `object: "realtime.session"`

58 

59 The object type. Always `realtime.session`.

60 

61 - `type: "realtime"`

62 

63 The type of session to create. Always `realtime` for the Realtime API.

64 

65 - `audio: optional object { input, output }`

66 

67 Configuration for input and output audio.

68 

69 - `input: optional object { format, noise_reduction, transcription, turn_detection }`

70 

71 - `format: optional object { rate, type } or object { type } or object { type }`

72 

73 The format of the input audio.

74 

75 - `audio/pcm: object { rate, type }`

76 

77 The PCM audio format. Only a 24kHz sample rate is supported.

78 

79 - `rate: optional 24000`

80 

81 The sample rate of the audio. Always `24000`.

82 

83 - `24000`

84 

85 - `type: optional "audio/pcm"`

86 

87 The audio format. Always `audio/pcm`.

88 

89 - `"audio/pcm"`

90 

91 - `audio/pcmu: object { type }`

92 

93 The G.711 μ-law format.

94 

95 - `type: optional "audio/pcmu"`

96 

97 The audio format. Always `audio/pcmu`.

98 

99 - `"audio/pcmu"`

100 

101 - `audio/pcma: object { type }`

102 

103 The G.711 A-law format.

104 

105 - `type: optional "audio/pcma"`

106 

107 The audio format. Always `audio/pcma`.

108 

109 - `"audio/pcma"`

110 

111 - `noise_reduction: optional object { type }`

112 

113 Configuration for input audio noise reduction. This can be set to `null` to turn off.

114 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

115 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

116 

117 - `type: optional "near_field" or "far_field"`

118 

119 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

120 

121 - `"near_field"`

122 

123 - `"far_field"`

124 

125 - `transcription: optional object { delay, language, model, prompt }`

126 

127 - `delay: optional "minimal" or "low" or "medium" or 2 more`

128 

129 Controls how long the model waits before emitting transcription text.

130 Higher values can improve transcription accuracy at the cost of latency.

131 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

132 

133 - `"minimal"`

134 

135 - `"low"`

136 

137 - `"medium"`

138 

139 - `"high"`

140 

141 - `"xhigh"`

142 

143 - `language: optional string`

144 

145 The language of the input audio. Supplying the input language in

146 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

147 will improve accuracy and latency.

148 

149 - `model: optional string or "whisper-1" or "gpt-4o-mini-transcribe" or "gpt-4o-mini-transcribe-2025-12-15" or 3 more`

150 

151 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

152 

153 - `"whisper-1"`

154 

155 - `"gpt-4o-mini-transcribe"`

156 

157 - `"gpt-4o-mini-transcribe-2025-12-15"`

158 

159 - `"gpt-4o-transcribe"`

160 

161 - `"gpt-4o-transcribe-diarize"`

162 

163 - `"gpt-realtime-whisper"`

164 

165 - `prompt: optional string`

166 

167 An optional text to guide the model's style or continue a previous audio

168 segment.

169 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).

170 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

171 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

172 

173 - `turn_detection: optional object { type, create_response, idle_timeout_ms, 4 more } or object { type, create_response, eagerness, interrupt_response }`

174 

175 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

176 

177 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

178 

179 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

180 

181 For `gpt-realtime-whisper` transcription sessions, turn detection must be

182 set to `null`; VAD is not supported.

183 

184 - `server_vad: object { type, create_response, idle_timeout_ms, 4 more }`

185 

186 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.

187 

188 - `type: "server_vad"`

189 

190 Type of turn detection, `server_vad` to turn on simple Server VAD.

191 

192 - `create_response: optional boolean`

193 

194 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

195 

196 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

197 

198 - `idle_timeout_ms: optional number`

199 

200 Optional timeout after which a model response will be triggered automatically. This is

201 useful for situations in which a long pause from the user is unexpected, such as a phone

202 call. The model will effectively prompt the user to continue the conversation based

203 on the current context.

204 

205 The timeout value will be applied after the last model response's audio has finished playing,

206 i.e. it's set to the `response.done` time plus audio playback duration.

207 

208 An `input_audio_buffer.timeout_triggered` event (plus events

209 associated with the Response) will be emitted when the timeout is reached.

210 Idle timeout is currently only supported for `server_vad` mode.

211 

212 - `interrupt_response: optional boolean`

213 

214 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

215 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

216 

217 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

218 

219 - `prefix_padding_ms: optional number`

220 

221 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

222 milliseconds). Defaults to 300ms.

223 

224 - `silence_duration_ms: optional number`

225 

226 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

227 to 500ms. With shorter values the model will respond more quickly,

228 but may jump in on short pauses from the user.

229 

230 - `threshold: optional number`

231 

232 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

233 higher threshold will require louder audio to activate the model, and

234 thus might perform better in noisy environments.

235 

236 - `semantic_vad: object { type, create_response, eagerness, interrupt_response }`

237 

238 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.

239 

240 - `type: "semantic_vad"`

241 

242 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

243 

244 - `create_response: optional boolean`

245 

246 Whether or not to automatically generate a response when a VAD stop event occurs.

247 

248 - `eagerness: optional "low" or "medium" or "high" or "auto"`

249 

250 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

251 

252 - `"low"`

253 

254 - `"medium"`

255 

256 - `"high"`

257 

258 - `"auto"`

259 

260 - `interrupt_response: optional boolean`

261 

262 Whether or not to automatically interrupt any ongoing response with output to the default

263 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

264 

265 - `output: optional object { format, speed, voice }`

266 

267 - `format: optional object { rate, type } or object { type } or object { type }`

268 

269 The format of the output audio.

270 

271 - `audio/pcm: object { rate, type }`

272 

273 The PCM audio format. Only a 24kHz sample rate is supported.

274 

275 - `audio/pcmu: object { type }`

276 

277 The G.711 μ-law format.

278 

279 - `audio/pcma: object { type }`

280 

281 The G.711 A-law format.

282 

283 - `speed: optional number`

284 

285 The speed of the model's spoken response as a multiple of the original speed.

286 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.

287 

288 This parameter is a post-processing adjustment to the audio after it is generated, it's

289 also possible to prompt the model to speak faster or slower.

290 

291 - `voice: optional string or "alloy" or "ash" or "ballad" or 7 more`

292 

293 The voice the model uses to respond. Voice cannot be changed during the

294 session once the model has responded with audio at least once. Current

295 voice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,

296 `shimmer`, `verse`, `marin`, and `cedar`. We recommend `marin` and `cedar` for

297 best quality.

298 

299 - `"alloy"`

300 

301 - `"ash"`

302 

303 - `"ballad"`

304 

305 - `"coral"`

306 

307 - `"echo"`

308 

309 - `"sage"`

310 

311 - `"shimmer"`

312 

313 - `"verse"`

314 

315 - `"marin"`

316 

317 - `"cedar"`

318 

319 - `expires_at: optional number`

320 

321 Expiration timestamp for the session, in seconds since epoch.

322 

323 - `include: optional array of "item.input_audio_transcription.logprobs"`

324 

325 Additional fields to include in server outputs.

326 

327 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

328 

329 - `"item.input_audio_transcription.logprobs"`

330 

331 - `instructions: optional string`

332 

333 The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.

334 

335 Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.

336 

337 - `max_output_tokens: optional number or "inf"`

338 

339 Maximum number of output tokens for a single assistant response,

340 inclusive of tool calls. Provide an integer between 1 and 4096 to

341 limit output tokens, or `inf` for the maximum available tokens for a

342 given model. Defaults to `inf`.

343 

344 - `union_member_0: number`

345 

346 - `union_member_1: "inf"`

347 

348 - `model: optional string or "gpt-realtime" or "gpt-realtime-1.5" or "gpt-realtime-2" or 14 more`

349 

350 The Realtime model used for this session.

351 

352 - `"gpt-realtime"`

353 

354 - `"gpt-realtime-1.5"`

355 

356 - `"gpt-realtime-2"`

357 

358 - `"gpt-realtime-2025-08-28"`

359 

360 - `"gpt-4o-realtime-preview"`

361 

362 - `"gpt-4o-realtime-preview-2024-10-01"`

363 

364 - `"gpt-4o-realtime-preview-2024-12-17"`

365 

366 - `"gpt-4o-realtime-preview-2025-06-03"`

367 

368 - `"gpt-4o-mini-realtime-preview"`

369 

370 - `"gpt-4o-mini-realtime-preview-2024-12-17"`

371 

372 - `"gpt-realtime-mini"`

373 

374 - `"gpt-realtime-mini-2025-10-06"`

375 

376 - `"gpt-realtime-mini-2025-12-15"`

377 

378 - `"gpt-audio-1.5"`

379 

380 - `"gpt-audio-mini"`

381 

382 - `"gpt-audio-mini-2025-10-06"`

383 

384 - `"gpt-audio-mini-2025-12-15"`

385 

386 - `output_modalities: optional array of "text" or "audio"`

387 

388 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating

389 that the model will respond with audio plus a transcript. `["text"]` can be used to make

390 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.

391 

392 - `"text"`

393 

394 - `"audio"`

395 

396 - `prompt: optional object { id, variables, version }`

397 

398 Reference to a prompt template and its variables.

399 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).

400 

401 - `id: string`

402 

403 The unique identifier of the prompt template to use.

404 

405 - `variables: optional map[string or ResponseInputText or ResponseInputImage or ResponseInputFile]`

406 

407 Optional map of values to substitute in for variables in your

408 prompt. The substitution values can either be strings, or other

409 Response input types like images or files.

410 

411 - `union_member_0: string`

412 

413 - `response_input_text: object { text, type }`

414 

415 A text input to the model.

416 

417 - `text: string`

418 

419 The text input to the model.

420 

421 - `type: "input_text"`

422 

423 The type of the input item. Always `input_text`.

424 

425 - `response_input_image: object { detail, type, file_id, image_url }`

426 

427 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).

428 

429 - `detail: "low" or "high" or "auto" or "original"`

430 

431 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.

432 

433 - `"low"`

434 

435 - `"high"`

436 

437 - `"auto"`

438 

439 - `"original"`

440 

441 - `type: "input_image"`

442 

443 The type of the input item. Always `input_image`.

444 

445 - `file_id: optional string`

446 

447 The ID of the file to be sent to the model.

448 

449 - `image_url: optional string`

450 

451 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.

452 

453 - `response_input_file: object { type, detail, file_data, 3 more }`

454 

455 A file input to the model.

456 

457 - `type: "input_file"`

458 

459 The type of the input item. Always `input_file`.

460 

461 - `detail: optional "low" or "high"`

462 

463 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.

464 

465 - `"low"`

466 

467 - `"high"`

468 

469 - `file_data: optional string`

470 

471 The content of the file to be sent to the model.

472 

473 - `file_id: optional string`

474 

475 The ID of the file to be sent to the model.

476 

477 - `file_url: optional string`

478 

479 The URL of the file to be sent to the model.

480 

481 - `filename: optional string`

482 

483 The name of the file to be sent to the model.

484 

485 - `version: optional string`

486 

487 Optional version of the prompt template.

488 

489 - `reasoning: optional object { effort }`

490 

491 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.

492 

493 - `effort: optional "minimal" or "low" or "medium" or 2 more`

494 

495 Constrains effort on reasoning for reasoning-capable Realtime models such as

496 `gpt-realtime-2`.

497 

498 - `"minimal"`

499 

500 - `"low"`

501 

502 - `"medium"`

503 

504 - `"high"`

505 

506 - `"xhigh"`

507 

508 - `tool_choice: optional ToolChoiceOptions or ToolChoiceFunction or ToolChoiceMcp`

509 

510 How the model chooses tools. Provide one of the string modes or force a specific

511 function/MCP tool.

512 

513 - `tool_choice_options: "none" or "auto" or "required"`

514 

515 Controls which (if any) tool is called by the model.

516 

517 `none` means the model will not call any tool and instead generates a message.

518 

519 `auto` means the model can pick between generating a message or calling one or

520 more tools.

521 

522 `required` means the model must call one or more tools.

523 

524 - `"none"`

525 

526 - `"auto"`

527 

528 - `"required"`

529 

530 - `tool_choice_function: object { name, type }`

531 

532 Use this option to force the model to call a specific function.

533 

534 - `name: string`

535 

536 The name of the function to call.

537 

538 - `type: "function"`

539 

540 For function calling, the type is always `function`.

541 

542 - `tool_choice_mcp: object { server_label, type, name }`

543 

544 Use this option to force the model to call a specific tool on a remote MCP server.

545 

546 - `server_label: string`

547 

548 The label of the MCP server to use.

549 

550 - `type: "mcp"`

551 

552 For MCP tools, the type is always `mcp`.

553 

554 - `name: optional string`

555 

556 The name of the tool to call on the server.

557 

558 - `tools: optional array of RealtimeFunctionTool or object { server_label, type, allowed_tools, 7 more }`

559 

560 Tools available to the model.

561 

562 - `realtime_function_tool: object { description, name, parameters, type }`

563 

564 - `description: optional string`

565 

566 The description of the function, including guidance on when and how

567 to call it, and guidance about what to tell the user when calling

568 (if anything).

569 

570 - `name: optional string`

571 

572 The name of the function.

573 

574 - `parameters: optional unknown`

575 

576 Parameters of the function in JSON Schema.

577 

578 - `type: optional "function"`

579 

580 The type of the tool, i.e. `function`.

581 

582 - `"function"`

583 

584 - `MCP tool: object { server_label, type, allowed_tools, 7 more }`

585 

586 Give the model access to additional tools via remote Model Context Protocol

587 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).

588 

589 - `server_label: string`

590 

591 A label for this MCP server, used to identify it in tool calls.

592 

593 - `type: "mcp"`

594 

595 The type of the MCP tool. Always `mcp`.

596 

597 - `allowed_tools: optional array of string or object { read_only, tool_names }`

598 

599 List of allowed tool names or a filter object.

600 

601 - `MCP allowed tools: array of string`

602 

603 A string array of allowed tool names

604 

605 - `MCP tool filter: object { read_only, tool_names }`

606 

607 A filter object to specify which tools are allowed.

608 

609 - `read_only: optional boolean`

610 

611 Indicates whether or not a tool modifies data or is read-only. If an

612 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

613 it will match this filter.

614 

615 - `tool_names: optional array of string`

616 

617 List of allowed tool names.

618 

619 - `authorization: optional string`

620 

621 An OAuth access token that can be used with a remote MCP server, either

622 with a custom MCP server URL or a service connector. Your application

623 must handle the OAuth authorization flow and provide the token here.

624 

625 - `connector_id: optional "connector_dropbox" or "connector_gmail" or "connector_googlecalendar" or 5 more`

626 

627 Identifier for service connectors, like those available in ChatGPT. One of

628 `server_url` or `connector_id` must be provided. Learn more about service

629 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).

630 

631 Currently supported `connector_id` values are:

632 

633 - Dropbox: `connector_dropbox`

634 - Gmail: `connector_gmail`

635 - Google Calendar: `connector_googlecalendar`

636 - Google Drive: `connector_googledrive`

637 - Microsoft Teams: `connector_microsoftteams`

638 - Outlook Calendar: `connector_outlookcalendar`

639 - Outlook Email: `connector_outlookemail`

640 - SharePoint: `connector_sharepoint`

641 

642 - `"connector_dropbox"`

643 

644 - `"connector_gmail"`

645 

646 - `"connector_googlecalendar"`

647 

648 - `"connector_googledrive"`

649 

650 - `"connector_microsoftteams"`

651 

652 - `"connector_outlookcalendar"`

653 

654 - `"connector_outlookemail"`

655 

656 - `"connector_sharepoint"`

657 

658 - `defer_loading: optional boolean`

659 

660 Whether this MCP tool is deferred and discovered via tool search.

661 

662 - `headers: optional map[string]`

663 

664 Optional HTTP headers to send to the MCP server. Use for authentication

665 or other purposes.

666 

667 - `require_approval: optional object { always, never } or "always" or "never"`

668 

669 Specify which of the MCP server's tools require approval.

670 

671 - `MCP tool approval filter: object { always, never }`

672 

673 Specify which of the MCP server's tools require approval. Can be

674 `always`, `never`, or a filter object associated with tools

675 that require approval.

676 

677 - `always: optional object { read_only, tool_names }`

678 

679 A filter object to specify which tools are allowed.

680 

681 - `read_only: optional boolean`

682 

683 Indicates whether or not a tool modifies data or is read-only. If an

684 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

685 it will match this filter.

686 

687 - `tool_names: optional array of string`

688 

689 List of allowed tool names.

690 

691 - `never: optional object { read_only, tool_names }`

692 

693 A filter object to specify which tools are allowed.

694 

695 - `read_only: optional boolean`

696 

697 Indicates whether or not a tool modifies data or is read-only. If an

698 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

699 it will match this filter.

700 

701 - `tool_names: optional array of string`

702 

703 List of allowed tool names.

704 

705 - `MCP tool approval setting: "always" or "never"`

706 

707 Specify a single approval policy for all tools. One of `always` or

708 `never`. When set to `always`, all tools will require approval. When

709 set to `never`, all tools will not require approval.

710 

711 - `"always"`

712 

713 - `"never"`

714 

715 - `server_description: optional string`

716 

717 Optional description of the MCP server, used to provide more context.

718 

719 - `server_url: optional string`

720 

721 The URL for the MCP server. One of `server_url` or `connector_id` must be

722 provided.

723 

724 - `tracing: optional "auto" or object { group_id, metadata, workflow_name }`

725 

726 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once

727 tracing is enabled for a session, the configuration cannot be modified.

728 

729 `auto` will create a trace for the session with default values for the

730 workflow name, group id, and metadata.

731 

732 - `auto: "auto"`

733 

734 Enables tracing and sets default values for tracing configuration options. Always `auto`.

735 

736 - `Tracing Configuration: object { group_id, metadata, workflow_name }`

737 

738 Granular configuration for tracing.

739 

740 - `group_id: optional string`

741 

742 The group id to attach to this trace to enable filtering and

743 grouping in the Traces Dashboard.

744 

745 - `metadata: optional unknown`

746 

747 The arbitrary metadata to attach to this trace to enable

748 filtering in the Traces Dashboard.

749 

750 - `workflow_name: optional string`

751 

752 The name of the workflow to attach to this trace. This is used to

753 name the trace in the Traces Dashboard.

754 

755 - `truncation: optional "auto" or "disabled" or RealtimeTruncationRetentionRatio`

756 

757 When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

758 

759 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

760 

761 Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

762 

763 Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.

764 

765 - `RealtimeTruncationStrategy: "auto" or "disabled"`

766 

767 The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit.

768 

769 - `"auto"`

770 

771 - `"disabled"`

772 

773 - `realtime_truncation_retention_ratio: object { retention_ratio, type, token_limits }`

774 

775 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

776 

777 - `retention_ratio: number`

778 

779 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.

780 

781 - `type: "retention_ratio"`

782 

783 Use retention ratio truncation.

784 

785 - `token_limits: optional object { post_instructions }`

786 

787 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.

788 

789 - `post_instructions: optional number`

790 

791 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.

792 

793 - `realtime_transcription_session_create_response: object { id, object, type, 3 more }`

794 

795 A Realtime transcription session configuration object.

796 

797 - `id: string`

798 

799 Unique identifier for the session that looks like `sess_1234567890abcdef`.

800 

801 - `object: string`

802 

803 The object type. Always `realtime.transcription_session`.

804 

805 - `type: "transcription"`

806 

807 The type of session. Always `transcription` for transcription sessions.

808 

809 - `audio: optional object { input }`

810 

811 Configuration for input audio for the session.

812 

813 - `input: optional object { format, noise_reduction, transcription, turn_detection }`

814 

815 - `format: optional object { rate, type } or object { type } or object { type }`

816 

817 The PCM audio format. Only a 24kHz sample rate is supported.

818 

819 - `audio/pcm: object { rate, type }`

820 

821 The PCM audio format. Only a 24kHz sample rate is supported.

822 

823 - `audio/pcmu: object { type }`

824 

825 The G.711 μ-law format.

826 

827 - `audio/pcma: object { type }`

828 

829 The G.711 A-law format.

830 

831 - `noise_reduction: optional object { type }`

832 

833 Configuration for input audio noise reduction.

834 

835 - `type: optional "near_field" or "far_field"`

836 

837 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

838 

839 - `"near_field"`

840 

841 - `"far_field"`

842 

843 - `transcription: optional object { delay, language, model, prompt }`

844 

845 - `delay: optional "minimal" or "low" or "medium" or 2 more`

846 

847 Controls how long the model waits before emitting transcription text.

848 Higher values can improve transcription accuracy at the cost of latency.

849 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

850 

851 - `language: optional string`

852 

853 The language of the input audio. Supplying the input language in

854 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

855 will improve accuracy and latency.

856 

857 - `model: optional string or "whisper-1" or "gpt-4o-mini-transcribe" or "gpt-4o-mini-transcribe-2025-12-15" or 3 more`

858 

859 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

860 

861 - `prompt: optional string`

862 

863 An optional text to guide the model's style or continue a previous audio

864 segment.

865 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).

866 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

867 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

868 

869 - `turn_detection: optional object { prefix_padding_ms, silence_duration_ms, threshold, type }`

870 

871 Configuration for turn detection. Can be set to `null` to turn off. Server

872 VAD means that the model will detect the start and end of speech based on

873 audio volume and respond at the end of user speech. For `gpt-realtime-whisper`, this must be `null`; VAD is not supported.

874 

875 - `prefix_padding_ms: optional number`

876 

877 Amount of audio to include before the VAD detected speech (in

878 milliseconds). Defaults to 300ms.

879 

880 - `silence_duration_ms: optional number`

881 

882 Duration of silence to detect speech stop (in milliseconds). Defaults

883 to 500ms. With shorter values the model will respond more quickly,

884 but may jump in on short pauses from the user.

885 

886 - `threshold: optional number`

887 

888 Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

889 higher threshold will require louder audio to activate the model, and

890 thus might perform better in noisy environments.

891 

892 - `type: optional string`

893 

894 Type of turn detection, only `server_vad` is currently supported.

895 

896 - `expires_at: optional number`

897 

898 Expiration timestamp for the session, in seconds since epoch.

899 

900 - `include: optional array of "item.input_audio_transcription.logprobs"`

901 

902 Additional fields to include in server outputs.

903 

904 - `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

905 

906 - `"item.input_audio_transcription.logprobs"`

907 

908 - `value: string`

909 

910 The generated client secret value.

911 

912### Example

913 

914```cli

915openai realtime:client-secrets create \

916 --api-key 'My API Key'

917```

918 

919#### Response

920 

921```json

922{

923 "expires_at": 0,

924 "session": {

925 "id": "id",

926 "object": "realtime.session",

927 "type": "realtime",

928 "audio": {

929 "input": {

930 "format": {

931 "rate": 24000,

932 "type": "audio/pcm"

933 },

934 "noise_reduction": {

935 "type": "near_field"

936 },

937 "transcription": {

938 "delay": "minimal",

939 "language": "language",

940 "model": "whisper-1",

941 "prompt": "prompt"

942 },

943 "turn_detection": {

944 "type": "server_vad",

945 "create_response": true,

946 "idle_timeout_ms": 5000,

947 "interrupt_response": true,

948 "prefix_padding_ms": 0,

949 "silence_duration_ms": 0,

950 "threshold": 0

951 }

952 },

953 "output": {

954 "format": {

955 "rate": 24000,

956 "type": "audio/pcm"

957 },

958 "speed": 0.25,

959 "voice": "ash"

960 }

961 },

962 "expires_at": 0,

963 "include": [

964 "item.input_audio_transcription.logprobs"

965 ],

966 "instructions": "instructions",

967 "max_output_tokens": "inf",

968 "model": "gpt-realtime",

969 "output_modalities": [

970 "text"

971 ],

972 "prompt": {

973 "id": "id",

974 "variables": {

975 "foo": "string"

976 },

977 "version": "version"

978 },

979 "reasoning": {

980 "effort": "minimal"

981 },

982 "tool_choice": "none",

983 "tools": [

984 {

985 "description": "description",

986 "name": "name",

987 "parameters": {},

988 "type": "function"

989 }

990 ],

991 "tracing": "auto",

992 "truncation": "auto"

993 },

994 "value": "value"

995}

996```

Details

1## Create video

2 

3`$ openai videos create`

4 

5**post** `/videos`

6 

7Create a new video generation job from a prompt and optional reference assets.

8 

9### Parameters

10 

11- `--prompt: string`

12 

13 Text prompt that describes the video to generate.

14 

15- `--input-reference: optional string or ImageInputReferenceParam`

16 

17 Optional reference asset upload or reference object that guides generation.

18 

19- `--model: optional string or "sora-2" or "sora-2-pro" or "sora-2-2025-10-06" or 2 more`

20 

21 The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to `sora-2`.

22 

23- `--seconds: optional "4" or "8" or "12"`

24 

25 Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds.

26 

27- `--size: optional "720x1280" or "1280x720" or "1024x1792" or "1792x1024"`

28 

29 Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280.

30 

31### Returns

32 

33- `video: object { id, completed_at, created_at, 10 more }`

34 

35 Structured information describing a generated video job.

36 

37 - `id: string`

38 

39 Unique identifier for the video job.

40 

41 - `completed_at: number`

42 

43 Unix timestamp (seconds) for when the job completed, if finished.

44 

45 - `created_at: number`

46 

47 Unix timestamp (seconds) for when the job was created.

48 

49 - `error: object { code, message }`

50 

51 Error payload that explains why generation failed, if applicable.

52 

53 - `code: string`

54 

55 A machine-readable error code that was returned.

56 

57 - `message: string`

58 

59 A human-readable description of the error that was returned.

60 

61 - `expires_at: number`

62 

63 Unix timestamp (seconds) for when the downloadable assets expire, if set.

64 

65 - `model: string or "sora-2" or "sora-2-pro" or "sora-2-2025-10-06" or 2 more`

66 

67 The video generation model that produced the job.

68 

69 - `"sora-2"`

70 

71 - `"sora-2-pro"`

72 

73 - `"sora-2-2025-10-06"`

74 

75 - `"sora-2-pro-2025-10-06"`

76 

77 - `"sora-2-2025-12-08"`

78 

79 - `object: "video"`

80 

81 The object type, which is always `video`.

82 

83 - `progress: number`

84 

85 Approximate completion percentage for the generation task.

86 

87 - `prompt: string`

88 

89 The prompt that was used to generate the video.

90 

91 - `remixed_from_video_id: string`

92 

93 Identifier of the source video if this video is a remix.

94 

95 - `seconds: string or VideoSeconds`

96 

97 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

98 

99 - `"4"`

100 

101 - `"8"`

102 

103 - `"12"`

104 

105 - `size: "720x1280" or "1280x720" or "1024x1792" or "1792x1024"`

106 

107 The resolution of the generated video.

108 

109 - `"720x1280"`

110 

111 - `"1280x720"`

112 

113 - `"1024x1792"`

114 

115 - `"1792x1024"`

116 

117 - `status: "queued" or "in_progress" or "completed" or "failed"`

118 

119 Current lifecycle status of the video job.

120 

121 - `"queued"`

122 

123 - `"in_progress"`

124 

125 - `"completed"`

126 

127 - `"failed"`

128 

129### Example

130 

131```cli

132openai videos create \

133 --api-key 'My API Key' \

134 --prompt x

135```

136 

137#### Response

138 

139```json

140{

141 "id": "id",

142 "completed_at": 0,

143 "created_at": 0,

144 "error": {

145 "code": "code",

146 "message": "message"

147 },

148 "expires_at": 0,

149 "model": "sora-2",

150 "object": "video",

151 "progress": 0,

152 "prompt": "prompt",

153 "remixed_from_video_id": "remixed_from_video_id",

154 "seconds": "4",

155 "size": "720x1280",

156 "status": "queued"

157}

158```

Details

1## Create a new video generation job by editing a source video or existing generated video.

2 

3`$ openai videos edit`

4 

5**post** `/videos/edits`

6 

7Create a new video generation job by editing a source video or existing generated video.

8 

9### Parameters

10 

11- `--prompt: string`

12 

13 Text prompt that describes how to edit the source video.

14 

15- `--video: string or object { id }`

16 

17 Reference to the completed video to edit.

18 

19### Returns

20 

21- `video: object { id, completed_at, created_at, 10 more }`

22 

23 Structured information describing a generated video job.

24 

25 - `id: string`

26 

27 Unique identifier for the video job.

28 

29 - `completed_at: number`

30 

31 Unix timestamp (seconds) for when the job completed, if finished.

32 

33 - `created_at: number`

34 

35 Unix timestamp (seconds) for when the job was created.

36 

37 - `error: object { code, message }`

38 

39 Error payload that explains why generation failed, if applicable.

40 

41 - `code: string`

42 

43 A machine-readable error code that was returned.

44 

45 - `message: string`

46 

47 A human-readable description of the error that was returned.

48 

49 - `expires_at: number`

50 

51 Unix timestamp (seconds) for when the downloadable assets expire, if set.

52 

53 - `model: string or "sora-2" or "sora-2-pro" or "sora-2-2025-10-06" or 2 more`

54 

55 The video generation model that produced the job.

56 

57 - `"sora-2"`

58 

59 - `"sora-2-pro"`

60 

61 - `"sora-2-2025-10-06"`

62 

63 - `"sora-2-pro-2025-10-06"`

64 

65 - `"sora-2-2025-12-08"`

66 

67 - `object: "video"`

68 

69 The object type, which is always `video`.

70 

71 - `progress: number`

72 

73 Approximate completion percentage for the generation task.

74 

75 - `prompt: string`

76 

77 The prompt that was used to generate the video.

78 

79 - `remixed_from_video_id: string`

80 

81 Identifier of the source video if this video is a remix.

82 

83 - `seconds: string or VideoSeconds`

84 

85 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

86 

87 - `"4"`

88 

89 - `"8"`

90 

91 - `"12"`

92 

93 - `size: "720x1280" or "1280x720" or "1024x1792" or "1792x1024"`

94 

95 The resolution of the generated video.

96 

97 - `"720x1280"`

98 

99 - `"1280x720"`

100 

101 - `"1024x1792"`

102 

103 - `"1792x1024"`

104 

105 - `status: "queued" or "in_progress" or "completed" or "failed"`

106 

107 Current lifecycle status of the video job.

108 

109 - `"queued"`

110 

111 - `"in_progress"`

112 

113 - `"completed"`

114 

115 - `"failed"`

116 

117### Example

118 

119```cli

120openai videos edit \

121 --api-key 'My API Key' \

122 --prompt x \

123 --video 'Example data'

124```

125 

126#### Response

127 

128```json

129{

130 "id": "id",

131 "completed_at": 0,

132 "created_at": 0,

133 "error": {

134 "code": "code",

135 "message": "message"

136 },

137 "expires_at": 0,

138 "model": "sora-2",

139 "object": "video",

140 "progress": 0,

141 "prompt": "prompt",

142 "remixed_from_video_id": "remixed_from_video_id",

143 "seconds": "4",

144 "size": "720x1280",

145 "status": "queued"

146}

147```

Details

1## Create an extension of a completed video.

2 

3`$ openai videos extend`

4 

5**post** `/videos/extensions`

6 

7Create an extension of a completed video.

8 

9### Parameters

10 

11- `--prompt: string`

12 

13 Updated text prompt that directs the extension generation.

14 

15- `--seconds: "4" or "8" or "12"`

16 

17 Length of the newly generated extension segment in seconds (allowed values: 4, 8, 12, 16, 20).

18 

19- `--video: string or object { id }`

20 

21 Reference to the completed video to extend.

22 

23### Returns

24 

25- `video: object { id, completed_at, created_at, 10 more }`

26 

27 Structured information describing a generated video job.

28 

29 - `id: string`

30 

31 Unique identifier for the video job.

32 

33 - `completed_at: number`

34 

35 Unix timestamp (seconds) for when the job completed, if finished.

36 

37 - `created_at: number`

38 

39 Unix timestamp (seconds) for when the job was created.

40 

41 - `error: object { code, message }`

42 

43 Error payload that explains why generation failed, if applicable.

44 

45 - `code: string`

46 

47 A machine-readable error code that was returned.

48 

49 - `message: string`

50 

51 A human-readable description of the error that was returned.

52 

53 - `expires_at: number`

54 

55 Unix timestamp (seconds) for when the downloadable assets expire, if set.

56 

57 - `model: string or "sora-2" or "sora-2-pro" or "sora-2-2025-10-06" or 2 more`

58 

59 The video generation model that produced the job.

60 

61 - `"sora-2"`

62 

63 - `"sora-2-pro"`

64 

65 - `"sora-2-2025-10-06"`

66 

67 - `"sora-2-pro-2025-10-06"`

68 

69 - `"sora-2-2025-12-08"`

70 

71 - `object: "video"`

72 

73 The object type, which is always `video`.

74 

75 - `progress: number`

76 

77 Approximate completion percentage for the generation task.

78 

79 - `prompt: string`

80 

81 The prompt that was used to generate the video.

82 

83 - `remixed_from_video_id: string`

84 

85 Identifier of the source video if this video is a remix.

86 

87 - `seconds: string or VideoSeconds`

88 

89 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

90 

91 - `"4"`

92 

93 - `"8"`

94 

95 - `"12"`

96 

97 - `size: "720x1280" or "1280x720" or "1024x1792" or "1792x1024"`

98 

99 The resolution of the generated video.

100 

101 - `"720x1280"`

102 

103 - `"1280x720"`

104 

105 - `"1024x1792"`

106 

107 - `"1792x1024"`

108 

109 - `status: "queued" or "in_progress" or "completed" or "failed"`

110 

111 Current lifecycle status of the video job.

112 

113 - `"queued"`

114 

115 - `"in_progress"`

116 

117 - `"completed"`

118 

119 - `"failed"`

120 

121### Example

122 

123```cli

124openai videos extend \

125 --api-key 'My API Key' \

126 --prompt x \

127 --seconds 4 \

128 --video 'Example data'

129```

130 

131#### Response

132 

133```json

134{

135 "id": "id",

136 "completed_at": 0,

137 "created_at": 0,

138 "error": {

139 "code": "code",

140 "message": "message"

141 },

142 "expires_at": 0,

143 "model": "sora-2",

144 "object": "video",

145 "progress": 0,

146 "prompt": "prompt",

147 "remixed_from_video_id": "remixed_from_video_id",

148 "seconds": "4",

149 "size": "720x1280",

150 "status": "queued"

151}

152```

Details

1## List videos

2 

3`$ openai videos list`

4 

5**get** `/videos`

6 

7List recently generated videos for the current project.

8 

9### Parameters

10 

11- `--after: optional string`

12 

13 Identifier for the last item from the previous pagination request

14 

15- `--limit: optional number`

16 

17 Number of items to retrieve

18 

19- `--order: optional "asc" or "desc"`

20 

21 Sort order of results by timestamp. Use `asc` for ascending order or `desc` for descending order.

22 

23### Returns

24 

25- `VideoListResource: object { data, first_id, has_more, 2 more }`

26 

27 - `data: array of Video`

28 

29 A list of items

30 

31 - `id: string`

32 

33 Unique identifier for the video job.

34 

35 - `completed_at: number`

36 

37 Unix timestamp (seconds) for when the job completed, if finished.

38 

39 - `created_at: number`

40 

41 Unix timestamp (seconds) for when the job was created.

42 

43 - `error: object { code, message }`

44 

45 Error payload that explains why generation failed, if applicable.

46 

47 - `code: string`

48 

49 A machine-readable error code that was returned.

50 

51 - `message: string`

52 

53 A human-readable description of the error that was returned.

54 

55 - `expires_at: number`

56 

57 Unix timestamp (seconds) for when the downloadable assets expire, if set.

58 

59 - `model: string or "sora-2" or "sora-2-pro" or "sora-2-2025-10-06" or 2 more`

60 

61 The video generation model that produced the job.

62 

63 - `"sora-2"`

64 

65 - `"sora-2-pro"`

66 

67 - `"sora-2-2025-10-06"`

68 

69 - `"sora-2-pro-2025-10-06"`

70 

71 - `"sora-2-2025-12-08"`

72 

73 - `object: "video"`

74 

75 The object type, which is always `video`.

76 

77 - `progress: number`

78 

79 Approximate completion percentage for the generation task.

80 

81 - `prompt: string`

82 

83 The prompt that was used to generate the video.

84 

85 - `remixed_from_video_id: string`

86 

87 Identifier of the source video if this video is a remix.

88 

89 - `seconds: string or VideoSeconds`

90 

91 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

92 

93 - `"4"`

94 

95 - `"8"`

96 

97 - `"12"`

98 

99 - `size: "720x1280" or "1280x720" or "1024x1792" or "1792x1024"`

100 

101 The resolution of the generated video.

102 

103 - `"720x1280"`

104 

105 - `"1280x720"`

106 

107 - `"1024x1792"`

108 

109 - `"1792x1024"`

110 

111 - `status: "queued" or "in_progress" or "completed" or "failed"`

112 

113 Current lifecycle status of the video job.

114 

115 - `"queued"`

116 

117 - `"in_progress"`

118 

119 - `"completed"`

120 

121 - `"failed"`

122 

123 - `first_id: string`

124 

125 The ID of the first item in the list.

126 

127 - `has_more: boolean`

128 

129 Whether there are more items available.

130 

131 - `last_id: string`

132 

133 The ID of the last item in the list.

134 

135 - `object: "list"`

136 

137 The type of object returned, must be `list`.

138 

139### Example

140 

141```cli

142openai videos list \

143 --api-key 'My API Key'

144```

145 

146#### Response

147 

148```json

149{

150 "data": [

151 {

152 "id": "id",

153 "completed_at": 0,

154 "created_at": 0,

155 "error": {

156 "code": "code",

157 "message": "message"

158 },

159 "expires_at": 0,

160 "model": "sora-2",

161 "object": "video",

162 "progress": 0,

163 "prompt": "prompt",

164 "remixed_from_video_id": "remixed_from_video_id",

165 "seconds": "4",

166 "size": "720x1280",

167 "status": "queued"

168 }

169 ],

170 "first_id": "first_id",

171 "has_more": true,

172 "last_id": "last_id",

173 "object": "list"

174}

175```

Details

1## Remix video

2 

3`$ openai videos remix`

4 

5**post** `/videos/{video_id}/remix`

6 

7Create a remix of a completed video using a refreshed prompt.

8 

9### Parameters

10 

11- `--video-id: string`

12 

13 The identifier of the completed video to remix.

14 

15- `--prompt: string`

16 

17 Updated text prompt that directs the remix generation.

18 

19### Returns

20 

21- `video: object { id, completed_at, created_at, 10 more }`

22 

23 Structured information describing a generated video job.

24 

25 - `id: string`

26 

27 Unique identifier for the video job.

28 

29 - `completed_at: number`

30 

31 Unix timestamp (seconds) for when the job completed, if finished.

32 

33 - `created_at: number`

34 

35 Unix timestamp (seconds) for when the job was created.

36 

37 - `error: object { code, message }`

38 

39 Error payload that explains why generation failed, if applicable.

40 

41 - `code: string`

42 

43 A machine-readable error code that was returned.

44 

45 - `message: string`

46 

47 A human-readable description of the error that was returned.

48 

49 - `expires_at: number`

50 

51 Unix timestamp (seconds) for when the downloadable assets expire, if set.

52 

53 - `model: string or "sora-2" or "sora-2-pro" or "sora-2-2025-10-06" or 2 more`

54 

55 The video generation model that produced the job.

56 

57 - `"sora-2"`

58 

59 - `"sora-2-pro"`

60 

61 - `"sora-2-2025-10-06"`

62 

63 - `"sora-2-pro-2025-10-06"`

64 

65 - `"sora-2-2025-12-08"`

66 

67 - `object: "video"`

68 

69 The object type, which is always `video`.

70 

71 - `progress: number`

72 

73 Approximate completion percentage for the generation task.

74 

75 - `prompt: string`

76 

77 The prompt that was used to generate the video.

78 

79 - `remixed_from_video_id: string`

80 

81 Identifier of the source video if this video is a remix.

82 

83 - `seconds: string or VideoSeconds`

84 

85 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

86 

87 - `"4"`

88 

89 - `"8"`

90 

91 - `"12"`

92 

93 - `size: "720x1280" or "1280x720" or "1024x1792" or "1792x1024"`

94 

95 The resolution of the generated video.

96 

97 - `"720x1280"`

98 

99 - `"1280x720"`

100 

101 - `"1024x1792"`

102 

103 - `"1792x1024"`

104 

105 - `status: "queued" or "in_progress" or "completed" or "failed"`

106 

107 Current lifecycle status of the video job.

108 

109 - `"queued"`

110 

111 - `"in_progress"`

112 

113 - `"completed"`

114 

115 - `"failed"`

116 

117### Example

118 

119```cli

120openai videos remix \

121 --api-key 'My API Key' \

122 --video-id video_123 \

123 --prompt x

124```

125 

126#### Response

127 

128```json

129{

130 "id": "id",

131 "completed_at": 0,

132 "created_at": 0,

133 "error": {

134 "code": "code",

135 "message": "message"

136 },

137 "expires_at": 0,

138 "model": "sora-2",

139 "object": "video",

140 "progress": 0,

141 "prompt": "prompt",

142 "remixed_from_video_id": "remixed_from_video_id",

143 "seconds": "4",

144 "size": "720x1280",

145 "status": "queued"

146}

147```

Details

1## Retrieve video

2 

3`$ openai videos retrieve`

4 

5**get** `/videos/{video_id}`

6 

7Fetch the latest metadata for a generated video.

8 

9### Parameters

10 

11- `--video-id: string`

12 

13 The identifier of the video to retrieve.

14 

15### Returns

16 

17- `video: object { id, completed_at, created_at, 10 more }`

18 

19 Structured information describing a generated video job.

20 

21 - `id: string`

22 

23 Unique identifier for the video job.

24 

25 - `completed_at: number`

26 

27 Unix timestamp (seconds) for when the job completed, if finished.

28 

29 - `created_at: number`

30 

31 Unix timestamp (seconds) for when the job was created.

32 

33 - `error: object { code, message }`

34 

35 Error payload that explains why generation failed, if applicable.

36 

37 - `code: string`

38 

39 A machine-readable error code that was returned.

40 

41 - `message: string`

42 

43 A human-readable description of the error that was returned.

44 

45 - `expires_at: number`

46 

47 Unix timestamp (seconds) for when the downloadable assets expire, if set.

48 

49 - `model: string or "sora-2" or "sora-2-pro" or "sora-2-2025-10-06" or 2 more`

50 

51 The video generation model that produced the job.

52 

53 - `"sora-2"`

54 

55 - `"sora-2-pro"`

56 

57 - `"sora-2-2025-10-06"`

58 

59 - `"sora-2-pro-2025-10-06"`

60 

61 - `"sora-2-2025-12-08"`

62 

63 - `object: "video"`

64 

65 The object type, which is always `video`.

66 

67 - `progress: number`

68 

69 Approximate completion percentage for the generation task.

70 

71 - `prompt: string`

72 

73 The prompt that was used to generate the video.

74 

75 - `remixed_from_video_id: string`

76 

77 Identifier of the source video if this video is a remix.

78 

79 - `seconds: string or VideoSeconds`

80 

81 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

82 

83 - `"4"`

84 

85 - `"8"`

86 

87 - `"12"`

88 

89 - `size: "720x1280" or "1280x720" or "1024x1792" or "1792x1024"`

90 

91 The resolution of the generated video.

92 

93 - `"720x1280"`

94 

95 - `"1280x720"`

96 

97 - `"1024x1792"`

98 

99 - `"1792x1024"`

100 

101 - `status: "queued" or "in_progress" or "completed" or "failed"`

102 

103 Current lifecycle status of the video job.

104 

105 - `"queued"`

106 

107 - `"in_progress"`

108 

109 - `"completed"`

110 

111 - `"failed"`

112 

113### Example

114 

115```cli

116openai videos retrieve \

117 --api-key 'My API Key' \

118 --video-id video_123

119```

120 

121#### Response

122 

123```json

124{

125 "id": "id",

126 "completed_at": 0,

127 "created_at": 0,

128 "error": {

129 "code": "code",

130 "message": "message"

131 },

132 "expires_at": 0,

133 "model": "sora-2",

134 "object": "video",

135 "progress": 0,

136 "prompt": "prompt",

137 "remixed_from_video_id": "remixed_from_video_id",

138 "seconds": "4",

139 "size": "720x1280",

140 "status": "queued"

141}

142```

Details

1## Create speech

2 

3`client.Audio.Speech.New(ctx, body) (*Response, error)`

4 

5**post** `/audio/speech`

6 

7Generates audio from the input text.

8 

9Returns the audio file content, or a stream of audio events.

10 

11### Parameters

12 

13- `body AudioSpeechNewParams`

14 

15 - `Input param.Field[string]`

16 

17 The text to generate audio for. The maximum length is 4096 characters.

18 

19 - `Model param.Field[SpeechModel]`

20 

21 One of the available [TTS models](https://platform.openai.com/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.

22 

23 - `string`

24 

25 - `type SpeechModel string`

26 

27 - `const SpeechModelTTS1 SpeechModel = "tts-1"`

28 

29 - `const SpeechModelTTS1HD SpeechModel = "tts-1-hd"`

30 

31 - `const SpeechModelGPT4oMiniTTS SpeechModel = "gpt-4o-mini-tts"`

32 

33 - `const SpeechModelGPT4oMiniTTS2025_12_15 SpeechModel = "gpt-4o-mini-tts-2025-12-15"`

34 

35 - `Voice param.Field[AudioSpeechNewParamsVoiceUnion]`

36 

37 The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ "id": "voice_1234" }`. Previews of the voices are available in the [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).

38 

39 - `string`

40 

41 - `type AudioSpeechNewParamsVoiceString2 string`

42 

43 - `const AudioSpeechNewParamsVoiceString2Alloy AudioSpeechNewParamsVoiceString2 = "alloy"`

44 

45 - `const AudioSpeechNewParamsVoiceString2Ash AudioSpeechNewParamsVoiceString2 = "ash"`

46 

47 - `const AudioSpeechNewParamsVoiceString2Ballad AudioSpeechNewParamsVoiceString2 = "ballad"`

48 

49 - `const AudioSpeechNewParamsVoiceString2Coral AudioSpeechNewParamsVoiceString2 = "coral"`

50 

51 - `const AudioSpeechNewParamsVoiceString2Echo AudioSpeechNewParamsVoiceString2 = "echo"`

52 

53 - `const AudioSpeechNewParamsVoiceString2Sage AudioSpeechNewParamsVoiceString2 = "sage"`

54 

55 - `const AudioSpeechNewParamsVoiceString2Shimmer AudioSpeechNewParamsVoiceString2 = "shimmer"`

56 

57 - `const AudioSpeechNewParamsVoiceString2Verse AudioSpeechNewParamsVoiceString2 = "verse"`

58 

59 - `const AudioSpeechNewParamsVoiceString2Marin AudioSpeechNewParamsVoiceString2 = "marin"`

60 

61 - `const AudioSpeechNewParamsVoiceString2Cedar AudioSpeechNewParamsVoiceString2 = "cedar"`

62 

63 - `type AudioSpeechNewParamsVoiceID struct{…}`

64 

65 Custom voice reference.

66 

67 - `ID string`

68 

69 The custom voice ID, e.g. `voice_1234`.

70 

71 - `Instructions param.Field[string]`

72 

73 Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.

74 

75 - `ResponseFormat param.Field[AudioSpeechNewParamsResponseFormat]`

76 

77 The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.

78 

79 - `const AudioSpeechNewParamsResponseFormatMP3 AudioSpeechNewParamsResponseFormat = "mp3"`

80 

81 - `const AudioSpeechNewParamsResponseFormatOpus AudioSpeechNewParamsResponseFormat = "opus"`

82 

83 - `const AudioSpeechNewParamsResponseFormatAAC AudioSpeechNewParamsResponseFormat = "aac"`

84 

85 - `const AudioSpeechNewParamsResponseFormatFLAC AudioSpeechNewParamsResponseFormat = "flac"`

86 

87 - `const AudioSpeechNewParamsResponseFormatWAV AudioSpeechNewParamsResponseFormat = "wav"`

88 

89 - `const AudioSpeechNewParamsResponseFormatPCM AudioSpeechNewParamsResponseFormat = "pcm"`

90 

91 - `Speed param.Field[float64]`

92 

93 The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.

94 

95 - `StreamFormat param.Field[AudioSpeechNewParamsStreamFormat]`

96 

97 The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.

98 

99 - `const AudioSpeechNewParamsStreamFormatSSE AudioSpeechNewParamsStreamFormat = "sse"`

100 

101 - `const AudioSpeechNewParamsStreamFormatAudio AudioSpeechNewParamsStreamFormat = "audio"`

102 

103### Returns

104 

105- `type AudioSpeechNewResponse interface{…}`

106 

107### Example

108 

109```go

110package main

111 

112import (

113 "context"

114 "fmt"

115 

116 "github.com/openai/openai-go"

117 "github.com/openai/openai-go/option"

118)

119 

120func main() {

121 client := openai.NewClient(

122 option.WithAPIKey("My API Key"),

123 )

124 speech, err := client.Audio.Speech.New(context.TODO(), openai.AudioSpeechNewParams{

125 Input: "input",

126 Model: openai.SpeechModelTTS1,

127 Voice: openai.AudioSpeechNewParamsVoiceUnion{

128 OfAudioSpeechNewsVoiceString2: openai.String("alloy"),

129 },

130 })

131 if err != nil {

132 panic(err.Error())

133 }

134 fmt.Printf("%+v\n", speech)

135}

136```

Details

1## Create client secret

2 

3`client.Realtime.ClientSecrets.New(ctx, body) (*ClientSecretNewResponse, error)`

4 

5**post** `/realtime/client_secrets`

6 

7Create a Realtime client secret with an associated session configuration.

8 

9Client secrets are short-lived tokens that can be passed to a client app,

10such as a web frontend or mobile client, which grants access to the Realtime API without

11leaking your main API key. You can configure a custom TTL for each client secret.

12 

13You can also attach session configuration options to the client secret, which will be

14applied to any sessions created using that client secret, but these can also be overridden

15by the client connection.

16 

17[Learn more about authentication with client secrets over WebRTC](https://platform.openai.com/docs/guides/realtime-webrtc).

18 

19Returns the created client secret and the effective session object. The client secret is a string that looks like `ek_1234`.

20 

21### Parameters

22 

23- `body ClientSecretNewParams`

24 

25 - `ExpiresAfter param.Field[ClientSecretNewParamsExpiresAfter]`

26 

27 Configuration for the client secret expiration. Expiration refers to the time after which

28 a client secret will no longer be valid for creating sessions. The session itself may

29 continue after that time once started. A secret can be used to create multiple sessions

30 until it expires.

31 

32 - `Anchor string`

33 

34 The anchor point for the client secret expiration, meaning that `seconds` will be added to the `created_at` time of the client secret to produce an expiration timestamp. Only `created_at` is currently supported.

35 

36 - `const ClientSecretNewParamsExpiresAfterAnchorCreatedAt ClientSecretNewParamsExpiresAfterAnchor = "created_at"`

37 

38 - `Seconds int64`

39 

40 The number of seconds from the anchor point to the expiration. Select a value between `10` and `7200` (2 hours). This default to 600 seconds (10 minutes) if not specified.

41 

42 - `Session param.Field[ClientSecretNewParamsSessionUnion]`

43 

44 Session configuration to use for the client secret. Choose either a realtime

45 session or a transcription session.

46 

47 - `type RealtimeSessionCreateRequest struct{…}`

48 

49 Realtime session object configuration.

50 

51 - `Type Realtime`

52 

53 The type of session to create. Always `realtime` for the Realtime API.

54 

55 - `const RealtimeRealtime Realtime = "realtime"`

56 

57 - `Audio RealtimeAudioConfig`

58 

59 Configuration for input and output audio.

60 

61 - `Input RealtimeAudioConfigInput`

62 

63 - `Format RealtimeAudioFormatsUnion`

64 

65 The format of the input audio.

66 

67 - `type RealtimeAudioFormatsAudioPCM struct{…}`

68 

69 The PCM audio format. Only a 24kHz sample rate is supported.

70 

71 - `Rate int64`

72 

73 The sample rate of the audio. Always `24000`.

74 

75 - `const RealtimeAudioFormatsAudioPCMRate24000 RealtimeAudioFormatsAudioPCMRate = 24000`

76 

77 - `Type string`

78 

79 The audio format. Always `audio/pcm`.

80 

81 - `const RealtimeAudioFormatsAudioPCMTypeAudioPCM RealtimeAudioFormatsAudioPCMType = "audio/pcm"`

82 

83 - `type RealtimeAudioFormatsAudioPCMU struct{…}`

84 

85 The G.711 μ-law format.

86 

87 - `Type string`

88 

89 The audio format. Always `audio/pcmu`.

90 

91 - `const RealtimeAudioFormatsAudioPCMUTypeAudioPCMU RealtimeAudioFormatsAudioPCMUType = "audio/pcmu"`

92 

93 - `type RealtimeAudioFormatsAudioPCMA struct{…}`

94 

95 The G.711 A-law format.

96 

97 - `Type string`

98 

99 The audio format. Always `audio/pcma`.

100 

101 - `const RealtimeAudioFormatsAudioPCMATypeAudioPCMA RealtimeAudioFormatsAudioPCMAType = "audio/pcma"`

102 

103 - `NoiseReduction RealtimeAudioConfigInputNoiseReduction`

104 

105 Configuration for input audio noise reduction. This can be set to `null` to turn off.

106 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

107 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

108 

109 - `Type NoiseReductionType`

110 

111 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

112 

113 - `const NoiseReductionTypeNearField NoiseReductionType = "near_field"`

114 

115 - `const NoiseReductionTypeFarField NoiseReductionType = "far_field"`

116 

117 - `Transcription AudioTranscription`

118 

119 Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.

120 

121 - `Delay AudioTranscriptionDelay`

122 

123 Controls how long the model waits before emitting transcription text.

124 Higher values can improve transcription accuracy at the cost of latency.

125 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

126 

127 - `const AudioTranscriptionDelayMinimal AudioTranscriptionDelay = "minimal"`

128 

129 - `const AudioTranscriptionDelayLow AudioTranscriptionDelay = "low"`

130 

131 - `const AudioTranscriptionDelayMedium AudioTranscriptionDelay = "medium"`

132 

133 - `const AudioTranscriptionDelayHigh AudioTranscriptionDelay = "high"`

134 

135 - `const AudioTranscriptionDelayXhigh AudioTranscriptionDelay = "xhigh"`

136 

137 - `Language string`

138 

139 The language of the input audio. Supplying the input language in

140 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

141 will improve accuracy and latency.

142 

143 - `Model AudioTranscriptionModel`

144 

145 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

146 

147 - `string`

148 

149 - `type AudioTranscriptionModel string`

150 

151 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

152 

153 - `const AudioTranscriptionModelWhisper1 AudioTranscriptionModel = "whisper-1"`

154 

155 - `const AudioTranscriptionModelGPT4oMiniTranscribe AudioTranscriptionModel = "gpt-4o-mini-transcribe"`

156 

157 - `const AudioTranscriptionModelGPT4oMiniTranscribe2025_12_15 AudioTranscriptionModel = "gpt-4o-mini-transcribe-2025-12-15"`

158 

159 - `const AudioTranscriptionModelGPT4oTranscribe AudioTranscriptionModel = "gpt-4o-transcribe"`

160 

161 - `const AudioTranscriptionModelGPT4oTranscribeDiarize AudioTranscriptionModel = "gpt-4o-transcribe-diarize"`

162 

163 - `const AudioTranscriptionModelGPTRealtimeWhisper AudioTranscriptionModel = "gpt-realtime-whisper"`

164 

165 - `Prompt string`

166 

167 An optional text to guide the model's style or continue a previous audio

168 segment.

169 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).

170 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

171 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

172 

173 - `TurnDetection RealtimeAudioInputTurnDetectionUnion`

174 

175 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

176 

177 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

178 

179 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

180 

181 For `gpt-realtime-whisper` transcription sessions, turn detection must be

182 set to `null`; VAD is not supported.

183 

184 - `RealtimeAudioInputTurnDetectionServerVad`

185 

186 - `Type ServerVad`

187 

188 Type of turn detection, `server_vad` to turn on simple Server VAD.

189 

190 - `const ServerVadServerVad ServerVad = "server_vad"`

191 

192 - `CreateResponse bool`

193 

194 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

195 

196 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

197 

198 - `IdleTimeoutMs int64`

199 

200 Optional timeout after which a model response will be triggered automatically. This is

201 useful for situations in which a long pause from the user is unexpected, such as a phone

202 call. The model will effectively prompt the user to continue the conversation based

203 on the current context.

204 

205 The timeout value will be applied after the last model response's audio has finished playing,

206 i.e. it's set to the `response.done` time plus audio playback duration.

207 

208 An `input_audio_buffer.timeout_triggered` event (plus events

209 associated with the Response) will be emitted when the timeout is reached.

210 Idle timeout is currently only supported for `server_vad` mode.

211 

212 - `InterruptResponse bool`

213 

214 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

215 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

216 

217 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

218 

219 - `PrefixPaddingMs int64`

220 

221 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

222 milliseconds). Defaults to 300ms.

223 

224 - `SilenceDurationMs int64`

225 

226 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

227 to 500ms. With shorter values the model will respond more quickly,

228 but may jump in on short pauses from the user.

229 

230 - `Threshold float64`

231 

232 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

233 higher threshold will require louder audio to activate the model, and

234 thus might perform better in noisy environments.

235 

236 - `RealtimeAudioInputTurnDetectionSemanticVad`

237 

238 - `Type SemanticVad`

239 

240 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

241 

242 - `const SemanticVadSemanticVad SemanticVad = "semantic_vad"`

243 

244 - `CreateResponse bool`

245 

246 Whether or not to automatically generate a response when a VAD stop event occurs.

247 

248 - `Eagerness string`

249 

250 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

251 

252 - `const RealtimeAudioInputTurnDetectionSemanticVadEagernessLow RealtimeAudioInputTurnDetectionSemanticVadEagerness = "low"`

253 

254 - `const RealtimeAudioInputTurnDetectionSemanticVadEagernessMedium RealtimeAudioInputTurnDetectionSemanticVadEagerness = "medium"`

255 

256 - `const RealtimeAudioInputTurnDetectionSemanticVadEagernessHigh RealtimeAudioInputTurnDetectionSemanticVadEagerness = "high"`

257 

258 - `const RealtimeAudioInputTurnDetectionSemanticVadEagernessAuto RealtimeAudioInputTurnDetectionSemanticVadEagerness = "auto"`

259 

260 - `InterruptResponse bool`

261 

262 Whether or not to automatically interrupt any ongoing response with output to the default

263 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

264 

265 - `Output RealtimeAudioConfigOutput`

266 

267 - `Format RealtimeAudioFormatsUnion`

268 

269 The format of the output audio.

270 

271 - `Speed float64`

272 

273 The speed of the model's spoken response as a multiple of the original speed.

274 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.

275 

276 This parameter is a post-processing adjustment to the audio after it is generated, it's

277 also possible to prompt the model to speak faster or slower.

278 

279 - `Voice RealtimeAudioConfigOutputVoiceUnion`

280 

281 The voice the model uses to respond. Supported built-in voices are

282 `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,

283 `marin`, and `cedar`. You may also provide a custom voice object with

284 an `id`, for example `{ "id": "voice_1234" }`. Voice cannot be changed

285 during the session once the model has responded with audio at least once.

286 We recommend `marin` and `cedar` for best quality.

287 

288 - `string`

289 

290 - `string`

291 

292 - `const RealtimeAudioConfigOutputVoiceString2Alloy RealtimeAudioConfigOutputVoiceString2 = "alloy"`

293 

294 - `const RealtimeAudioConfigOutputVoiceString2Ash RealtimeAudioConfigOutputVoiceString2 = "ash"`

295 

296 - `const RealtimeAudioConfigOutputVoiceString2Ballad RealtimeAudioConfigOutputVoiceString2 = "ballad"`

297 

298 - `const RealtimeAudioConfigOutputVoiceString2Coral RealtimeAudioConfigOutputVoiceString2 = "coral"`

299 

300 - `const RealtimeAudioConfigOutputVoiceString2Echo RealtimeAudioConfigOutputVoiceString2 = "echo"`

301 

302 - `const RealtimeAudioConfigOutputVoiceString2Sage RealtimeAudioConfigOutputVoiceString2 = "sage"`

303 

304 - `const RealtimeAudioConfigOutputVoiceString2Shimmer RealtimeAudioConfigOutputVoiceString2 = "shimmer"`

305 

306 - `const RealtimeAudioConfigOutputVoiceString2Verse RealtimeAudioConfigOutputVoiceString2 = "verse"`

307 

308 - `const RealtimeAudioConfigOutputVoiceString2Marin RealtimeAudioConfigOutputVoiceString2 = "marin"`

309 

310 - `const RealtimeAudioConfigOutputVoiceString2Cedar RealtimeAudioConfigOutputVoiceString2 = "cedar"`

311 

312 - `RealtimeAudioConfigOutputVoiceID`

313 

314 - `ID string`

315 

316 The custom voice ID, e.g. `voice_1234`.

317 

318 - `Include []string`

319 

320 Additional fields to include in server outputs.

321 

322 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

323 

324 - `const RealtimeSessionCreateRequestIncludeItemInputAudioTranscriptionLogprobs RealtimeSessionCreateRequestInclude = "item.input_audio_transcription.logprobs"`

325 

326 - `Instructions string`

327 

328 The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.

329 

330 Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.

331 

332 - `MaxOutputTokens RealtimeSessionCreateRequestMaxOutputTokensUnion`

333 

334 Maximum number of output tokens for a single assistant response,

335 inclusive of tool calls. Provide an integer between 1 and 4096 to

336 limit output tokens, or `inf` for the maximum available tokens for a

337 given model. Defaults to `inf`.

338 

339 - `int64`

340 

341 - `Inf`

342 

343 - `const InfInf Inf = "inf"`

344 

345 - `Model RealtimeSessionCreateRequestModel`

346 

347 The Realtime model used for this session.

348 

349 - `string`

350 

351 - `RealtimeSessionCreateRequestModel`

352 

353 - `const RealtimeSessionCreateRequestModelGPTRealtime RealtimeSessionCreateRequestModel = "gpt-realtime"`

354 

355 - `const RealtimeSessionCreateRequestModelGPTRealtime1_5 RealtimeSessionCreateRequestModel = "gpt-realtime-1.5"`

356 

357 - `const RealtimeSessionCreateRequestModelGPTRealtime2 RealtimeSessionCreateRequestModel = "gpt-realtime-2"`

358 

359 - `const RealtimeSessionCreateRequestModelGPTRealtime2025_08_28 RealtimeSessionCreateRequestModel = "gpt-realtime-2025-08-28"`

360 

361 - `const RealtimeSessionCreateRequestModelGPT4oRealtimePreview RealtimeSessionCreateRequestModel = "gpt-4o-realtime-preview"`

362 

363 - `const RealtimeSessionCreateRequestModelGPT4oRealtimePreview2024_10_01 RealtimeSessionCreateRequestModel = "gpt-4o-realtime-preview-2024-10-01"`

364 

365 - `const RealtimeSessionCreateRequestModelGPT4oRealtimePreview2024_12_17 RealtimeSessionCreateRequestModel = "gpt-4o-realtime-preview-2024-12-17"`

366 

367 - `const RealtimeSessionCreateRequestModelGPT4oRealtimePreview2025_06_03 RealtimeSessionCreateRequestModel = "gpt-4o-realtime-preview-2025-06-03"`

368 

369 - `const RealtimeSessionCreateRequestModelGPT4oMiniRealtimePreview RealtimeSessionCreateRequestModel = "gpt-4o-mini-realtime-preview"`

370 

371 - `const RealtimeSessionCreateRequestModelGPT4oMiniRealtimePreview2024_12_17 RealtimeSessionCreateRequestModel = "gpt-4o-mini-realtime-preview-2024-12-17"`

372 

373 - `const RealtimeSessionCreateRequestModelGPTRealtimeMini RealtimeSessionCreateRequestModel = "gpt-realtime-mini"`

374 

375 - `const RealtimeSessionCreateRequestModelGPTRealtimeMini2025_10_06 RealtimeSessionCreateRequestModel = "gpt-realtime-mini-2025-10-06"`

376 

377 - `const RealtimeSessionCreateRequestModelGPTRealtimeMini2025_12_15 RealtimeSessionCreateRequestModel = "gpt-realtime-mini-2025-12-15"`

378 

379 - `const RealtimeSessionCreateRequestModelGPTAudio1_5 RealtimeSessionCreateRequestModel = "gpt-audio-1.5"`

380 

381 - `const RealtimeSessionCreateRequestModelGPTAudioMini RealtimeSessionCreateRequestModel = "gpt-audio-mini"`

382 

383 - `const RealtimeSessionCreateRequestModelGPTAudioMini2025_10_06 RealtimeSessionCreateRequestModel = "gpt-audio-mini-2025-10-06"`

384 

385 - `const RealtimeSessionCreateRequestModelGPTAudioMini2025_12_15 RealtimeSessionCreateRequestModel = "gpt-audio-mini-2025-12-15"`

386 

387 - `OutputModalities []string`

388 

389 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating

390 that the model will respond with audio plus a transcript. `["text"]` can be used to make

391 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.

392 

393 - `const RealtimeSessionCreateRequestOutputModalityText RealtimeSessionCreateRequestOutputModality = "text"`

394 

395 - `const RealtimeSessionCreateRequestOutputModalityAudio RealtimeSessionCreateRequestOutputModality = "audio"`

396 

397 - `ParallelToolCalls bool`

398 

399 Whether the model may call multiple tools in parallel. Only supported by

400 reasoning Realtime models such as `gpt-realtime-2`.

401 

402 - `Prompt ResponsePrompt`

403 

404 Reference to a prompt template and its variables.

405 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).

406 

407 - `ID string`

408 

409 The unique identifier of the prompt template to use.

410 

411 - `Variables map[string, ResponsePromptVariableUnion]`

412 

413 Optional map of values to substitute in for variables in your

414 prompt. The substitution values can either be strings, or other

415 Response input types like images or files.

416 

417 - `string`

418 

419 - `type ResponseInputText struct{…}`

420 

421 A text input to the model.

422 

423 - `Text string`

424 

425 The text input to the model.

426 

427 - `Type InputText`

428 

429 The type of the input item. Always `input_text`.

430 

431 - `const InputTextInputText InputText = "input_text"`

432 

433 - `type ResponseInputImage struct{…}`

434 

435 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).

436 

437 - `Detail ResponseInputImageDetail`

438 

439 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.

440 

441 - `const ResponseInputImageDetailLow ResponseInputImageDetail = "low"`

442 

443 - `const ResponseInputImageDetailHigh ResponseInputImageDetail = "high"`

444 

445 - `const ResponseInputImageDetailAuto ResponseInputImageDetail = "auto"`

446 

447 - `const ResponseInputImageDetailOriginal ResponseInputImageDetail = "original"`

448 

449 - `Type InputImage`

450 

451 The type of the input item. Always `input_image`.

452 

453 - `const InputImageInputImage InputImage = "input_image"`

454 

455 - `FileID string`

456 

457 The ID of the file to be sent to the model.

458 

459 - `ImageURL string`

460 

461 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.

462 

463 - `type ResponseInputFile struct{…}`

464 

465 A file input to the model.

466 

467 - `Type InputFile`

468 

469 The type of the input item. Always `input_file`.

470 

471 - `const InputFileInputFile InputFile = "input_file"`

472 

473 - `Detail ResponseInputFileDetail`

474 

475 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.

476 

477 - `const ResponseInputFileDetailLow ResponseInputFileDetail = "low"`

478 

479 - `const ResponseInputFileDetailHigh ResponseInputFileDetail = "high"`

480 

481 - `FileData string`

482 

483 The content of the file to be sent to the model.

484 

485 - `FileID string`

486 

487 The ID of the file to be sent to the model.

488 

489 - `FileURL string`

490 

491 The URL of the file to be sent to the model.

492 

493 - `Filename string`

494 

495 The name of the file to be sent to the model.

496 

497 - `Version string`

498 

499 Optional version of the prompt template.

500 

501 - `Reasoning RealtimeReasoning`

502 

503 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.

504 

505 - `Effort RealtimeReasoningEffort`

506 

507 Constrains effort on reasoning for reasoning-capable Realtime models such as

508 `gpt-realtime-2`.

509 

510 - `const RealtimeReasoningEffortMinimal RealtimeReasoningEffort = "minimal"`

511 

512 - `const RealtimeReasoningEffortLow RealtimeReasoningEffort = "low"`

513 

514 - `const RealtimeReasoningEffortMedium RealtimeReasoningEffort = "medium"`

515 

516 - `const RealtimeReasoningEffortHigh RealtimeReasoningEffort = "high"`

517 

518 - `const RealtimeReasoningEffortXhigh RealtimeReasoningEffort = "xhigh"`

519 

520 - `ToolChoice RealtimeToolChoiceConfigUnion`

521 

522 How the model chooses tools. Provide one of the string modes or force a specific

523 function/MCP tool.

524 

525 - `type ToolChoiceOptions string`

526 

527 Controls which (if any) tool is called by the model.

528 

529 `none` means the model will not call any tool and instead generates a message.

530 

531 `auto` means the model can pick between generating a message or calling one or

532 more tools.

533 

534 `required` means the model must call one or more tools.

535 

536 - `const ToolChoiceOptionsNone ToolChoiceOptions = "none"`

537 

538 - `const ToolChoiceOptionsAuto ToolChoiceOptions = "auto"`

539 

540 - `const ToolChoiceOptionsRequired ToolChoiceOptions = "required"`

541 

542 - `type ToolChoiceFunction struct{…}`

543 

544 Use this option to force the model to call a specific function.

545 

546 - `Name string`

547 

548 The name of the function to call.

549 

550 - `Type Function`

551 

552 For function calling, the type is always `function`.

553 

554 - `const FunctionFunction Function = "function"`

555 

556 - `type ToolChoiceMcp struct{…}`

557 

558 Use this option to force the model to call a specific tool on a remote MCP server.

559 

560 - `ServerLabel string`

561 

562 The label of the MCP server to use.

563 

564 - `Type Mcp`

565 

566 For MCP tools, the type is always `mcp`.

567 

568 - `const McpMcp Mcp = "mcp"`

569 

570 - `Name string`

571 

572 The name of the tool to call on the server.

573 

574 - `Tools RealtimeToolsConfig`

575 

576 Tools available to the model.

577 

578 - `type RealtimeFunctionTool struct{…}`

579 

580 - `Description string`

581 

582 The description of the function, including guidance on when and how

583 to call it, and guidance about what to tell the user when calling

584 (if anything).

585 

586 - `Name string`

587 

588 The name of the function.

589 

590 - `Parameters any`

591 

592 Parameters of the function in JSON Schema.

593 

594 - `Type RealtimeFunctionToolType`

595 

596 The type of the tool, i.e. `function`.

597 

598 - `const RealtimeFunctionToolTypeFunction RealtimeFunctionToolType = "function"`

599 

600 - `RealtimeToolsConfigUnionMcp`

601 

602 - `ServerLabel string`

603 

604 A label for this MCP server, used to identify it in tool calls.

605 

606 - `Type Mcp`

607 

608 The type of the MCP tool. Always `mcp`.

609 

610 - `const McpMcp Mcp = "mcp"`

611 

612 - `AllowedTools RealtimeToolsConfigUnionMcpAllowedTools`

613 

614 List of allowed tool names or a filter object.

615 

616 - `[]string`

617 

618 - `RealtimeToolsConfigUnionMcpAllowedToolsMcpToolFilter`

619 

620 - `ReadOnly bool`

621 

622 Indicates whether or not a tool modifies data or is read-only. If an

623 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

624 it will match this filter.

625 

626 - `ToolNames []string`

627 

628 List of allowed tool names.

629 

630 - `Authorization string`

631 

632 An OAuth access token that can be used with a remote MCP server, either

633 with a custom MCP server URL or a service connector. Your application

634 must handle the OAuth authorization flow and provide the token here.

635 

636 - `ConnectorID string`

637 

638 Identifier for service connectors, like those available in ChatGPT. One of

639 `server_url` or `connector_id` must be provided. Learn more about service

640 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).

641 

642 Currently supported `connector_id` values are:

643 

644 - Dropbox: `connector_dropbox`

645 - Gmail: `connector_gmail`

646 - Google Calendar: `connector_googlecalendar`

647 - Google Drive: `connector_googledrive`

648 - Microsoft Teams: `connector_microsoftteams`

649 - Outlook Calendar: `connector_outlookcalendar`

650 - Outlook Email: `connector_outlookemail`

651 - SharePoint: `connector_sharepoint`

652 

653 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorDropbox RealtimeToolsConfigUnionMcpConnectorID = "connector_dropbox"`

654 

655 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorGmail RealtimeToolsConfigUnionMcpConnectorID = "connector_gmail"`

656 

657 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorGooglecalendar RealtimeToolsConfigUnionMcpConnectorID = "connector_googlecalendar"`

658 

659 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorGoogledrive RealtimeToolsConfigUnionMcpConnectorID = "connector_googledrive"`

660 

661 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorMicrosoftteams RealtimeToolsConfigUnionMcpConnectorID = "connector_microsoftteams"`

662 

663 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorOutlookcalendar RealtimeToolsConfigUnionMcpConnectorID = "connector_outlookcalendar"`

664 

665 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorOutlookemail RealtimeToolsConfigUnionMcpConnectorID = "connector_outlookemail"`

666 

667 - `const RealtimeToolsConfigUnionMcpConnectorIDConnectorSharepoint RealtimeToolsConfigUnionMcpConnectorID = "connector_sharepoint"`

668 

669 - `DeferLoading bool`

670 

671 Whether this MCP tool is deferred and discovered via tool search.

672 

673 - `Headers map[string, string]`

674 

675 Optional HTTP headers to send to the MCP server. Use for authentication

676 or other purposes.

677 

678 - `RequireApproval RealtimeToolsConfigUnionMcpRequireApproval`

679 

680 Specify which of the MCP server's tools require approval.

681 

682 - `RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalFilter`

683 

684 - `Always RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalFilterAlways`

685 

686 A filter object to specify which tools are allowed.

687 

688 - `ReadOnly bool`

689 

690 Indicates whether or not a tool modifies data or is read-only. If an

691 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

692 it will match this filter.

693 

694 - `ToolNames []string`

695 

696 List of allowed tool names.

697 

698 - `Never RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalFilterNever`

699 

700 A filter object to specify which tools are allowed.

701 

702 - `ReadOnly bool`

703 

704 Indicates whether or not a tool modifies data or is read-only. If an

705 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

706 it will match this filter.

707 

708 - `ToolNames []string`

709 

710 List of allowed tool names.

711 

712 - `string`

713 

714 - `const RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalSettingAlways RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalSetting = "always"`

715 

716 - `const RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalSettingNever RealtimeToolsConfigUnionMcpRequireApprovalMcpToolApprovalSetting = "never"`

717 

718 - `ServerDescription string`

719 

720 Optional description of the MCP server, used to provide more context.

721 

722 - `ServerURL string`

723 

724 The URL for the MCP server. One of `server_url` or `connector_id` must be

725 provided.

726 

727 - `Tracing RealtimeTracingConfigUnion`

728 

729 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once

730 tracing is enabled for a session, the configuration cannot be modified.

731 

732 `auto` will create a trace for the session with default values for the

733 workflow name, group id, and metadata.

734 

735 - `Auto`

736 

737 - `const AutoAuto Auto = "auto"`

738 

739 - `RealtimeTracingConfigTracingConfiguration`

740 

741 - `GroupID string`

742 

743 The group id to attach to this trace to enable filtering and

744 grouping in the Traces Dashboard.

745 

746 - `Metadata any`

747 

748 The arbitrary metadata to attach to this trace to enable

749 filtering in the Traces Dashboard.

750 

751 - `WorkflowName string`

752 

753 The name of the workflow to attach to this trace. This is used to

754 name the trace in the Traces Dashboard.

755 

756 - `Truncation RealtimeTruncationUnion`

757 

758 When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

759 

760 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

761 

762 Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

763 

764 Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.

765 

766 - `type RealtimeTruncationRealtimeTruncationStrategy string`

767 

768 The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit.

769 

770 - `const RealtimeTruncationRealtimeTruncationStrategyAuto RealtimeTruncationRealtimeTruncationStrategy = "auto"`

771 

772 - `const RealtimeTruncationRealtimeTruncationStrategyDisabled RealtimeTruncationRealtimeTruncationStrategy = "disabled"`

773 

774 - `type RealtimeTruncationRetentionRatio struct{…}`

775 

776 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

777 

778 - `RetentionRatio float64`

779 

780 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.

781 

782 - `Type RetentionRatio`

783 

784 Use retention ratio truncation.

785 

786 - `const RetentionRatioRetentionRatio RetentionRatio = "retention_ratio"`

787 

788 - `TokenLimits RealtimeTruncationRetentionRatioTokenLimits`

789 

790 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.

791 

792 - `PostInstructions int64`

793 

794 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.

795 

796 - `type RealtimeTranscriptionSessionCreateRequest struct{…}`

797 

798 Realtime transcription session object configuration.

799 

800 - `Type Transcription`

801 

802 The type of session to create. Always `transcription` for transcription sessions.

803 

804 - `const TranscriptionTranscription Transcription = "transcription"`

805 

806 - `Audio RealtimeTranscriptionSessionAudio`

807 

808 Configuration for input and output audio.

809 

810 - `Input RealtimeTranscriptionSessionAudioInput`

811 

812 - `Format RealtimeAudioFormatsUnion`

813 

814 The PCM audio format. Only a 24kHz sample rate is supported.

815 

816 - `NoiseReduction RealtimeTranscriptionSessionAudioInputNoiseReduction`

817 

818 Configuration for input audio noise reduction. This can be set to `null` to turn off.

819 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

820 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

821 

822 - `Type NoiseReductionType`

823 

824 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

825 

826 - `Transcription AudioTranscription`

827 

828 Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.

829 

830 - `TurnDetection RealtimeTranscriptionSessionAudioInputTurnDetectionUnion`

831 

832 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

833 

834 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

835 

836 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

837 

838 For `gpt-realtime-whisper` transcription sessions, turn detection must be

839 set to `null`; VAD is not supported.

840 

841 - `RealtimeTranscriptionSessionAudioInputTurnDetectionServerVad`

842 

843 - `Type ServerVad`

844 

845 Type of turn detection, `server_vad` to turn on simple Server VAD.

846 

847 - `const ServerVadServerVad ServerVad = "server_vad"`

848 

849 - `CreateResponse bool`

850 

851 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

852 

853 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

854 

855 - `IdleTimeoutMs int64`

856 

857 Optional timeout after which a model response will be triggered automatically. This is

858 useful for situations in which a long pause from the user is unexpected, such as a phone

859 call. The model will effectively prompt the user to continue the conversation based

860 on the current context.

861 

862 The timeout value will be applied after the last model response's audio has finished playing,

863 i.e. it's set to the `response.done` time plus audio playback duration.

864 

865 An `input_audio_buffer.timeout_triggered` event (plus events

866 associated with the Response) will be emitted when the timeout is reached.

867 Idle timeout is currently only supported for `server_vad` mode.

868 

869 - `InterruptResponse bool`

870 

871 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

872 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

873 

874 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

875 

876 - `PrefixPaddingMs int64`

877 

878 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

879 milliseconds). Defaults to 300ms.

880 

881 - `SilenceDurationMs int64`

882 

883 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

884 to 500ms. With shorter values the model will respond more quickly,

885 but may jump in on short pauses from the user.

886 

887 - `Threshold float64`

888 

889 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

890 higher threshold will require louder audio to activate the model, and

891 thus might perform better in noisy environments.

892 

893 - `RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVad`

894 

895 - `Type SemanticVad`

896 

897 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

898 

899 - `const SemanticVadSemanticVad SemanticVad = "semantic_vad"`

900 

901 - `CreateResponse bool`

902 

903 Whether or not to automatically generate a response when a VAD stop event occurs.

904 

905 - `Eagerness string`

906 

907 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

908 

909 - `const RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagernessLow RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagerness = "low"`

910 

911 - `const RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagernessMedium RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagerness = "medium"`

912 

913 - `const RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagernessHigh RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagerness = "high"`

914 

915 - `const RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagernessAuto RealtimeTranscriptionSessionAudioInputTurnDetectionSemanticVadEagerness = "auto"`

916 

917 - `InterruptResponse bool`

918 

919 Whether or not to automatically interrupt any ongoing response with output to the default

920 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

921 

922 - `Include []string`

923 

924 Additional fields to include in server outputs.

925 

926 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

927 

928 - `const RealtimeTranscriptionSessionCreateRequestIncludeItemInputAudioTranscriptionLogprobs RealtimeTranscriptionSessionCreateRequestInclude = "item.input_audio_transcription.logprobs"`

929 

930### Returns

931 

932- `type ClientSecretNewResponse struct{…}`

933 

934 Response from creating a session and client secret for the Realtime API.

935 

936 - `ExpiresAt int64`

937 

938 Expiration timestamp for the client secret, in seconds since epoch.

939 

940 - `Session ClientSecretNewResponseSessionUnion`

941 

942 The session configuration for either a realtime or transcription session.

943 

944 - `type RealtimeSessionCreateResponse struct{…}`

945 

946 A Realtime session configuration object.

947 

948 - `ID string`

949 

950 Unique identifier for the session that looks like `sess_1234567890abcdef`.

951 

952 - `Object RealtimeSession`

953 

954 The object type. Always `realtime.session`.

955 

956 - `const RealtimeSessionRealtimeSession RealtimeSession = "realtime.session"`

957 

958 - `Type Realtime`

959 

960 The type of session to create. Always `realtime` for the Realtime API.

961 

962 - `const RealtimeRealtime Realtime = "realtime"`

963 

964 - `Audio RealtimeSessionCreateResponseAudio`

965 

966 Configuration for input and output audio.

967 

968 - `Input RealtimeSessionCreateResponseAudioInput`

969 

970 - `Format RealtimeAudioFormatsUnion`

971 

972 The format of the input audio.

973 

974 - `type RealtimeAudioFormatsAudioPCM struct{…}`

975 

976 The PCM audio format. Only a 24kHz sample rate is supported.

977 

978 - `Rate int64`

979 

980 The sample rate of the audio. Always `24000`.

981 

982 - `const RealtimeAudioFormatsAudioPCMRate24000 RealtimeAudioFormatsAudioPCMRate = 24000`

983 

984 - `Type string`

985 

986 The audio format. Always `audio/pcm`.

987 

988 - `const RealtimeAudioFormatsAudioPCMTypeAudioPCM RealtimeAudioFormatsAudioPCMType = "audio/pcm"`

989 

990 - `type RealtimeAudioFormatsAudioPCMU struct{…}`

991 

992 The G.711 μ-law format.

993 

994 - `Type string`

995 

996 The audio format. Always `audio/pcmu`.

997 

998 - `const RealtimeAudioFormatsAudioPCMUTypeAudioPCMU RealtimeAudioFormatsAudioPCMUType = "audio/pcmu"`

999 

1000 - `type RealtimeAudioFormatsAudioPCMA struct{…}`

1001 

1002 The G.711 A-law format.

1003 

1004 - `Type string`

1005 

1006 The audio format. Always `audio/pcma`.

1007 

1008 - `const RealtimeAudioFormatsAudioPCMATypeAudioPCMA RealtimeAudioFormatsAudioPCMAType = "audio/pcma"`

1009 

1010 - `NoiseReduction RealtimeSessionCreateResponseAudioInputNoiseReduction`

1011 

1012 Configuration for input audio noise reduction. This can be set to `null` to turn off.

1013 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

1014 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

1015 

1016 - `Type NoiseReductionType`

1017 

1018 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

1019 

1020 - `const NoiseReductionTypeNearField NoiseReductionType = "near_field"`

1021 

1022 - `const NoiseReductionTypeFarField NoiseReductionType = "far_field"`

1023 

1024 - `Transcription AudioTranscription`

1025 

1026 - `Delay AudioTranscriptionDelay`

1027 

1028 Controls how long the model waits before emitting transcription text.

1029 Higher values can improve transcription accuracy at the cost of latency.

1030 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

1031 

1032 - `const AudioTranscriptionDelayMinimal AudioTranscriptionDelay = "minimal"`

1033 

1034 - `const AudioTranscriptionDelayLow AudioTranscriptionDelay = "low"`

1035 

1036 - `const AudioTranscriptionDelayMedium AudioTranscriptionDelay = "medium"`

1037 

1038 - `const AudioTranscriptionDelayHigh AudioTranscriptionDelay = "high"`

1039 

1040 - `const AudioTranscriptionDelayXhigh AudioTranscriptionDelay = "xhigh"`

1041 

1042 - `Language string`

1043 

1044 The language of the input audio. Supplying the input language in

1045 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

1046 will improve accuracy and latency.

1047 

1048 - `Model AudioTranscriptionModel`

1049 

1050 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

1051 

1052 - `string`

1053 

1054 - `type AudioTranscriptionModel string`

1055 

1056 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

1057 

1058 - `const AudioTranscriptionModelWhisper1 AudioTranscriptionModel = "whisper-1"`

1059 

1060 - `const AudioTranscriptionModelGPT4oMiniTranscribe AudioTranscriptionModel = "gpt-4o-mini-transcribe"`

1061 

1062 - `const AudioTranscriptionModelGPT4oMiniTranscribe2025_12_15 AudioTranscriptionModel = "gpt-4o-mini-transcribe-2025-12-15"`

1063 

1064 - `const AudioTranscriptionModelGPT4oTranscribe AudioTranscriptionModel = "gpt-4o-transcribe"`

1065 

1066 - `const AudioTranscriptionModelGPT4oTranscribeDiarize AudioTranscriptionModel = "gpt-4o-transcribe-diarize"`

1067 

1068 - `const AudioTranscriptionModelGPTRealtimeWhisper AudioTranscriptionModel = "gpt-realtime-whisper"`

1069 

1070 - `Prompt string`

1071 

1072 An optional text to guide the model's style or continue a previous audio

1073 segment.

1074 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).

1075 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

1076 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

1077 

1078 - `TurnDetection RealtimeSessionCreateResponseAudioInputTurnDetectionUnion`

1079 

1080 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

1081 

1082 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

1083 

1084 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

1085 

1086 For `gpt-realtime-whisper` transcription sessions, turn detection must be

1087 set to `null`; VAD is not supported.

1088 

1089 - `type RealtimeSessionCreateResponseAudioInputTurnDetectionServerVad struct{…}`

1090 

1091 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.

1092 

1093 - `Type ServerVad`

1094 

1095 Type of turn detection, `server_vad` to turn on simple Server VAD.

1096 

1097 - `const ServerVadServerVad ServerVad = "server_vad"`

1098 

1099 - `CreateResponse bool`

1100 

1101 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

1102 

1103 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

1104 

1105 - `IdleTimeoutMs int64`

1106 

1107 Optional timeout after which a model response will be triggered automatically. This is

1108 useful for situations in which a long pause from the user is unexpected, such as a phone

1109 call. The model will effectively prompt the user to continue the conversation based

1110 on the current context.

1111 

1112 The timeout value will be applied after the last model response's audio has finished playing,

1113 i.e. it's set to the `response.done` time plus audio playback duration.

1114 

1115 An `input_audio_buffer.timeout_triggered` event (plus events

1116 associated with the Response) will be emitted when the timeout is reached.

1117 Idle timeout is currently only supported for `server_vad` mode.

1118 

1119 - `InterruptResponse bool`

1120 

1121 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

1122 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

1123 

1124 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

1125 

1126 - `PrefixPaddingMs int64`

1127 

1128 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

1129 milliseconds). Defaults to 300ms.

1130 

1131 - `SilenceDurationMs int64`

1132 

1133 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

1134 to 500ms. With shorter values the model will respond more quickly,

1135 but may jump in on short pauses from the user.

1136 

1137 - `Threshold float64`

1138 

1139 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

1140 higher threshold will require louder audio to activate the model, and

1141 thus might perform better in noisy environments.

1142 

1143 - `type RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVad struct{…}`

1144 

1145 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.

1146 

1147 - `Type SemanticVad`

1148 

1149 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

1150 

1151 - `const SemanticVadSemanticVad SemanticVad = "semantic_vad"`

1152 

1153 - `CreateResponse bool`

1154 

1155 Whether or not to automatically generate a response when a VAD stop event occurs.

1156 

1157 - `Eagerness string`

1158 

1159 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

1160 

1161 - `const RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagernessLow RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagerness = "low"`

1162 

1163 - `const RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagernessMedium RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagerness = "medium"`

1164 

1165 - `const RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagernessHigh RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagerness = "high"`

1166 

1167 - `const RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagernessAuto RealtimeSessionCreateResponseAudioInputTurnDetectionSemanticVadEagerness = "auto"`

1168 

1169 - `InterruptResponse bool`

1170 

1171 Whether or not to automatically interrupt any ongoing response with output to the default

1172 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

1173 

1174 - `Output RealtimeSessionCreateResponseAudioOutput`

1175 

1176 - `Format RealtimeAudioFormatsUnion`

1177 

1178 The format of the output audio.

1179 

1180 - `Speed float64`

1181 

1182 The speed of the model's spoken response as a multiple of the original speed.

1183 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.

1184 

1185 This parameter is a post-processing adjustment to the audio after it is generated, it's

1186 also possible to prompt the model to speak faster or slower.

1187 

1188 - `Voice string`

1189 

1190 The voice the model uses to respond. Voice cannot be changed during the

1191 session once the model has responded with audio at least once. Current

1192 voice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,

1193 `shimmer`, `verse`, `marin`, and `cedar`. We recommend `marin` and `cedar` for

1194 best quality.

1195 

1196 - `string`

1197 

1198 - `string`

1199 

1200 - `const RealtimeSessionCreateResponseAudioOutputVoiceAlloy RealtimeSessionCreateResponseAudioOutputVoice = "alloy"`

1201 

1202 - `const RealtimeSessionCreateResponseAudioOutputVoiceAsh RealtimeSessionCreateResponseAudioOutputVoice = "ash"`

1203 

1204 - `const RealtimeSessionCreateResponseAudioOutputVoiceBallad RealtimeSessionCreateResponseAudioOutputVoice = "ballad"`

1205 

1206 - `const RealtimeSessionCreateResponseAudioOutputVoiceCoral RealtimeSessionCreateResponseAudioOutputVoice = "coral"`

1207 

1208 - `const RealtimeSessionCreateResponseAudioOutputVoiceEcho RealtimeSessionCreateResponseAudioOutputVoice = "echo"`

1209 

1210 - `const RealtimeSessionCreateResponseAudioOutputVoiceSage RealtimeSessionCreateResponseAudioOutputVoice = "sage"`

1211 

1212 - `const RealtimeSessionCreateResponseAudioOutputVoiceShimmer RealtimeSessionCreateResponseAudioOutputVoice = "shimmer"`

1213 

1214 - `const RealtimeSessionCreateResponseAudioOutputVoiceVerse RealtimeSessionCreateResponseAudioOutputVoice = "verse"`

1215 

1216 - `const RealtimeSessionCreateResponseAudioOutputVoiceMarin RealtimeSessionCreateResponseAudioOutputVoice = "marin"`

1217 

1218 - `const RealtimeSessionCreateResponseAudioOutputVoiceCedar RealtimeSessionCreateResponseAudioOutputVoice = "cedar"`

1219 

1220 - `ExpiresAt int64`

1221 

1222 Expiration timestamp for the session, in seconds since epoch.

1223 

1224 - `Include []string`

1225 

1226 Additional fields to include in server outputs.

1227 

1228 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

1229 

1230 - `const RealtimeSessionCreateResponseIncludeItemInputAudioTranscriptionLogprobs RealtimeSessionCreateResponseInclude = "item.input_audio_transcription.logprobs"`

1231 

1232 - `Instructions string`

1233 

1234 The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.

1235 

1236 Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.

1237 

1238 - `MaxOutputTokens RealtimeSessionCreateResponseMaxOutputTokensUnion`

1239 

1240 Maximum number of output tokens for a single assistant response,

1241 inclusive of tool calls. Provide an integer between 1 and 4096 to

1242 limit output tokens, or `inf` for the maximum available tokens for a

1243 given model. Defaults to `inf`.

1244 

1245 - `int64`

1246 

1247 - `type Inf string`

1248 

1249 - `const InfInf Inf = "inf"`

1250 

1251 - `Model RealtimeSessionCreateResponseModel`

1252 

1253 The Realtime model used for this session.

1254 

1255 - `string`

1256 

1257 - `type RealtimeSessionCreateResponseModel string`

1258 

1259 The Realtime model used for this session.

1260 

1261 - `const RealtimeSessionCreateResponseModelGPTRealtime RealtimeSessionCreateResponseModel = "gpt-realtime"`

1262 

1263 - `const RealtimeSessionCreateResponseModelGPTRealtime1_5 RealtimeSessionCreateResponseModel = "gpt-realtime-1.5"`

1264 

1265 - `const RealtimeSessionCreateResponseModelGPTRealtime2 RealtimeSessionCreateResponseModel = "gpt-realtime-2"`

1266 

1267 - `const RealtimeSessionCreateResponseModelGPTRealtime2025_08_28 RealtimeSessionCreateResponseModel = "gpt-realtime-2025-08-28"`

1268 

1269 - `const RealtimeSessionCreateResponseModelGPT4oRealtimePreview RealtimeSessionCreateResponseModel = "gpt-4o-realtime-preview"`

1270 

1271 - `const RealtimeSessionCreateResponseModelGPT4oRealtimePreview2024_10_01 RealtimeSessionCreateResponseModel = "gpt-4o-realtime-preview-2024-10-01"`

1272 

1273 - `const RealtimeSessionCreateResponseModelGPT4oRealtimePreview2024_12_17 RealtimeSessionCreateResponseModel = "gpt-4o-realtime-preview-2024-12-17"`

1274 

1275 - `const RealtimeSessionCreateResponseModelGPT4oRealtimePreview2025_06_03 RealtimeSessionCreateResponseModel = "gpt-4o-realtime-preview-2025-06-03"`

1276 

1277 - `const RealtimeSessionCreateResponseModelGPT4oMiniRealtimePreview RealtimeSessionCreateResponseModel = "gpt-4o-mini-realtime-preview"`

1278 

1279 - `const RealtimeSessionCreateResponseModelGPT4oMiniRealtimePreview2024_12_17 RealtimeSessionCreateResponseModel = "gpt-4o-mini-realtime-preview-2024-12-17"`

1280 

1281 - `const RealtimeSessionCreateResponseModelGPTRealtimeMini RealtimeSessionCreateResponseModel = "gpt-realtime-mini"`

1282 

1283 - `const RealtimeSessionCreateResponseModelGPTRealtimeMini2025_10_06 RealtimeSessionCreateResponseModel = "gpt-realtime-mini-2025-10-06"`

1284 

1285 - `const RealtimeSessionCreateResponseModelGPTRealtimeMini2025_12_15 RealtimeSessionCreateResponseModel = "gpt-realtime-mini-2025-12-15"`

1286 

1287 - `const RealtimeSessionCreateResponseModelGPTAudio1_5 RealtimeSessionCreateResponseModel = "gpt-audio-1.5"`

1288 

1289 - `const RealtimeSessionCreateResponseModelGPTAudioMini RealtimeSessionCreateResponseModel = "gpt-audio-mini"`

1290 

1291 - `const RealtimeSessionCreateResponseModelGPTAudioMini2025_10_06 RealtimeSessionCreateResponseModel = "gpt-audio-mini-2025-10-06"`

1292 

1293 - `const RealtimeSessionCreateResponseModelGPTAudioMini2025_12_15 RealtimeSessionCreateResponseModel = "gpt-audio-mini-2025-12-15"`

1294 

1295 - `OutputModalities []string`

1296 

1297 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating

1298 that the model will respond with audio plus a transcript. `["text"]` can be used to make

1299 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.

1300 

1301 - `const RealtimeSessionCreateResponseOutputModalityText RealtimeSessionCreateResponseOutputModality = "text"`

1302 

1303 - `const RealtimeSessionCreateResponseOutputModalityAudio RealtimeSessionCreateResponseOutputModality = "audio"`

1304 

1305 - `Prompt ResponsePrompt`

1306 

1307 Reference to a prompt template and its variables.

1308 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).

1309 

1310 - `ID string`

1311 

1312 The unique identifier of the prompt template to use.

1313 

1314 - `Variables map[string, ResponsePromptVariableUnion]`

1315 

1316 Optional map of values to substitute in for variables in your

1317 prompt. The substitution values can either be strings, or other

1318 Response input types like images or files.

1319 

1320 - `string`

1321 

1322 - `type ResponseInputText struct{…}`

1323 

1324 A text input to the model.

1325 

1326 - `Text string`

1327 

1328 The text input to the model.

1329 

1330 - `Type InputText`

1331 

1332 The type of the input item. Always `input_text`.

1333 

1334 - `const InputTextInputText InputText = "input_text"`

1335 

1336 - `type ResponseInputImage struct{…}`

1337 

1338 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).

1339 

1340 - `Detail ResponseInputImageDetail`

1341 

1342 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.

1343 

1344 - `const ResponseInputImageDetailLow ResponseInputImageDetail = "low"`

1345 

1346 - `const ResponseInputImageDetailHigh ResponseInputImageDetail = "high"`

1347 

1348 - `const ResponseInputImageDetailAuto ResponseInputImageDetail = "auto"`

1349 

1350 - `const ResponseInputImageDetailOriginal ResponseInputImageDetail = "original"`

1351 

1352 - `Type InputImage`

1353 

1354 The type of the input item. Always `input_image`.

1355 

1356 - `const InputImageInputImage InputImage = "input_image"`

1357 

1358 - `FileID string`

1359 

1360 The ID of the file to be sent to the model.

1361 

1362 - `ImageURL string`

1363 

1364 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.

1365 

1366 - `type ResponseInputFile struct{…}`

1367 

1368 A file input to the model.

1369 

1370 - `Type InputFile`

1371 

1372 The type of the input item. Always `input_file`.

1373 

1374 - `const InputFileInputFile InputFile = "input_file"`

1375 

1376 - `Detail ResponseInputFileDetail`

1377 

1378 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.

1379 

1380 - `const ResponseInputFileDetailLow ResponseInputFileDetail = "low"`

1381 

1382 - `const ResponseInputFileDetailHigh ResponseInputFileDetail = "high"`

1383 

1384 - `FileData string`

1385 

1386 The content of the file to be sent to the model.

1387 

1388 - `FileID string`

1389 

1390 The ID of the file to be sent to the model.

1391 

1392 - `FileURL string`

1393 

1394 The URL of the file to be sent to the model.

1395 

1396 - `Filename string`

1397 

1398 The name of the file to be sent to the model.

1399 

1400 - `Version string`

1401 

1402 Optional version of the prompt template.

1403 

1404 - `Reasoning RealtimeReasoning`

1405 

1406 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.

1407 

1408 - `Effort RealtimeReasoningEffort`

1409 

1410 Constrains effort on reasoning for reasoning-capable Realtime models such as

1411 `gpt-realtime-2`.

1412 

1413 - `const RealtimeReasoningEffortMinimal RealtimeReasoningEffort = "minimal"`

1414 

1415 - `const RealtimeReasoningEffortLow RealtimeReasoningEffort = "low"`

1416 

1417 - `const RealtimeReasoningEffortMedium RealtimeReasoningEffort = "medium"`

1418 

1419 - `const RealtimeReasoningEffortHigh RealtimeReasoningEffort = "high"`

1420 

1421 - `const RealtimeReasoningEffortXhigh RealtimeReasoningEffort = "xhigh"`

1422 

1423 - `ToolChoice RealtimeSessionCreateResponseToolChoiceUnion`

1424 

1425 How the model chooses tools. Provide one of the string modes or force a specific

1426 function/MCP tool.

1427 

1428 - `type ToolChoiceOptions string`

1429 

1430 Controls which (if any) tool is called by the model.

1431 

1432 `none` means the model will not call any tool and instead generates a message.

1433 

1434 `auto` means the model can pick between generating a message or calling one or

1435 more tools.

1436 

1437 `required` means the model must call one or more tools.

1438 

1439 - `const ToolChoiceOptionsNone ToolChoiceOptions = "none"`

1440 

1441 - `const ToolChoiceOptionsAuto ToolChoiceOptions = "auto"`

1442 

1443 - `const ToolChoiceOptionsRequired ToolChoiceOptions = "required"`

1444 

1445 - `type ToolChoiceFunction struct{…}`

1446 

1447 Use this option to force the model to call a specific function.

1448 

1449 - `Name string`

1450 

1451 The name of the function to call.

1452 

1453 - `Type Function`

1454 

1455 For function calling, the type is always `function`.

1456 

1457 - `const FunctionFunction Function = "function"`

1458 

1459 - `type ToolChoiceMcp struct{…}`

1460 

1461 Use this option to force the model to call a specific tool on a remote MCP server.

1462 

1463 - `ServerLabel string`

1464 

1465 The label of the MCP server to use.

1466 

1467 - `Type Mcp`

1468 

1469 For MCP tools, the type is always `mcp`.

1470 

1471 - `const McpMcp Mcp = "mcp"`

1472 

1473 - `Name string`

1474 

1475 The name of the tool to call on the server.

1476 

1477 - `Tools []RealtimeSessionCreateResponseToolUnion`

1478 

1479 Tools available to the model.

1480 

1481 - `type RealtimeFunctionTool struct{…}`

1482 

1483 - `Description string`

1484 

1485 The description of the function, including guidance on when and how

1486 to call it, and guidance about what to tell the user when calling

1487 (if anything).

1488 

1489 - `Name string`

1490 

1491 The name of the function.

1492 

1493 - `Parameters any`

1494 

1495 Parameters of the function in JSON Schema.

1496 

1497 - `Type RealtimeFunctionToolType`

1498 

1499 The type of the tool, i.e. `function`.

1500 

1501 - `const RealtimeFunctionToolTypeFunction RealtimeFunctionToolType = "function"`

1502 

1503 - `type RealtimeSessionCreateResponseToolMcpTool struct{…}`

1504 

1505 Give the model access to additional tools via remote Model Context Protocol

1506 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).

1507 

1508 - `ServerLabel string`

1509 

1510 A label for this MCP server, used to identify it in tool calls.

1511 

1512 - `Type Mcp`

1513 

1514 The type of the MCP tool. Always `mcp`.

1515 

1516 - `const McpMcp Mcp = "mcp"`

1517 

1518 - `AllowedTools RealtimeSessionCreateResponseToolMcpToolAllowedToolsUnion`

1519 

1520 List of allowed tool names or a filter object.

1521 

1522 - `type RealtimeSessionCreateResponseToolMcpToolAllowedToolsMcpAllowedTools []string`

1523 

1524 A string array of allowed tool names

1525 

1526 - `type RealtimeSessionCreateResponseToolMcpToolAllowedToolsMcpToolFilter struct{…}`

1527 

1528 A filter object to specify which tools are allowed.

1529 

1530 - `ReadOnly bool`

1531 

1532 Indicates whether or not a tool modifies data or is read-only. If an

1533 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1534 it will match this filter.

1535 

1536 - `ToolNames []string`

1537 

1538 List of allowed tool names.

1539 

1540 - `Authorization string`

1541 

1542 An OAuth access token that can be used with a remote MCP server, either

1543 with a custom MCP server URL or a service connector. Your application

1544 must handle the OAuth authorization flow and provide the token here.

1545 

1546 - `ConnectorID string`

1547 

1548 Identifier for service connectors, like those available in ChatGPT. One of

1549 `server_url` or `connector_id` must be provided. Learn more about service

1550 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).

1551 

1552 Currently supported `connector_id` values are:

1553 

1554 - Dropbox: `connector_dropbox`

1555 - Gmail: `connector_gmail`

1556 - Google Calendar: `connector_googlecalendar`

1557 - Google Drive: `connector_googledrive`

1558 - Microsoft Teams: `connector_microsoftteams`

1559 - Outlook Calendar: `connector_outlookcalendar`

1560 - Outlook Email: `connector_outlookemail`

1561 - SharePoint: `connector_sharepoint`

1562 

1563 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorDropbox RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_dropbox"`

1564 

1565 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorGmail RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_gmail"`

1566 

1567 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorGooglecalendar RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_googlecalendar"`

1568 

1569 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorGoogledrive RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_googledrive"`

1570 

1571 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorMicrosoftteams RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_microsoftteams"`

1572 

1573 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorOutlookcalendar RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_outlookcalendar"`

1574 

1575 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorOutlookemail RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_outlookemail"`

1576 

1577 - `const RealtimeSessionCreateResponseToolMcpToolConnectorIDConnectorSharepoint RealtimeSessionCreateResponseToolMcpToolConnectorID = "connector_sharepoint"`

1578 

1579 - `DeferLoading bool`

1580 

1581 Whether this MCP tool is deferred and discovered via tool search.

1582 

1583 - `Headers map[string, string]`

1584 

1585 Optional HTTP headers to send to the MCP server. Use for authentication

1586 or other purposes.

1587 

1588 - `RequireApproval RealtimeSessionCreateResponseToolMcpToolRequireApprovalUnion`

1589 

1590 Specify which of the MCP server's tools require approval.

1591 

1592 - `type RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalFilter struct{…}`

1593 

1594 Specify which of the MCP server's tools require approval. Can be

1595 `always`, `never`, or a filter object associated with tools

1596 that require approval.

1597 

1598 - `Always RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalFilterAlways`

1599 

1600 A filter object to specify which tools are allowed.

1601 

1602 - `ReadOnly bool`

1603 

1604 Indicates whether or not a tool modifies data or is read-only. If an

1605 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1606 it will match this filter.

1607 

1608 - `ToolNames []string`

1609 

1610 List of allowed tool names.

1611 

1612 - `Never RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalFilterNever`

1613 

1614 A filter object to specify which tools are allowed.

1615 

1616 - `ReadOnly bool`

1617 

1618 Indicates whether or not a tool modifies data or is read-only. If an

1619 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1620 it will match this filter.

1621 

1622 - `ToolNames []string`

1623 

1624 List of allowed tool names.

1625 

1626 - `type RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalSetting string`

1627 

1628 Specify a single approval policy for all tools. One of `always` or

1629 `never`. When set to `always`, all tools will require approval. When

1630 set to `never`, all tools will not require approval.

1631 

1632 - `const RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalSettingAlways RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalSetting = "always"`

1633 

1634 - `const RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalSettingNever RealtimeSessionCreateResponseToolMcpToolRequireApprovalMcpToolApprovalSetting = "never"`

1635 

1636 - `ServerDescription string`

1637 

1638 Optional description of the MCP server, used to provide more context.

1639 

1640 - `ServerURL string`

1641 

1642 The URL for the MCP server. One of `server_url` or `connector_id` must be

1643 provided.

1644 

1645 - `Tracing RealtimeSessionCreateResponseTracingUnion`

1646 

1647 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once

1648 tracing is enabled for a session, the configuration cannot be modified.

1649 

1650 `auto` will create a trace for the session with default values for the

1651 workflow name, group id, and metadata.

1652 

1653 - `type Auto string`

1654 

1655 Enables tracing and sets default values for tracing configuration options. Always `auto`.

1656 

1657 - `const AutoAuto Auto = "auto"`

1658 

1659 - `type RealtimeSessionCreateResponseTracingTracingConfiguration struct{…}`

1660 

1661 Granular configuration for tracing.

1662 

1663 - `GroupID string`

1664 

1665 The group id to attach to this trace to enable filtering and

1666 grouping in the Traces Dashboard.

1667 

1668 - `Metadata any`

1669 

1670 The arbitrary metadata to attach to this trace to enable

1671 filtering in the Traces Dashboard.

1672 

1673 - `WorkflowName string`

1674 

1675 The name of the workflow to attach to this trace. This is used to

1676 name the trace in the Traces Dashboard.

1677 

1678 - `Truncation RealtimeTruncationUnion`

1679 

1680 When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

1681 

1682 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

1683 

1684 Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

1685 

1686 Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.

1687 

1688 - `type RealtimeTruncationRealtimeTruncationStrategy string`

1689 

1690 The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit.

1691 

1692 - `const RealtimeTruncationRealtimeTruncationStrategyAuto RealtimeTruncationRealtimeTruncationStrategy = "auto"`

1693 

1694 - `const RealtimeTruncationRealtimeTruncationStrategyDisabled RealtimeTruncationRealtimeTruncationStrategy = "disabled"`

1695 

1696 - `type RealtimeTruncationRetentionRatio struct{…}`

1697 

1698 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

1699 

1700 - `RetentionRatio float64`

1701 

1702 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.

1703 

1704 - `Type RetentionRatio`

1705 

1706 Use retention ratio truncation.

1707 

1708 - `const RetentionRatioRetentionRatio RetentionRatio = "retention_ratio"`

1709 

1710 - `TokenLimits RealtimeTruncationRetentionRatioTokenLimits`

1711 

1712 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.

1713 

1714 - `PostInstructions int64`

1715 

1716 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.

1717 

1718 - `type RealtimeTranscriptionSessionCreateResponse struct{…}`

1719 

1720 A Realtime transcription session configuration object.

1721 

1722 - `ID string`

1723 

1724 Unique identifier for the session that looks like `sess_1234567890abcdef`.

1725 

1726 - `Object string`

1727 

1728 The object type. Always `realtime.transcription_session`.

1729 

1730 - `Type Transcription`

1731 

1732 The type of session. Always `transcription` for transcription sessions.

1733 

1734 - `const TranscriptionTranscription Transcription = "transcription"`

1735 

1736 - `Audio RealtimeTranscriptionSessionCreateResponseAudio`

1737 

1738 Configuration for input audio for the session.

1739 

1740 - `Input RealtimeTranscriptionSessionCreateResponseAudioInput`

1741 

1742 - `Format RealtimeAudioFormatsUnion`

1743 

1744 The PCM audio format. Only a 24kHz sample rate is supported.

1745 

1746 - `NoiseReduction RealtimeTranscriptionSessionCreateResponseAudioInputNoiseReduction`

1747 

1748 Configuration for input audio noise reduction.

1749 

1750 - `Type NoiseReductionType`

1751 

1752 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

1753 

1754 - `Transcription AudioTranscription`

1755 

1756 - `TurnDetection RealtimeTranscriptionSessionTurnDetection`

1757 

1758 Configuration for turn detection. Can be set to `null` to turn off. Server

1759 VAD means that the model will detect the start and end of speech based on

1760 audio volume and respond at the end of user speech. For `gpt-realtime-whisper`, this must be `null`; VAD is not supported.

1761 

1762 - `PrefixPaddingMs int64`

1763 

1764 Amount of audio to include before the VAD detected speech (in

1765 milliseconds). Defaults to 300ms.

1766 

1767 - `SilenceDurationMs int64`

1768 

1769 Duration of silence to detect speech stop (in milliseconds). Defaults

1770 to 500ms. With shorter values the model will respond more quickly,

1771 but may jump in on short pauses from the user.

1772 

1773 - `Threshold float64`

1774 

1775 Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

1776 higher threshold will require louder audio to activate the model, and

1777 thus might perform better in noisy environments.

1778 

1779 - `Type string`

1780 

1781 Type of turn detection, only `server_vad` is currently supported.

1782 

1783 - `ExpiresAt int64`

1784 

1785 Expiration timestamp for the session, in seconds since epoch.

1786 

1787 - `Include []string`

1788 

1789 Additional fields to include in server outputs.

1790 

1791 - `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

1792 

1793 - `const RealtimeTranscriptionSessionCreateResponseIncludeItemInputAudioTranscriptionLogprobs RealtimeTranscriptionSessionCreateResponseInclude = "item.input_audio_transcription.logprobs"`

1794 

1795 - `Value string`

1796 

1797 The generated client secret value.

1798 

1799### Example

1800 

1801```go

1802package main

1803 

1804import (

1805 "context"

1806 "fmt"

1807 

1808 "github.com/openai/openai-go"

1809 "github.com/openai/openai-go/option"

1810 "github.com/openai/openai-go/realtime"

1811)

1812 

1813func main() {

1814 client := openai.NewClient(

1815 option.WithAPIKey("My API Key"),

1816 )

1817 clientSecret, err := client.Realtime.ClientSecrets.New(context.TODO(), realtime.ClientSecretNewParams{

1818 

1819 })

1820 if err != nil {

1821 panic(err.Error())

1822 }

1823 fmt.Printf("%+v\n", clientSecret.ExpiresAt)

1824}

1825```

1826 

1827#### Response

1828 

1829```json

1830{

1831 "expires_at": 0,

1832 "session": {

1833 "id": "id",

1834 "object": "realtime.session",

1835 "type": "realtime",

1836 "audio": {

1837 "input": {

1838 "format": {

1839 "rate": 24000,

1840 "type": "audio/pcm"

1841 },

1842 "noise_reduction": {

1843 "type": "near_field"

1844 },

1845 "transcription": {

1846 "delay": "minimal",

1847 "language": "language",

1848 "model": "whisper-1",

1849 "prompt": "prompt"

1850 },

1851 "turn_detection": {

1852 "type": "server_vad",

1853 "create_response": true,

1854 "idle_timeout_ms": 5000,

1855 "interrupt_response": true,

1856 "prefix_padding_ms": 0,

1857 "silence_duration_ms": 0,

1858 "threshold": 0

1859 }

1860 },

1861 "output": {

1862 "format": {

1863 "rate": 24000,

1864 "type": "audio/pcm"

1865 },

1866 "speed": 0.25,

1867 "voice": "ash"

1868 }

1869 },

1870 "expires_at": 0,

1871 "include": [

1872 "item.input_audio_transcription.logprobs"

1873 ],

1874 "instructions": "instructions",

1875 "max_output_tokens": "inf",

1876 "model": "gpt-realtime",

1877 "output_modalities": [

1878 "text"

1879 ],

1880 "prompt": {

1881 "id": "id",

1882 "variables": {

1883 "foo": "string"

1884 },

1885 "version": "version"

1886 },

1887 "reasoning": {

1888 "effort": "minimal"

1889 },

1890 "tool_choice": "none",

1891 "tools": [

1892 {

1893 "description": "description",

1894 "name": "name",

1895 "parameters": {},

1896 "type": "function"

1897 }

1898 ],

1899 "tracing": "auto",

1900 "truncation": "auto"

1901 },

1902 "value": "value"

1903}

1904```

Details

1## Create video

2 

3`client.Videos.New(ctx, body) (*Video, error)`

4 

5**post** `/videos`

6 

7Create a new video generation job from a prompt and optional reference assets.

8 

9### Parameters

10 

11- `body VideoNewParams`

12 

13 - `Prompt param.Field[string]`

14 

15 Text prompt that describes the video to generate.

16 

17 - `InputReference param.Field[VideoNewParamsInputReferenceUnion]`

18 

19 Optional reference asset upload or reference object that guides generation.

20 

21 - `Reader`

22 

23 - `type ImageInputReferenceParamResp struct{…}`

24 

25 - `FileID string`

26 

27 - `ImageURL string`

28 

29 A fully qualified URL or base64-encoded data URL.

30 

31 - `Model param.Field[VideoModel]`

32 

33 The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to `sora-2`.

34 

35 - `Seconds param.Field[VideoSeconds]`

36 

37 Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds.

38 

39 - `Size param.Field[VideoSize]`

40 

41 Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280.

42 

43### Returns

44 

45- `type Video struct{…}`

46 

47 Structured information describing a generated video job.

48 

49 - `ID string`

50 

51 Unique identifier for the video job.

52 

53 - `CompletedAt int64`

54 

55 Unix timestamp (seconds) for when the job completed, if finished.

56 

57 - `CreatedAt int64`

58 

59 Unix timestamp (seconds) for when the job was created.

60 

61 - `Error VideoCreateError`

62 

63 Error payload that explains why generation failed, if applicable.

64 

65 - `Code string`

66 

67 A machine-readable error code that was returned.

68 

69 - `Message string`

70 

71 A human-readable description of the error that was returned.

72 

73 - `ExpiresAt int64`

74 

75 Unix timestamp (seconds) for when the downloadable assets expire, if set.

76 

77 - `Model VideoModel`

78 

79 The video generation model that produced the job.

80 

81 - `string`

82 

83 - `type VideoModel string`

84 

85 - `const VideoModelSora2 VideoModel = "sora-2"`

86 

87 - `const VideoModelSora2Pro VideoModel = "sora-2-pro"`

88 

89 - `const VideoModelSora2_2025_10_06 VideoModel = "sora-2-2025-10-06"`

90 

91 - `const VideoModelSora2Pro2025_10_06 VideoModel = "sora-2-pro-2025-10-06"`

92 

93 - `const VideoModelSora2_2025_12_08 VideoModel = "sora-2-2025-12-08"`

94 

95 - `Object Video`

96 

97 The object type, which is always `video`.

98 

99 - `const VideoVideo Video = "video"`

100 

101 - `Progress int64`

102 

103 Approximate completion percentage for the generation task.

104 

105 - `Prompt string`

106 

107 The prompt that was used to generate the video.

108 

109 - `RemixedFromVideoID string`

110 

111 Identifier of the source video if this video is a remix.

112 

113 - `Seconds VideoSeconds`

114 

115 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

116 

117 - `string`

118 

119 - `type VideoSeconds string`

120 

121 - `const VideoSeconds4 VideoSeconds = "4"`

122 

123 - `const VideoSeconds8 VideoSeconds = "8"`

124 

125 - `const VideoSeconds12 VideoSeconds = "12"`

126 

127 - `Size VideoSize`

128 

129 The resolution of the generated video.

130 

131 - `const VideoSize720x1280 VideoSize = "720x1280"`

132 

133 - `const VideoSize1280x720 VideoSize = "1280x720"`

134 

135 - `const VideoSize1024x1792 VideoSize = "1024x1792"`

136 

137 - `const VideoSize1792x1024 VideoSize = "1792x1024"`

138 

139 - `Status VideoStatus`

140 

141 Current lifecycle status of the video job.

142 

143 - `const VideoStatusQueued VideoStatus = "queued"`

144 

145 - `const VideoStatusInProgress VideoStatus = "in_progress"`

146 

147 - `const VideoStatusCompleted VideoStatus = "completed"`

148 

149 - `const VideoStatusFailed VideoStatus = "failed"`

150 

151### Example

152 

153```go

154package main

155 

156import (

157 "context"

158 "fmt"

159 

160 "github.com/openai/openai-go"

161 "github.com/openai/openai-go/option"

162)

163 

164func main() {

165 client := openai.NewClient(

166 option.WithAPIKey("My API Key"),

167 )

168 video, err := client.Videos.New(context.TODO(), openai.VideoNewParams{

169 Prompt: "x",

170 })

171 if err != nil {

172 panic(err.Error())

173 }

174 fmt.Printf("%+v\n", video.ID)

175}

176```

177 

178#### Response

179 

180```json

181{

182 "id": "id",

183 "completed_at": 0,

184 "created_at": 0,

185 "error": {

186 "code": "code",

187 "message": "message"

188 },

189 "expires_at": 0,

190 "model": "sora-2",

191 "object": "video",

192 "progress": 0,

193 "prompt": "prompt",

194 "remixed_from_video_id": "remixed_from_video_id",

195 "seconds": "4",

196 "size": "720x1280",

197 "status": "queued"

198}

199```

200 

201### Example

202 

203```go

204package main

205 

206import (

207 "context"

208 "fmt"

209 

210 "github.com/openai/openai-go"

211)

212 

213func main() {

214 client := openai.NewClient()

215 video, err := client.Videos.New(context.TODO(), openai.VideoNewParams{

216 Prompt: "A calico cat playing a piano on stage",

217 })

218 if err != nil {

219 panic(err.Error())

220 }

221 fmt.Printf("%+v\n", video.ID)

222}

223```

224 

225#### Response

226 

227```json

228{

229 "id": "video_123",

230 "object": "video",

231 "model": "sora-2",

232 "status": "queued",

233 "progress": 0,

234 "created_at": 1712697600,

235 "size": "1024x1792",

236 "seconds": "8",

237 "quality": "standard"

238}

239```

Details

1## Create a new video generation job by editing a source video or existing generated video.

2 

3`client.Videos.Edit(ctx, body) (*Video, error)`

4 

5**post** `/videos/edits`

6 

7Create a new video generation job by editing a source video or existing generated video.

8 

9### Parameters

10 

11- `body VideoEditParams`

12 

13 - `Prompt param.Field[string]`

14 

15 Text prompt that describes how to edit the source video.

16 

17 - `Video param.Field[VideoEditParamsVideoUnion]`

18 

19 Reference to the completed video to edit.

20 

21 - `Reader`

22 

23 - `type VideoEditParamsVideoVideoReferenceInputParam struct{…}`

24 

25 Reference to the completed video.

26 

27 - `ID string`

28 

29 The identifier of the completed video.

30 

31### Returns

32 

33- `type Video struct{…}`

34 

35 Structured information describing a generated video job.

36 

37 - `ID string`

38 

39 Unique identifier for the video job.

40 

41 - `CompletedAt int64`

42 

43 Unix timestamp (seconds) for when the job completed, if finished.

44 

45 - `CreatedAt int64`

46 

47 Unix timestamp (seconds) for when the job was created.

48 

49 - `Error VideoCreateError`

50 

51 Error payload that explains why generation failed, if applicable.

52 

53 - `Code string`

54 

55 A machine-readable error code that was returned.

56 

57 - `Message string`

58 

59 A human-readable description of the error that was returned.

60 

61 - `ExpiresAt int64`

62 

63 Unix timestamp (seconds) for when the downloadable assets expire, if set.

64 

65 - `Model VideoModel`

66 

67 The video generation model that produced the job.

68 

69 - `string`

70 

71 - `type VideoModel string`

72 

73 - `const VideoModelSora2 VideoModel = "sora-2"`

74 

75 - `const VideoModelSora2Pro VideoModel = "sora-2-pro"`

76 

77 - `const VideoModelSora2_2025_10_06 VideoModel = "sora-2-2025-10-06"`

78 

79 - `const VideoModelSora2Pro2025_10_06 VideoModel = "sora-2-pro-2025-10-06"`

80 

81 - `const VideoModelSora2_2025_12_08 VideoModel = "sora-2-2025-12-08"`

82 

83 - `Object Video`

84 

85 The object type, which is always `video`.

86 

87 - `const VideoVideo Video = "video"`

88 

89 - `Progress int64`

90 

91 Approximate completion percentage for the generation task.

92 

93 - `Prompt string`

94 

95 The prompt that was used to generate the video.

96 

97 - `RemixedFromVideoID string`

98 

99 Identifier of the source video if this video is a remix.

100 

101 - `Seconds VideoSeconds`

102 

103 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

104 

105 - `string`

106 

107 - `type VideoSeconds string`

108 

109 - `const VideoSeconds4 VideoSeconds = "4"`

110 

111 - `const VideoSeconds8 VideoSeconds = "8"`

112 

113 - `const VideoSeconds12 VideoSeconds = "12"`

114 

115 - `Size VideoSize`

116 

117 The resolution of the generated video.

118 

119 - `const VideoSize720x1280 VideoSize = "720x1280"`

120 

121 - `const VideoSize1280x720 VideoSize = "1280x720"`

122 

123 - `const VideoSize1024x1792 VideoSize = "1024x1792"`

124 

125 - `const VideoSize1792x1024 VideoSize = "1792x1024"`

126 

127 - `Status VideoStatus`

128 

129 Current lifecycle status of the video job.

130 

131 - `const VideoStatusQueued VideoStatus = "queued"`

132 

133 - `const VideoStatusInProgress VideoStatus = "in_progress"`

134 

135 - `const VideoStatusCompleted VideoStatus = "completed"`

136 

137 - `const VideoStatusFailed VideoStatus = "failed"`

138 

139### Example

140 

141```go

142package main

143 

144import (

145 "bytes"

146 "context"

147 "fmt"

148 "io"

149 

150 "github.com/openai/openai-go"

151 "github.com/openai/openai-go/option"

152)

153 

154func main() {

155 client := openai.NewClient(

156 option.WithAPIKey("My API Key"),

157 )

158 video, err := client.Videos.Edit(context.TODO(), openai.VideoEditParams{

159 Prompt: "x",

160 Video: openai.VideoEditParamsVideoUnion{

161 OfFile: io.Reader(bytes.NewBuffer([]byte("Example data"))),

162 },

163 })

164 if err != nil {

165 panic(err.Error())

166 }

167 fmt.Printf("%+v\n", video.ID)

168}

169```

170 

171#### Response

172 

173```json

174{

175 "id": "id",

176 "completed_at": 0,

177 "created_at": 0,

178 "error": {

179 "code": "code",

180 "message": "message"

181 },

182 "expires_at": 0,

183 "model": "sora-2",

184 "object": "video",

185 "progress": 0,

186 "prompt": "prompt",

187 "remixed_from_video_id": "remixed_from_video_id",

188 "seconds": "4",

189 "size": "720x1280",

190 "status": "queued"

191}

192```

Details

1## Create an extension of a completed video.

2 

3`client.Videos.Extend(ctx, body) (*Video, error)`

4 

5**post** `/videos/extensions`

6 

7Create an extension of a completed video.

8 

9### Parameters

10 

11- `body VideoExtendParams`

12 

13 - `Prompt param.Field[string]`

14 

15 Updated text prompt that directs the extension generation.

16 

17 - `Seconds param.Field[VideoSeconds]`

18 

19 Length of the newly generated extension segment in seconds (allowed values: 4, 8, 12, 16, 20).

20 

21 - `Video param.Field[VideoExtendParamsVideoUnion]`

22 

23 Reference to the completed video to extend.

24 

25 - `Reader`

26 

27 - `type VideoExtendParamsVideoVideoReferenceInputParam struct{…}`

28 

29 Reference to the completed video.

30 

31 - `ID string`

32 

33 The identifier of the completed video.

34 

35### Returns

36 

37- `type Video struct{…}`

38 

39 Structured information describing a generated video job.

40 

41 - `ID string`

42 

43 Unique identifier for the video job.

44 

45 - `CompletedAt int64`

46 

47 Unix timestamp (seconds) for when the job completed, if finished.

48 

49 - `CreatedAt int64`

50 

51 Unix timestamp (seconds) for when the job was created.

52 

53 - `Error VideoCreateError`

54 

55 Error payload that explains why generation failed, if applicable.

56 

57 - `Code string`

58 

59 A machine-readable error code that was returned.

60 

61 - `Message string`

62 

63 A human-readable description of the error that was returned.

64 

65 - `ExpiresAt int64`

66 

67 Unix timestamp (seconds) for when the downloadable assets expire, if set.

68 

69 - `Model VideoModel`

70 

71 The video generation model that produced the job.

72 

73 - `string`

74 

75 - `type VideoModel string`

76 

77 - `const VideoModelSora2 VideoModel = "sora-2"`

78 

79 - `const VideoModelSora2Pro VideoModel = "sora-2-pro"`

80 

81 - `const VideoModelSora2_2025_10_06 VideoModel = "sora-2-2025-10-06"`

82 

83 - `const VideoModelSora2Pro2025_10_06 VideoModel = "sora-2-pro-2025-10-06"`

84 

85 - `const VideoModelSora2_2025_12_08 VideoModel = "sora-2-2025-12-08"`

86 

87 - `Object Video`

88 

89 The object type, which is always `video`.

90 

91 - `const VideoVideo Video = "video"`

92 

93 - `Progress int64`

94 

95 Approximate completion percentage for the generation task.

96 

97 - `Prompt string`

98 

99 The prompt that was used to generate the video.

100 

101 - `RemixedFromVideoID string`

102 

103 Identifier of the source video if this video is a remix.

104 

105 - `Seconds VideoSeconds`

106 

107 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

108 

109 - `string`

110 

111 - `type VideoSeconds string`

112 

113 - `const VideoSeconds4 VideoSeconds = "4"`

114 

115 - `const VideoSeconds8 VideoSeconds = "8"`

116 

117 - `const VideoSeconds12 VideoSeconds = "12"`

118 

119 - `Size VideoSize`

120 

121 The resolution of the generated video.

122 

123 - `const VideoSize720x1280 VideoSize = "720x1280"`

124 

125 - `const VideoSize1280x720 VideoSize = "1280x720"`

126 

127 - `const VideoSize1024x1792 VideoSize = "1024x1792"`

128 

129 - `const VideoSize1792x1024 VideoSize = "1792x1024"`

130 

131 - `Status VideoStatus`

132 

133 Current lifecycle status of the video job.

134 

135 - `const VideoStatusQueued VideoStatus = "queued"`

136 

137 - `const VideoStatusInProgress VideoStatus = "in_progress"`

138 

139 - `const VideoStatusCompleted VideoStatus = "completed"`

140 

141 - `const VideoStatusFailed VideoStatus = "failed"`

142 

143### Example

144 

145```go

146package main

147 

148import (

149 "bytes"

150 "context"

151 "fmt"

152 "io"

153 

154 "github.com/openai/openai-go"

155 "github.com/openai/openai-go/option"

156)

157 

158func main() {

159 client := openai.NewClient(

160 option.WithAPIKey("My API Key"),

161 )

162 video, err := client.Videos.Extend(context.TODO(), openai.VideoExtendParams{

163 Prompt: "x",

164 Seconds: openai.VideoSeconds4,

165 Video: openai.VideoExtendParamsVideoUnion{

166 OfFile: io.Reader(bytes.NewBuffer([]byte("Example data"))),

167 },

168 })

169 if err != nil {

170 panic(err.Error())

171 }

172 fmt.Printf("%+v\n", video.ID)

173}

174```

175 

176#### Response

177 

178```json

179{

180 "id": "id",

181 "completed_at": 0,

182 "created_at": 0,

183 "error": {

184 "code": "code",

185 "message": "message"

186 },

187 "expires_at": 0,

188 "model": "sora-2",

189 "object": "video",

190 "progress": 0,

191 "prompt": "prompt",

192 "remixed_from_video_id": "remixed_from_video_id",

193 "seconds": "4",

194 "size": "720x1280",

195 "status": "queued"

196}

197```

Details

1## List videos

2 

3`client.Videos.List(ctx, query) (*ConversationCursorPage[Video], error)`

4 

5**get** `/videos`

6 

7List recently generated videos for the current project.

8 

9### Parameters

10 

11- `query VideoListParams`

12 

13 - `After param.Field[string]`

14 

15 Identifier for the last item from the previous pagination request

16 

17 - `Limit param.Field[int64]`

18 

19 Number of items to retrieve

20 

21 - `Order param.Field[VideoListParamsOrder]`

22 

23 Sort order of results by timestamp. Use `asc` for ascending order or `desc` for descending order.

24 

25 - `const VideoListParamsOrderAsc VideoListParamsOrder = "asc"`

26 

27 - `const VideoListParamsOrderDesc VideoListParamsOrder = "desc"`

28 

29### Returns

30 

31- `type Video struct{…}`

32 

33 Structured information describing a generated video job.

34 

35 - `ID string`

36 

37 Unique identifier for the video job.

38 

39 - `CompletedAt int64`

40 

41 Unix timestamp (seconds) for when the job completed, if finished.

42 

43 - `CreatedAt int64`

44 

45 Unix timestamp (seconds) for when the job was created.

46 

47 - `Error VideoCreateError`

48 

49 Error payload that explains why generation failed, if applicable.

50 

51 - `Code string`

52 

53 A machine-readable error code that was returned.

54 

55 - `Message string`

56 

57 A human-readable description of the error that was returned.

58 

59 - `ExpiresAt int64`

60 

61 Unix timestamp (seconds) for when the downloadable assets expire, if set.

62 

63 - `Model VideoModel`

64 

65 The video generation model that produced the job.

66 

67 - `string`

68 

69 - `type VideoModel string`

70 

71 - `const VideoModelSora2 VideoModel = "sora-2"`

72 

73 - `const VideoModelSora2Pro VideoModel = "sora-2-pro"`

74 

75 - `const VideoModelSora2_2025_10_06 VideoModel = "sora-2-2025-10-06"`

76 

77 - `const VideoModelSora2Pro2025_10_06 VideoModel = "sora-2-pro-2025-10-06"`

78 

79 - `const VideoModelSora2_2025_12_08 VideoModel = "sora-2-2025-12-08"`

80 

81 - `Object Video`

82 

83 The object type, which is always `video`.

84 

85 - `const VideoVideo Video = "video"`

86 

87 - `Progress int64`

88 

89 Approximate completion percentage for the generation task.

90 

91 - `Prompt string`

92 

93 The prompt that was used to generate the video.

94 

95 - `RemixedFromVideoID string`

96 

97 Identifier of the source video if this video is a remix.

98 

99 - `Seconds VideoSeconds`

100 

101 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

102 

103 - `string`

104 

105 - `type VideoSeconds string`

106 

107 - `const VideoSeconds4 VideoSeconds = "4"`

108 

109 - `const VideoSeconds8 VideoSeconds = "8"`

110 

111 - `const VideoSeconds12 VideoSeconds = "12"`

112 

113 - `Size VideoSize`

114 

115 The resolution of the generated video.

116 

117 - `const VideoSize720x1280 VideoSize = "720x1280"`

118 

119 - `const VideoSize1280x720 VideoSize = "1280x720"`

120 

121 - `const VideoSize1024x1792 VideoSize = "1024x1792"`

122 

123 - `const VideoSize1792x1024 VideoSize = "1792x1024"`

124 

125 - `Status VideoStatus`

126 

127 Current lifecycle status of the video job.

128 

129 - `const VideoStatusQueued VideoStatus = "queued"`

130 

131 - `const VideoStatusInProgress VideoStatus = "in_progress"`

132 

133 - `const VideoStatusCompleted VideoStatus = "completed"`

134 

135 - `const VideoStatusFailed VideoStatus = "failed"`

136 

137### Example

138 

139```go

140package main

141 

142import (

143 "context"

144 "fmt"

145 

146 "github.com/openai/openai-go"

147 "github.com/openai/openai-go/option"

148)

149 

150func main() {

151 client := openai.NewClient(

152 option.WithAPIKey("My API Key"),

153 )

154 page, err := client.Videos.List(context.TODO(), openai.VideoListParams{

155 

156 })

157 if err != nil {

158 panic(err.Error())

159 }

160 fmt.Printf("%+v\n", page)

161}

162```

163 

164#### Response

165 

166```json

167{

168 "data": [

169 {

170 "id": "id",

171 "completed_at": 0,

172 "created_at": 0,

173 "error": {

174 "code": "code",

175 "message": "message"

176 },

177 "expires_at": 0,

178 "model": "sora-2",

179 "object": "video",

180 "progress": 0,

181 "prompt": "prompt",

182 "remixed_from_video_id": "remixed_from_video_id",

183 "seconds": "4",

184 "size": "720x1280",

185 "status": "queued"

186 }

187 ],

188 "first_id": "first_id",

189 "has_more": true,

190 "last_id": "last_id",

191 "object": "list"

192}

193```

194 

195### Example

196 

197```go

198package main

199 

200import (

201 "context"

202 "fmt"

203 

204 "github.com/openai/openai-go"

205)

206 

207func main() {

208 client := openai.NewClient()

209 page, err := client.Videos.List(context.TODO(), openai.VideoListParams{

210 

211 })

212 if err != nil {

213 panic(err.Error())

214 }

215 fmt.Printf("%+v\n", page)

216}

217```

218 

219#### Response

220 

221```json

222{

223 "data": [

224 {

225 "id": "video_123",

226 "object": "video",

227 "model": "sora-2",

228 "status": "completed"

229 }

230 ],

231 "object": "list"

232}

233```

Details

1## Remix video

2 

3`client.Videos.Remix(ctx, videoID, body) (*Video, error)`

4 

5**post** `/videos/{video_id}/remix`

6 

7Create a remix of a completed video using a refreshed prompt.

8 

9### Parameters

10 

11- `videoID string`

12 

13- `body VideoRemixParams`

14 

15 - `Prompt param.Field[string]`

16 

17 Updated text prompt that directs the remix generation.

18 

19### Returns

20 

21- `type Video struct{…}`

22 

23 Structured information describing a generated video job.

24 

25 - `ID string`

26 

27 Unique identifier for the video job.

28 

29 - `CompletedAt int64`

30 

31 Unix timestamp (seconds) for when the job completed, if finished.

32 

33 - `CreatedAt int64`

34 

35 Unix timestamp (seconds) for when the job was created.

36 

37 - `Error VideoCreateError`

38 

39 Error payload that explains why generation failed, if applicable.

40 

41 - `Code string`

42 

43 A machine-readable error code that was returned.

44 

45 - `Message string`

46 

47 A human-readable description of the error that was returned.

48 

49 - `ExpiresAt int64`

50 

51 Unix timestamp (seconds) for when the downloadable assets expire, if set.

52 

53 - `Model VideoModel`

54 

55 The video generation model that produced the job.

56 

57 - `string`

58 

59 - `type VideoModel string`

60 

61 - `const VideoModelSora2 VideoModel = "sora-2"`

62 

63 - `const VideoModelSora2Pro VideoModel = "sora-2-pro"`

64 

65 - `const VideoModelSora2_2025_10_06 VideoModel = "sora-2-2025-10-06"`

66 

67 - `const VideoModelSora2Pro2025_10_06 VideoModel = "sora-2-pro-2025-10-06"`

68 

69 - `const VideoModelSora2_2025_12_08 VideoModel = "sora-2-2025-12-08"`

70 

71 - `Object Video`

72 

73 The object type, which is always `video`.

74 

75 - `const VideoVideo Video = "video"`

76 

77 - `Progress int64`

78 

79 Approximate completion percentage for the generation task.

80 

81 - `Prompt string`

82 

83 The prompt that was used to generate the video.

84 

85 - `RemixedFromVideoID string`

86 

87 Identifier of the source video if this video is a remix.

88 

89 - `Seconds VideoSeconds`

90 

91 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

92 

93 - `string`

94 

95 - `type VideoSeconds string`

96 

97 - `const VideoSeconds4 VideoSeconds = "4"`

98 

99 - `const VideoSeconds8 VideoSeconds = "8"`

100 

101 - `const VideoSeconds12 VideoSeconds = "12"`

102 

103 - `Size VideoSize`

104 

105 The resolution of the generated video.

106 

107 - `const VideoSize720x1280 VideoSize = "720x1280"`

108 

109 - `const VideoSize1280x720 VideoSize = "1280x720"`

110 

111 - `const VideoSize1024x1792 VideoSize = "1024x1792"`

112 

113 - `const VideoSize1792x1024 VideoSize = "1792x1024"`

114 

115 - `Status VideoStatus`

116 

117 Current lifecycle status of the video job.

118 

119 - `const VideoStatusQueued VideoStatus = "queued"`

120 

121 - `const VideoStatusInProgress VideoStatus = "in_progress"`

122 

123 - `const VideoStatusCompleted VideoStatus = "completed"`

124 

125 - `const VideoStatusFailed VideoStatus = "failed"`

126 

127### Example

128 

129```go

130package main

131 

132import (

133 "context"

134 "fmt"

135 

136 "github.com/openai/openai-go"

137 "github.com/openai/openai-go/option"

138)

139 

140func main() {

141 client := openai.NewClient(

142 option.WithAPIKey("My API Key"),

143 )

144 video, err := client.Videos.Remix(

145 context.TODO(),

146 "video_123",

147 openai.VideoRemixParams{

148 Prompt: "x",

149 },

150 )

151 if err != nil {

152 panic(err.Error())

153 }

154 fmt.Printf("%+v\n", video.ID)

155}

156```

157 

158#### Response

159 

160```json

161{

162 "id": "id",

163 "completed_at": 0,

164 "created_at": 0,

165 "error": {

166 "code": "code",

167 "message": "message"

168 },

169 "expires_at": 0,

170 "model": "sora-2",

171 "object": "video",

172 "progress": 0,

173 "prompt": "prompt",

174 "remixed_from_video_id": "remixed_from_video_id",

175 "seconds": "4",

176 "size": "720x1280",

177 "status": "queued"

178}

179```

180 

181### Example

182 

183```go

184package main

185 

186import (

187 "context"

188 "fmt"

189 

190 "github.com/openai/openai-go"

191)

192 

193func main() {

194 client := openai.NewClient()

195 video, err := client.Videos.Remix(

196 context.TODO(),

197 "video_123",

198 openai.VideoRemixParams{

199 Prompt: "Extend the scene with the cat taking a bow to the cheering audience",

200 },

201 )

202 if err != nil {

203 panic(err.Error())

204 }

205 fmt.Printf("%+v\n", video.ID)

206}

207```

208 

209#### Response

210 

211```json

212{

213 "id": "video_456",

214 "object": "video",

215 "model": "sora-2",

216 "status": "queued",

217 "progress": 0,

218 "created_at": 1712698600,

219 "size": "720x1280",

220 "seconds": "8",

221 "remixed_from_video_id": "video_123"

222}

223```

Details

1## Retrieve video

2 

3`client.Videos.Get(ctx, videoID) (*Video, error)`

4 

5**get** `/videos/{video_id}`

6 

7Fetch the latest metadata for a generated video.

8 

9### Parameters

10 

11- `videoID string`

12 

13### Returns

14 

15- `type Video struct{…}`

16 

17 Structured information describing a generated video job.

18 

19 - `ID string`

20 

21 Unique identifier for the video job.

22 

23 - `CompletedAt int64`

24 

25 Unix timestamp (seconds) for when the job completed, if finished.

26 

27 - `CreatedAt int64`

28 

29 Unix timestamp (seconds) for when the job was created.

30 

31 - `Error VideoCreateError`

32 

33 Error payload that explains why generation failed, if applicable.

34 

35 - `Code string`

36 

37 A machine-readable error code that was returned.

38 

39 - `Message string`

40 

41 A human-readable description of the error that was returned.

42 

43 - `ExpiresAt int64`

44 

45 Unix timestamp (seconds) for when the downloadable assets expire, if set.

46 

47 - `Model VideoModel`

48 

49 The video generation model that produced the job.

50 

51 - `string`

52 

53 - `type VideoModel string`

54 

55 - `const VideoModelSora2 VideoModel = "sora-2"`

56 

57 - `const VideoModelSora2Pro VideoModel = "sora-2-pro"`

58 

59 - `const VideoModelSora2_2025_10_06 VideoModel = "sora-2-2025-10-06"`

60 

61 - `const VideoModelSora2Pro2025_10_06 VideoModel = "sora-2-pro-2025-10-06"`

62 

63 - `const VideoModelSora2_2025_12_08 VideoModel = "sora-2-2025-12-08"`

64 

65 - `Object Video`

66 

67 The object type, which is always `video`.

68 

69 - `const VideoVideo Video = "video"`

70 

71 - `Progress int64`

72 

73 Approximate completion percentage for the generation task.

74 

75 - `Prompt string`

76 

77 The prompt that was used to generate the video.

78 

79 - `RemixedFromVideoID string`

80 

81 Identifier of the source video if this video is a remix.

82 

83 - `Seconds VideoSeconds`

84 

85 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

86 

87 - `string`

88 

89 - `type VideoSeconds string`

90 

91 - `const VideoSeconds4 VideoSeconds = "4"`

92 

93 - `const VideoSeconds8 VideoSeconds = "8"`

94 

95 - `const VideoSeconds12 VideoSeconds = "12"`

96 

97 - `Size VideoSize`

98 

99 The resolution of the generated video.

100 

101 - `const VideoSize720x1280 VideoSize = "720x1280"`

102 

103 - `const VideoSize1280x720 VideoSize = "1280x720"`

104 

105 - `const VideoSize1024x1792 VideoSize = "1024x1792"`

106 

107 - `const VideoSize1792x1024 VideoSize = "1792x1024"`

108 

109 - `Status VideoStatus`

110 

111 Current lifecycle status of the video job.

112 

113 - `const VideoStatusQueued VideoStatus = "queued"`

114 

115 - `const VideoStatusInProgress VideoStatus = "in_progress"`

116 

117 - `const VideoStatusCompleted VideoStatus = "completed"`

118 

119 - `const VideoStatusFailed VideoStatus = "failed"`

120 

121### Example

122 

123```go

124package main

125 

126import (

127 "context"

128 "fmt"

129 

130 "github.com/openai/openai-go"

131 "github.com/openai/openai-go/option"

132)

133 

134func main() {

135 client := openai.NewClient(

136 option.WithAPIKey("My API Key"),

137 )

138 video, err := client.Videos.Get(context.TODO(), "video_123")

139 if err != nil {

140 panic(err.Error())

141 }

142 fmt.Printf("%+v\n", video.ID)

143}

144```

145 

146#### Response

147 

148```json

149{

150 "id": "id",

151 "completed_at": 0,

152 "created_at": 0,

153 "error": {

154 "code": "code",

155 "message": "message"

156 },

157 "expires_at": 0,

158 "model": "sora-2",

159 "object": "video",

160 "progress": 0,

161 "prompt": "prompt",

162 "remixed_from_video_id": "remixed_from_video_id",

163 "seconds": "4",

164 "size": "720x1280",

165 "status": "queued"

166}

167```

168 

169### Example

170 

171```go

172package main

173 

174import (

175 "context"

176 "fmt"

177 

178 "github.com/openai/openai-go"

179)

180 

181func main() {

182 client := openai.NewClient()

183 video, err := client.Videos.Get(context.TODO(), "video_123")

184 if err != nil {

185 panic(err.Error())

186 }

187 fmt.Printf("%+v\n", video.ID)

188}

189```

index.md +741 −0 created

Details

1# API Reference

2 

3## [Shared](/api/reference/resources/$shared/index.md)

4 

5## [Completions](/api/reference/resources/completions/index.md)

6 

7- [Create](/api/reference/resources/completions/methods/create/index.md)

8 

9## [Chat](/api/reference/resources/chat/index.md)

10 

11- [Completions](/api/reference/resources/chat/subresources/completions/index.md)

12 

13 - [Create](/api/reference/resources/chat/subresources/completions/methods/create/index.md)

14 

15 - [List](/api/reference/resources/chat/subresources/completions/methods/list/index.md)

16 

17 - [Retrieve](/api/reference/resources/chat/subresources/completions/methods/retrieve/index.md)

18 

19 - [Update](/api/reference/resources/chat/subresources/completions/methods/update/index.md)

20 

21 - [Delete](/api/reference/resources/chat/subresources/completions/methods/delete/index.md)

22 

23 - [Messages](/api/reference/resources/chat/subresources/completions/subresources/messages/index.md)

24 

25 - [List](/api/reference/resources/chat/subresources/completions/subresources/messages/methods/list/index.md)

26 

27## [Embeddings](/api/reference/resources/embeddings/index.md)

28 

29- [Create](/api/reference/resources/embeddings/methods/create/index.md)

30 

31## [Files](/api/reference/resources/files/index.md)

32 

33- [List](/api/reference/resources/files/methods/list/index.md)

34 

35- [Create](/api/reference/resources/files/methods/create/index.md)

36 

37- [Delete](/api/reference/resources/files/methods/delete/index.md)

38 

39- [Retrieve](/api/reference/resources/files/methods/retrieve/index.md)

40 

41- [Content](/api/reference/resources/files/methods/content/index.md)

42 

43- [Retrieve Content](/api/reference/resources/files/methods/retrieve_content/index.md)

44 

45## [Images](/api/reference/resources/images/index.md)

46 

47- [Generate](/api/reference/resources/images/methods/generate/index.md)

48 

49- [Edit](/api/reference/resources/images/methods/edit/index.md)

50 

51- [Create Variation](/api/reference/resources/images/methods/create_variation/index.md)

52 

53## [Audio](/api/reference/resources/audio/index.md)

54 

55- [Transcriptions](/api/reference/resources/audio/subresources/transcriptions/index.md)

56 

57 - [Create](/api/reference/resources/audio/subresources/transcriptions/methods/create/index.md)

58 

59- [Translations](/api/reference/resources/audio/subresources/translations/index.md)

60 

61 - [Create](/api/reference/resources/audio/subresources/translations/methods/create/index.md)

62 

63- [Speech](/api/reference/resources/audio/subresources/speech/index.md)

64 

65 - [Create](/api/reference/resources/audio/subresources/speech/methods/create/index.md)

66 

67- [Voices](/api/reference/resources/audio/subresources/voices/index.md)

68 

69 - [Create](/api/reference/resources/audio/subresources/voices/methods/create/index.md)

70 

71- [Voice Consents](/api/reference/resources/audio/subresources/voice_consents/index.md)

72 

73 - [List](/api/reference/resources/audio/subresources/voice_consents/methods/list/index.md)

74 

75 - [Create](/api/reference/resources/audio/subresources/voice_consents/methods/create/index.md)

76 

77 - [Retrieve](/api/reference/resources/audio/subresources/voice_consents/methods/retrieve/index.md)

78 

79 - [Update](/api/reference/resources/audio/subresources/voice_consents/methods/update/index.md)

80 

81 - [Delete](/api/reference/resources/audio/subresources/voice_consents/methods/delete/index.md)

82 

83## [Moderations](/api/reference/resources/moderations/index.md)

84 

85- [Create](/api/reference/resources/moderations/methods/create/index.md)

86 

87## [Models](/api/reference/resources/models/index.md)

88 

89- [List](/api/reference/resources/models/methods/list/index.md)

90 

91- [Retrieve](/api/reference/resources/models/methods/retrieve/index.md)

92 

93- [Delete](/api/reference/resources/models/methods/delete/index.md)

94 

95## [Fine Tuning](/api/reference/resources/fine_tuning/index.md)

96 

97- [Methods](/api/reference/resources/fine_tuning/subresources/methods/index.md)

98 

99- [Jobs](/api/reference/resources/fine_tuning/subresources/jobs/index.md)

100 

101 - [Create](/api/reference/resources/fine_tuning/subresources/jobs/methods/create/index.md)

102 

103 - [List](/api/reference/resources/fine_tuning/subresources/jobs/methods/list/index.md)

104 

105 - [Retrieve](/api/reference/resources/fine_tuning/subresources/jobs/methods/retrieve/index.md)

106 

107 - [List Events](/api/reference/resources/fine_tuning/subresources/jobs/methods/list_events/index.md)

108 

109 - [Cancel](/api/reference/resources/fine_tuning/subresources/jobs/methods/cancel/index.md)

110 

111 - [Pause](/api/reference/resources/fine_tuning/subresources/jobs/methods/pause/index.md)

112 

113 - [Resume](/api/reference/resources/fine_tuning/subresources/jobs/methods/resume/index.md)

114 

115 - [Checkpoints](/api/reference/resources/fine_tuning/subresources/jobs/subresources/checkpoints/index.md)

116 

117 - [List](/api/reference/resources/fine_tuning/subresources/jobs/subresources/checkpoints/methods/list/index.md)

118 

119- [Checkpoints](/api/reference/resources/fine_tuning/subresources/checkpoints/index.md)

120 

121 - [Permissions](/api/reference/resources/fine_tuning/subresources/checkpoints/subresources/permissions/index.md)

122 

123 - [Retrieve](/api/reference/resources/fine_tuning/subresources/checkpoints/subresources/permissions/methods/retrieve/index.md)

124 

125 - [List](/api/reference/resources/fine_tuning/subresources/checkpoints/subresources/permissions/methods/list/index.md)

126 

127 - [Create](/api/reference/resources/fine_tuning/subresources/checkpoints/subresources/permissions/methods/create/index.md)

128 

129 - [Delete](/api/reference/resources/fine_tuning/subresources/checkpoints/subresources/permissions/methods/delete/index.md)

130 

131- [Alpha](/api/reference/resources/fine_tuning/subresources/alpha/index.md)

132 

133 - [Graders](/api/reference/resources/fine_tuning/subresources/alpha/subresources/graders/index.md)

134 

135 - [Run](/api/reference/resources/fine_tuning/subresources/alpha/subresources/graders/methods/run/index.md)

136 

137 - [Validate](/api/reference/resources/fine_tuning/subresources/alpha/subresources/graders/methods/validate/index.md)

138 

139## [Graders](/api/reference/resources/graders/index.md)

140 

141- [Grader Models](/api/reference/resources/graders/subresources/grader_models/index.md)

142 

143## [Vector Stores](/api/reference/resources/vector_stores/index.md)

144 

145- [List](/api/reference/resources/vector_stores/methods/list/index.md)

146 

147- [Create](/api/reference/resources/vector_stores/methods/create/index.md)

148 

149- [Retrieve](/api/reference/resources/vector_stores/methods/retrieve/index.md)

150 

151- [Update](/api/reference/resources/vector_stores/methods/update/index.md)

152 

153- [Delete](/api/reference/resources/vector_stores/methods/delete/index.md)

154 

155- [Search](/api/reference/resources/vector_stores/methods/search/index.md)

156 

157- [Files](/api/reference/resources/vector_stores/subresources/files/index.md)

158 

159 - [List](/api/reference/resources/vector_stores/subresources/files/methods/list/index.md)

160 

161 - [Create](/api/reference/resources/vector_stores/subresources/files/methods/create/index.md)

162 

163 - [Update](/api/reference/resources/vector_stores/subresources/files/methods/update/index.md)

164 

165 - [Retrieve](/api/reference/resources/vector_stores/subresources/files/methods/retrieve/index.md)

166 

167 - [Delete](/api/reference/resources/vector_stores/subresources/files/methods/delete/index.md)

168 

169 - [Content](/api/reference/resources/vector_stores/subresources/files/methods/content/index.md)

170 

171- [File Batches](/api/reference/resources/vector_stores/subresources/file_batches/index.md)

172 

173 - [Create](/api/reference/resources/vector_stores/subresources/file_batches/methods/create/index.md)

174 

175 - [Retrieve](/api/reference/resources/vector_stores/subresources/file_batches/methods/retrieve/index.md)

176 

177 - [Cancel](/api/reference/resources/vector_stores/subresources/file_batches/methods/cancel/index.md)

178 

179 - [List Files](/api/reference/resources/vector_stores/subresources/file_batches/methods/list_files/index.md)

180 

181## [Webhooks](/api/reference/resources/webhooks/index.md)

182 

183- [Unwrap](/api/reference/resources/webhooks/methods/unwrap/index.md)

184 

185## [Beta](/api/reference/resources/beta/index.md)

186 

187- [ChatKit](/api/reference/resources/beta/subresources/chatkit/index.md)

188 

189 - [Sessions](/api/reference/resources/beta/subresources/chatkit/subresources/sessions/index.md)

190 

191 - [Cancel](/api/reference/resources/beta/subresources/chatkit/subresources/sessions/methods/cancel/index.md)

192 

193 - [Create](/api/reference/resources/beta/subresources/chatkit/subresources/sessions/methods/create/index.md)

194 

195 - [Threads](/api/reference/resources/beta/subresources/chatkit/subresources/threads/index.md)

196 

197 - [List Items](/api/reference/resources/beta/subresources/chatkit/subresources/threads/methods/list_items/index.md)

198 

199 - [Retrieve](/api/reference/resources/beta/subresources/chatkit/subresources/threads/methods/retrieve/index.md)

200 

201 - [Delete](/api/reference/resources/beta/subresources/chatkit/subresources/threads/methods/delete/index.md)

202 

203 - [List](/api/reference/resources/beta/subresources/chatkit/subresources/threads/methods/list/index.md)

204 

205- [Assistants](/api/reference/resources/beta/subresources/assistants/index.md)

206 

207 - [List](/api/reference/resources/beta/subresources/assistants/methods/list/index.md)

208 

209 - [Create](/api/reference/resources/beta/subresources/assistants/methods/create/index.md)

210 

211 - [Retrieve](/api/reference/resources/beta/subresources/assistants/methods/retrieve/index.md)

212 

213 - [Update](/api/reference/resources/beta/subresources/assistants/methods/update/index.md)

214 

215 - [Delete](/api/reference/resources/beta/subresources/assistants/methods/delete/index.md)

216 

217- [Threads](/api/reference/resources/beta/subresources/threads/index.md)

218 

219 - [Create](/api/reference/resources/beta/subresources/threads/methods/create/index.md)

220 

221 - [Create And Run](/api/reference/resources/beta/subresources/threads/methods/create_and_run/index.md)

222 

223 - [Retrieve](/api/reference/resources/beta/subresources/threads/methods/retrieve/index.md)

224 

225 - [Update](/api/reference/resources/beta/subresources/threads/methods/update/index.md)

226 

227 - [Delete](/api/reference/resources/beta/subresources/threads/methods/delete/index.md)

228 

229 - [Runs](/api/reference/resources/beta/subresources/threads/subresources/runs/index.md)

230 

231 - [List](/api/reference/resources/beta/subresources/threads/subresources/runs/methods/list/index.md)

232 

233 - [Create](/api/reference/resources/beta/subresources/threads/subresources/runs/methods/create/index.md)

234 

235 - [Retrieve](/api/reference/resources/beta/subresources/threads/subresources/runs/methods/retrieve/index.md)

236 

237 - [Update](/api/reference/resources/beta/subresources/threads/subresources/runs/methods/update/index.md)

238 

239 - [Submit Tool Outputs](/api/reference/resources/beta/subresources/threads/subresources/runs/methods/submit_tool_outputs/index.md)

240 

241 - [Cancel](/api/reference/resources/beta/subresources/threads/subresources/runs/methods/cancel/index.md)

242 

243 - [Steps](/api/reference/resources/beta/subresources/threads/subresources/runs/subresources/steps/index.md)

244 

245 - [List](/api/reference/resources/beta/subresources/threads/subresources/runs/subresources/steps/methods/list/index.md)

246 

247 - [Retrieve](/api/reference/resources/beta/subresources/threads/subresources/runs/subresources/steps/methods/retrieve/index.md)

248 

249 - [Messages](/api/reference/resources/beta/subresources/threads/subresources/messages/index.md)

250 

251 - [List](/api/reference/resources/beta/subresources/threads/subresources/messages/methods/list/index.md)

252 

253 - [Create](/api/reference/resources/beta/subresources/threads/subresources/messages/methods/create/index.md)

254 

255 - [Update](/api/reference/resources/beta/subresources/threads/subresources/messages/methods/update/index.md)

256 

257 - [Retrieve](/api/reference/resources/beta/subresources/threads/subresources/messages/methods/retrieve/index.md)

258 

259 - [Delete](/api/reference/resources/beta/subresources/threads/subresources/messages/methods/delete/index.md)

260 

261## [Batches](/api/reference/resources/batches/index.md)

262 

263- [Create](/api/reference/resources/batches/methods/create/index.md)

264 

265- [Retrieve](/api/reference/resources/batches/methods/retrieve/index.md)

266 

267- [Cancel](/api/reference/resources/batches/methods/cancel/index.md)

268 

269- [List](/api/reference/resources/batches/methods/list/index.md)

270 

271## [Uploads](/api/reference/resources/uploads/index.md)

272 

273- [Create](/api/reference/resources/uploads/methods/create/index.md)

274 

275- [Complete](/api/reference/resources/uploads/methods/complete/index.md)

276 

277- [Cancel](/api/reference/resources/uploads/methods/cancel/index.md)

278 

279- [Parts](/api/reference/resources/uploads/subresources/parts/index.md)

280 

281 - [Create](/api/reference/resources/uploads/subresources/parts/methods/create/index.md)

282 

283## [Admin](/api/reference/resources/admin/index.md)

284 

285- [Organization](/api/reference/resources/admin/subresources/organization/index.md)

286 

287 - [Audit Logs](/api/reference/resources/admin/subresources/organization/subresources/audit_logs/index.md)

288 

289 - [List](/api/reference/resources/admin/subresources/organization/subresources/audit_logs/methods/list/index.md)

290 

291 - [Admin API Keys](/api/reference/resources/admin/subresources/organization/subresources/admin_api_keys/index.md)

292 

293 - [List](/api/reference/resources/admin/subresources/organization/subresources/admin_api_keys/methods/list/index.md)

294 

295 - [Create](/api/reference/resources/admin/subresources/organization/subresources/admin_api_keys/methods/create/index.md)

296 

297 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/admin_api_keys/methods/retrieve/index.md)

298 

299 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/admin_api_keys/methods/delete/index.md)

300 

301 - [Usage](/api/reference/resources/admin/subresources/organization/subresources/usage/index.md)

302 

303 - [Audio Speeches](/api/reference/resources/admin/subresources/organization/subresources/usage/methods/audio_speeches/index.md)

304 

305 - [Audio Transcriptions](/api/reference/resources/admin/subresources/organization/subresources/usage/methods/audio_transcriptions/index.md)

306 

307 - [Code Interpreter Sessions](/api/reference/resources/admin/subresources/organization/subresources/usage/methods/code_interpreter_sessions/index.md)

308 

309 - [Completions](/api/reference/resources/admin/subresources/organization/subresources/usage/methods/completions/index.md)

310 

311 - [Embeddings](/api/reference/resources/admin/subresources/organization/subresources/usage/methods/embeddings/index.md)

312 

313 - [Images](/api/reference/resources/admin/subresources/organization/subresources/usage/methods/images/index.md)

314 

315 - [Moderations](/api/reference/resources/admin/subresources/organization/subresources/usage/methods/moderations/index.md)

316 

317 - [Vector Stores](/api/reference/resources/admin/subresources/organization/subresources/usage/methods/vector_stores/index.md)

318 

319 - [File Search Calls](/api/reference/resources/admin/subresources/organization/subresources/usage/methods/file_search_calls/index.md)

320 

321 - [Web Search Calls](/api/reference/resources/admin/subresources/organization/subresources/usage/methods/web_search_calls/index.md)

322 

323 - [Costs](/api/reference/resources/admin/subresources/organization/subresources/usage/methods/costs/index.md)

324 

325 - [Invites](/api/reference/resources/admin/subresources/organization/subresources/invites/index.md)

326 

327 - [List](/api/reference/resources/admin/subresources/organization/subresources/invites/methods/list/index.md)

328 

329 - [Create](/api/reference/resources/admin/subresources/organization/subresources/invites/methods/create/index.md)

330 

331 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/invites/methods/retrieve/index.md)

332 

333 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/invites/methods/delete/index.md)

334 

335 - [Users](/api/reference/resources/admin/subresources/organization/subresources/users/index.md)

336 

337 - [List](/api/reference/resources/admin/subresources/organization/subresources/users/methods/list/index.md)

338 

339 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/users/methods/retrieve/index.md)

340 

341 - [Update](/api/reference/resources/admin/subresources/organization/subresources/users/methods/update/index.md)

342 

343 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/users/methods/delete/index.md)

344 

345 - [Roles](/api/reference/resources/admin/subresources/organization/subresources/users/subresources/roles/index.md)

346 

347 - [List](/api/reference/resources/admin/subresources/organization/subresources/users/subresources/roles/methods/list/index.md)

348 

349 - [Create](/api/reference/resources/admin/subresources/organization/subresources/users/subresources/roles/methods/create/index.md)

350 

351 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/users/subresources/roles/methods/retrieve/index.md)

352 

353 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/users/subresources/roles/methods/delete/index.md)

354 

355 - [Groups](/api/reference/resources/admin/subresources/organization/subresources/groups/index.md)

356 

357 - [List](/api/reference/resources/admin/subresources/organization/subresources/groups/methods/list/index.md)

358 

359 - [Create](/api/reference/resources/admin/subresources/organization/subresources/groups/methods/create/index.md)

360 

361 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/groups/methods/retrieve/index.md)

362 

363 - [Update](/api/reference/resources/admin/subresources/organization/subresources/groups/methods/update/index.md)

364 

365 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/groups/methods/delete/index.md)

366 

367 - [Users](/api/reference/resources/admin/subresources/organization/subresources/groups/subresources/users/index.md)

368 

369 - [List](/api/reference/resources/admin/subresources/organization/subresources/groups/subresources/users/methods/list/index.md)

370 

371 - [Create](/api/reference/resources/admin/subresources/organization/subresources/groups/subresources/users/methods/create/index.md)

372 

373 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/groups/subresources/users/methods/retrieve/index.md)

374 

375 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/groups/subresources/users/methods/delete/index.md)

376 

377 - [Roles](/api/reference/resources/admin/subresources/organization/subresources/groups/subresources/roles/index.md)

378 

379 - [List](/api/reference/resources/admin/subresources/organization/subresources/groups/subresources/roles/methods/list/index.md)

380 

381 - [Create](/api/reference/resources/admin/subresources/organization/subresources/groups/subresources/roles/methods/create/index.md)

382 

383 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/groups/subresources/roles/methods/retrieve/index.md)

384 

385 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/groups/subresources/roles/methods/delete/index.md)

386 

387 - [Roles](/api/reference/resources/admin/subresources/organization/subresources/roles/index.md)

388 

389 - [List](/api/reference/resources/admin/subresources/organization/subresources/roles/methods/list/index.md)

390 

391 - [Create](/api/reference/resources/admin/subresources/organization/subresources/roles/methods/create/index.md)

392 

393 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/roles/methods/retrieve/index.md)

394 

395 - [Update](/api/reference/resources/admin/subresources/organization/subresources/roles/methods/update/index.md)

396 

397 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/roles/methods/delete/index.md)

398 

399 - [Data Retention](/api/reference/resources/admin/subresources/organization/subresources/data_retention/index.md)

400 

401 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/data_retention/methods/retrieve/index.md)

402 

403 - [Update](/api/reference/resources/admin/subresources/organization/subresources/data_retention/methods/update/index.md)

404 

405 - [Spend Alerts](/api/reference/resources/admin/subresources/organization/subresources/spend_alerts/index.md)

406 

407 - [List](/api/reference/resources/admin/subresources/organization/subresources/spend_alerts/methods/list/index.md)

408 

409 - [Create](/api/reference/resources/admin/subresources/organization/subresources/spend_alerts/methods/create/index.md)

410 

411 - [Update](/api/reference/resources/admin/subresources/organization/subresources/spend_alerts/methods/update/index.md)

412 

413 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/spend_alerts/methods/delete/index.md)

414 

415 - [Certificates](/api/reference/resources/admin/subresources/organization/subresources/certificates/index.md)

416 

417 - [List](/api/reference/resources/admin/subresources/organization/subresources/certificates/methods/list/index.md)

418 

419 - [Create](/api/reference/resources/admin/subresources/organization/subresources/certificates/methods/create/index.md)

420 

421 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/certificates/methods/retrieve/index.md)

422 

423 - [Update](/api/reference/resources/admin/subresources/organization/subresources/certificates/methods/update/index.md)

424 

425 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/certificates/methods/delete/index.md)

426 

427 - [Activate](/api/reference/resources/admin/subresources/organization/subresources/certificates/methods/activate/index.md)

428 

429 - [Deactivate](/api/reference/resources/admin/subresources/organization/subresources/certificates/methods/deactivate/index.md)

430 

431 - [Projects](/api/reference/resources/admin/subresources/organization/subresources/projects/index.md)

432 

433 - [List](/api/reference/resources/admin/subresources/organization/subresources/projects/methods/list/index.md)

434 

435 - [Create](/api/reference/resources/admin/subresources/organization/subresources/projects/methods/create/index.md)

436 

437 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/projects/methods/retrieve/index.md)

438 

439 - [Update](/api/reference/resources/admin/subresources/organization/subresources/projects/methods/update/index.md)

440 

441 - [Archive](/api/reference/resources/admin/subresources/organization/subresources/projects/methods/archive/index.md)

442 

443 - [Users](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/users/index.md)

444 

445 - [List](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/users/methods/list/index.md)

446 

447 - [Create](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/users/methods/create/index.md)

448 

449 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/users/methods/retrieve/index.md)

450 

451 - [Update](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/users/methods/update/index.md)

452 

453 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/users/methods/delete/index.md)

454 

455 - [Roles](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/users/subresources/roles/index.md)

456 

457 - [List](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/users/subresources/roles/methods/list/index.md)

458 

459 - [Create](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/users/subresources/roles/methods/create/index.md)

460 

461 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/users/subresources/roles/methods/retrieve/index.md)

462 

463 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/users/subresources/roles/methods/delete/index.md)

464 

465 - [Service Accounts](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/service_accounts/index.md)

466 

467 - [List](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/service_accounts/methods/list/index.md)

468 

469 - [Create](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/service_accounts/methods/create/index.md)

470 

471 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/service_accounts/methods/retrieve/index.md)

472 

473 - [Update](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/service_accounts/methods/update/index.md)

474 

475 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/service_accounts/methods/delete/index.md)

476 

477 - [API Keys](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/api_keys/index.md)

478 

479 - [List](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/api_keys/methods/list/index.md)

480 

481 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/api_keys/methods/retrieve/index.md)

482 

483 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/api_keys/methods/delete/index.md)

484 

485 - [Rate Limits](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/rate_limits/index.md)

486 

487 - [List Rate Limits](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/rate_limits/methods/list_rate_limits/index.md)

488 

489 - [Update Rate Limit](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/rate_limits/methods/update_rate_limit/index.md)

490 

491 - [Model Permissions](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/model_permissions/index.md)

492 

493 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/model_permissions/methods/retrieve/index.md)

494 

495 - [Update](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/model_permissions/methods/update/index.md)

496 

497 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/model_permissions/methods/delete/index.md)

498 

499 - [Hosted Tool Permissions](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/hosted_tool_permissions/index.md)

500 

501 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/hosted_tool_permissions/methods/retrieve/index.md)

502 

503 - [Update](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/hosted_tool_permissions/methods/update/index.md)

504 

505 - [Groups](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/groups/index.md)

506 

507 - [List](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/groups/methods/list/index.md)

508 

509 - [Create](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/groups/methods/create/index.md)

510 

511 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/groups/methods/retrieve/index.md)

512 

513 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/groups/methods/delete/index.md)

514 

515 - [Roles](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/groups/subresources/roles/index.md)

516 

517 - [List](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/groups/subresources/roles/methods/list/index.md)

518 

519 - [Create](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/groups/subresources/roles/methods/create/index.md)

520 

521 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/groups/subresources/roles/methods/retrieve/index.md)

522 

523 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/groups/subresources/roles/methods/delete/index.md)

524 

525 - [Roles](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/roles/index.md)

526 

527 - [List](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/roles/methods/list/index.md)

528 

529 - [Create](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/roles/methods/create/index.md)

530 

531 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/roles/methods/retrieve/index.md)

532 

533 - [Update](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/roles/methods/update/index.md)

534 

535 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/roles/methods/delete/index.md)

536 

537 - [Data Retention](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/data_retention/index.md)

538 

539 - [Retrieve](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/data_retention/methods/retrieve/index.md)

540 

541 - [Update](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/data_retention/methods/update/index.md)

542 

543 - [Spend Alerts](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/spend_alerts/index.md)

544 

545 - [List](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/spend_alerts/methods/list/index.md)

546 

547 - [Create](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/spend_alerts/methods/create/index.md)

548 

549 - [Update](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/spend_alerts/methods/update/index.md)

550 

551 - [Delete](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/spend_alerts/methods/delete/index.md)

552 

553 - [Certificates](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/certificates/index.md)

554 

555 - [List](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/certificates/methods/list/index.md)

556 

557 - [Activate](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/certificates/methods/activate/index.md)

558 

559 - [Deactivate](/api/reference/resources/admin/subresources/organization/subresources/projects/subresources/certificates/methods/deactivate/index.md)

560 

561## [Responses](/api/reference/resources/responses/index.md)

562 

563- [Connect](/api/reference/resources/responses/methods/connect/index.md)

564 

565- [Create](/api/reference/resources/responses/methods/create/index.md)

566 

567- [Retrieve](/api/reference/resources/responses/methods/retrieve/index.md)

568 

569- [Delete](/api/reference/resources/responses/methods/delete/index.md)

570 

571- [Cancel](/api/reference/resources/responses/methods/cancel/index.md)

572 

573- [Compact](/api/reference/resources/responses/methods/compact/index.md)

574 

575- [Input Items](/api/reference/resources/responses/subresources/input_items/index.md)

576 

577 - [List](/api/reference/resources/responses/subresources/input_items/methods/list/index.md)

578 

579- [Input Tokens](/api/reference/resources/responses/subresources/input_tokens/index.md)

580 

581 - [Count](/api/reference/resources/responses/subresources/input_tokens/methods/count/index.md)

582 

583## [Realtime](/api/reference/resources/realtime/index.md)

584 

585- [Connect](/api/reference/resources/realtime/methods/connect/index.md)

586 

587- [Client Secrets](/api/reference/resources/realtime/subresources/client_secrets/index.md)

588 

589 - [Create](/api/reference/resources/realtime/subresources/client_secrets/methods/create/index.md)

590 

591- [Calls](/api/reference/resources/realtime/subresources/calls/index.md)

592 

593 - [Accept](/api/reference/resources/realtime/subresources/calls/methods/accept/index.md)

594 

595 - [Hangup](/api/reference/resources/realtime/subresources/calls/methods/hangup/index.md)

596 

597 - [Refer](/api/reference/resources/realtime/subresources/calls/methods/refer/index.md)

598 

599 - [Reject](/api/reference/resources/realtime/subresources/calls/methods/reject/index.md)

600 

601 - [Create](/api/reference/resources/realtime/subresources/calls/methods/create/index.md)

602 

603- [Translations](/api/reference/resources/realtime/subresources/translations/index.md)

604 

605 - [Client Secrets](/api/reference/resources/realtime/subresources/translations/subresources/client_secrets/index.md)

606 

607 - [Create](/api/reference/resources/realtime/subresources/translations/subresources/client_secrets/methods/create/index.md)

608 

609- [Sessions](/api/reference/resources/realtime/subresources/sessions/index.md)

610 

611 - [Create](/api/reference/resources/realtime/subresources/sessions/methods/create/index.md)

612 

613- [Transcription Sessions](/api/reference/resources/realtime/subresources/transcription_sessions/index.md)

614 

615 - [Create](/api/reference/resources/realtime/subresources/transcription_sessions/methods/create/index.md)

616 

617## [Conversations](/api/reference/resources/conversations/index.md)

618 

619- [Create](/api/reference/resources/conversations/methods/create/index.md)

620 

621- [Retrieve](/api/reference/resources/conversations/methods/retrieve/index.md)

622 

623- [Update](/api/reference/resources/conversations/methods/update/index.md)

624 

625- [Delete](/api/reference/resources/conversations/methods/delete/index.md)

626 

627- [Items](/api/reference/resources/conversations/subresources/items/index.md)

628 

629 - [Create](/api/reference/resources/conversations/subresources/items/methods/create/index.md)

630 

631 - [List](/api/reference/resources/conversations/subresources/items/methods/list/index.md)

632 

633 - [Retrieve](/api/reference/resources/conversations/subresources/items/methods/retrieve/index.md)

634 

635 - [Delete](/api/reference/resources/conversations/subresources/items/methods/delete/index.md)

636 

637## [Evals](/api/reference/resources/evals/index.md)

638 

639- [List](/api/reference/resources/evals/methods/list/index.md)

640 

641- [Create](/api/reference/resources/evals/methods/create/index.md)

642 

643- [Retrieve](/api/reference/resources/evals/methods/retrieve/index.md)

644 

645- [Update](/api/reference/resources/evals/methods/update/index.md)

646 

647- [Delete](/api/reference/resources/evals/methods/delete/index.md)

648 

649- [Runs](/api/reference/resources/evals/subresources/runs/index.md)

650 

651 - [List](/api/reference/resources/evals/subresources/runs/methods/list/index.md)

652 

653 - [Create](/api/reference/resources/evals/subresources/runs/methods/create/index.md)

654 

655 - [Retrieve](/api/reference/resources/evals/subresources/runs/methods/retrieve/index.md)

656 

657 - [Cancel](/api/reference/resources/evals/subresources/runs/methods/cancel/index.md)

658 

659 - [Delete](/api/reference/resources/evals/subresources/runs/methods/delete/index.md)

660 

661 - [Output Items](/api/reference/resources/evals/subresources/runs/subresources/output_items/index.md)

662 

663 - [List](/api/reference/resources/evals/subresources/runs/subresources/output_items/methods/list/index.md)

664 

665 - [Retrieve](/api/reference/resources/evals/subresources/runs/subresources/output_items/methods/retrieve/index.md)

666 

667## [Containers](/api/reference/resources/containers/index.md)

668 

669- [List](/api/reference/resources/containers/methods/list/index.md)

670 

671- [Create](/api/reference/resources/containers/methods/create/index.md)

672 

673- [Retrieve](/api/reference/resources/containers/methods/retrieve/index.md)

674 

675- [Delete](/api/reference/resources/containers/methods/delete/index.md)

676 

677- [Files](/api/reference/resources/containers/subresources/files/index.md)

678 

679 - [List](/api/reference/resources/containers/subresources/files/methods/list/index.md)

680 

681 - [Create](/api/reference/resources/containers/subresources/files/methods/create/index.md)

682 

683 - [Retrieve](/api/reference/resources/containers/subresources/files/methods/retrieve/index.md)

684 

685 - [Delete](/api/reference/resources/containers/subresources/files/methods/delete/index.md)

686 

687 - [Content](/api/reference/resources/containers/subresources/files/subresources/content/index.md)

688 

689 - [Retrieve](/api/reference/resources/containers/subresources/files/subresources/content/methods/retrieve/index.md)

690 

691## [Skills](/api/reference/resources/skills/index.md)

692 

693- [Create](/api/reference/resources/skills/methods/create/index.md)

694 

695- [List](/api/reference/resources/skills/methods/list/index.md)

696 

697- [Retrieve](/api/reference/resources/skills/methods/retrieve/index.md)

698 

699- [Update](/api/reference/resources/skills/methods/update/index.md)

700 

701- [Delete](/api/reference/resources/skills/methods/delete/index.md)

702 

703- [Content](/api/reference/resources/skills/subresources/content/index.md)

704 

705 - [Retrieve](/api/reference/resources/skills/subresources/content/methods/retrieve/index.md)

706 

707- [Versions](/api/reference/resources/skills/subresources/versions/index.md)

708 

709 - [Create](/api/reference/resources/skills/subresources/versions/methods/create/index.md)

710 

711 - [List](/api/reference/resources/skills/subresources/versions/methods/list/index.md)

712 

713 - [Retrieve](/api/reference/resources/skills/subresources/versions/methods/retrieve/index.md)

714 

715 - [Delete](/api/reference/resources/skills/subresources/versions/methods/delete/index.md)

716 

717 - [Content](/api/reference/resources/skills/subresources/versions/subresources/content/index.md)

718 

719 - [Retrieve](/api/reference/resources/skills/subresources/versions/subresources/content/methods/retrieve/index.md)

720 

721## [Videos](/api/reference/resources/videos/index.md)

722 

723- [Create](/api/reference/resources/videos/methods/create/index.md)

724 

725- [Edit](/api/reference/resources/videos/methods/edit/index.md)

726 

727- [Extend](/api/reference/resources/videos/methods/extend/index.md)

728 

729- [Create Character](/api/reference/resources/videos/methods/create_character/index.md)

730 

731- [Get Character](/api/reference/resources/videos/methods/get_character/index.md)

732 

733- [List](/api/reference/resources/videos/methods/list/index.md)

734 

735- [Retrieve](/api/reference/resources/videos/methods/retrieve/index.md)

736 

737- [Delete](/api/reference/resources/videos/methods/delete/index.md)

738 

739- [Remix](/api/reference/resources/videos/methods/remix/index.md)

740 

741- [Download Content](/api/reference/resources/videos/methods/download_content/index.md)

Details

1# Shared

2 

3## Domain Types

4 

5### All Models

6 

7- `class AllModels: A class that can be one of several variants.union`

8 

9 - `String`

10 

11 - `enum ChatModel:`

12 

13 - `GPT_5_4("gpt-5.4")`

14 

15 - `GPT_5_4_MINI("gpt-5.4-mini")`

16 

17 - `GPT_5_4_NANO("gpt-5.4-nano")`

18 

19 - `GPT_5_4_MINI_2026_03_17("gpt-5.4-mini-2026-03-17")`

20 

21 - `GPT_5_4_NANO_2026_03_17("gpt-5.4-nano-2026-03-17")`

22 

23 - `GPT_5_3_CHAT_LATEST("gpt-5.3-chat-latest")`

24 

25 - `GPT_5_2("gpt-5.2")`

26 

27 - `GPT_5_2_2025_12_11("gpt-5.2-2025-12-11")`

28 

29 - `GPT_5_2_CHAT_LATEST("gpt-5.2-chat-latest")`

30 

31 - `GPT_5_2_PRO("gpt-5.2-pro")`

32 

33 - `GPT_5_2_PRO_2025_12_11("gpt-5.2-pro-2025-12-11")`

34 

35 - `GPT_5_1("gpt-5.1")`

36 

37 - `GPT_5_1_2025_11_13("gpt-5.1-2025-11-13")`

38 

39 - `GPT_5_1_CODEX("gpt-5.1-codex")`

40 

41 - `GPT_5_1_MINI("gpt-5.1-mini")`

42 

43 - `GPT_5_1_CHAT_LATEST("gpt-5.1-chat-latest")`

44 

45 - `GPT_5("gpt-5")`

46 

47 - `GPT_5_MINI("gpt-5-mini")`

48 

49 - `GPT_5_NANO("gpt-5-nano")`

50 

51 - `GPT_5_2025_08_07("gpt-5-2025-08-07")`

52 

53 - `GPT_5_MINI_2025_08_07("gpt-5-mini-2025-08-07")`

54 

55 - `GPT_5_NANO_2025_08_07("gpt-5-nano-2025-08-07")`

56 

57 - `GPT_5_CHAT_LATEST("gpt-5-chat-latest")`

58 

59 - `GPT_4_1("gpt-4.1")`

60 

61 - `GPT_4_1_MINI("gpt-4.1-mini")`

62 

63 - `GPT_4_1_NANO("gpt-4.1-nano")`

64 

65 - `GPT_4_1_2025_04_14("gpt-4.1-2025-04-14")`

66 

67 - `GPT_4_1_MINI_2025_04_14("gpt-4.1-mini-2025-04-14")`

68 

69 - `GPT_4_1_NANO_2025_04_14("gpt-4.1-nano-2025-04-14")`

70 

71 - `O4_MINI("o4-mini")`

72 

73 - `O4_MINI_2025_04_16("o4-mini-2025-04-16")`

74 

75 - `O3("o3")`

76 

77 - `O3_2025_04_16("o3-2025-04-16")`

78 

79 - `O3_MINI("o3-mini")`

80 

81 - `O3_MINI_2025_01_31("o3-mini-2025-01-31")`

82 

83 - `O1("o1")`

84 

85 - `O1_2024_12_17("o1-2024-12-17")`

86 

87 - `O1_PREVIEW("o1-preview")`

88 

89 - `O1_PREVIEW_2024_09_12("o1-preview-2024-09-12")`

90 

91 - `O1_MINI("o1-mini")`

92 

93 - `O1_MINI_2024_09_12("o1-mini-2024-09-12")`

94 

95 - `GPT_4O("gpt-4o")`

96 

97 - `GPT_4O_2024_11_20("gpt-4o-2024-11-20")`

98 

99 - `GPT_4O_2024_08_06("gpt-4o-2024-08-06")`

100 

101 - `GPT_4O_2024_05_13("gpt-4o-2024-05-13")`

102 

103 - `GPT_4O_AUDIO_PREVIEW("gpt-4o-audio-preview")`

104 

105 - `GPT_4O_AUDIO_PREVIEW_2024_10_01("gpt-4o-audio-preview-2024-10-01")`

106 

107 - `GPT_4O_AUDIO_PREVIEW_2024_12_17("gpt-4o-audio-preview-2024-12-17")`

108 

109 - `GPT_4O_AUDIO_PREVIEW_2025_06_03("gpt-4o-audio-preview-2025-06-03")`

110 

111 - `GPT_4O_MINI_AUDIO_PREVIEW("gpt-4o-mini-audio-preview")`

112 

113 - `GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17("gpt-4o-mini-audio-preview-2024-12-17")`

114 

115 - `GPT_4O_SEARCH_PREVIEW("gpt-4o-search-preview")`

116 

117 - `GPT_4O_MINI_SEARCH_PREVIEW("gpt-4o-mini-search-preview")`

118 

119 - `GPT_4O_SEARCH_PREVIEW_2025_03_11("gpt-4o-search-preview-2025-03-11")`

120 

121 - `GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11("gpt-4o-mini-search-preview-2025-03-11")`

122 

123 - `CHATGPT_4O_LATEST("chatgpt-4o-latest")`

124 

125 - `CODEX_MINI_LATEST("codex-mini-latest")`

126 

127 - `GPT_4O_MINI("gpt-4o-mini")`

128 

129 - `GPT_4O_MINI_2024_07_18("gpt-4o-mini-2024-07-18")`

130 

131 - `GPT_4_TURBO("gpt-4-turbo")`

132 

133 - `GPT_4_TURBO_2024_04_09("gpt-4-turbo-2024-04-09")`

134 

135 - `GPT_4_0125_PREVIEW("gpt-4-0125-preview")`

136 

137 - `GPT_4_TURBO_PREVIEW("gpt-4-turbo-preview")`

138 

139 - `GPT_4_1106_PREVIEW("gpt-4-1106-preview")`

140 

141 - `GPT_4_VISION_PREVIEW("gpt-4-vision-preview")`

142 

143 - `GPT_4("gpt-4")`

144 

145 - `GPT_4_0314("gpt-4-0314")`

146 

147 - `GPT_4_0613("gpt-4-0613")`

148 

149 - `GPT_4_32K("gpt-4-32k")`

150 

151 - `GPT_4_32K_0314("gpt-4-32k-0314")`

152 

153 - `GPT_4_32K_0613("gpt-4-32k-0613")`

154 

155 - `GPT_3_5_TURBO("gpt-3.5-turbo")`

156 

157 - `GPT_3_5_TURBO_16K("gpt-3.5-turbo-16k")`

158 

159 - `GPT_3_5_TURBO_0301("gpt-3.5-turbo-0301")`

160 

161 - `GPT_3_5_TURBO_0613("gpt-3.5-turbo-0613")`

162 

163 - `GPT_3_5_TURBO_1106("gpt-3.5-turbo-1106")`

164 

165 - `GPT_3_5_TURBO_0125("gpt-3.5-turbo-0125")`

166 

167 - `GPT_3_5_TURBO_16K_0613("gpt-3.5-turbo-16k-0613")`

168 

169 - `ResponsesOnlyModel`

170 

171 - `O1_PRO("o1-pro")`

172 

173 - `O1_PRO_2025_03_19("o1-pro-2025-03-19")`

174 

175 - `O3_PRO("o3-pro")`

176 

177 - `O3_PRO_2025_06_10("o3-pro-2025-06-10")`

178 

179 - `O3_DEEP_RESEARCH("o3-deep-research")`

180 

181 - `O3_DEEP_RESEARCH_2025_06_26("o3-deep-research-2025-06-26")`

182 

183 - `O4_MINI_DEEP_RESEARCH("o4-mini-deep-research")`

184 

185 - `O4_MINI_DEEP_RESEARCH_2025_06_26("o4-mini-deep-research-2025-06-26")`

186 

187 - `COMPUTER_USE_PREVIEW("computer-use-preview")`

188 

189 - `COMPUTER_USE_PREVIEW_2025_03_11("computer-use-preview-2025-03-11")`

190 

191 - `GPT_5_CODEX("gpt-5-codex")`

192 

193 - `GPT_5_PRO("gpt-5-pro")`

194 

195 - `GPT_5_PRO_2025_10_06("gpt-5-pro-2025-10-06")`

196 

197 - `GPT_5_1_CODEX_MAX("gpt-5.1-codex-max")`

198 

199### Chat Model

200 

201- `enum ChatModel:`

202 

203 - `GPT_5_4("gpt-5.4")`

204 

205 - `GPT_5_4_MINI("gpt-5.4-mini")`

206 

207 - `GPT_5_4_NANO("gpt-5.4-nano")`

208 

209 - `GPT_5_4_MINI_2026_03_17("gpt-5.4-mini-2026-03-17")`

210 

211 - `GPT_5_4_NANO_2026_03_17("gpt-5.4-nano-2026-03-17")`

212 

213 - `GPT_5_3_CHAT_LATEST("gpt-5.3-chat-latest")`

214 

215 - `GPT_5_2("gpt-5.2")`

216 

217 - `GPT_5_2_2025_12_11("gpt-5.2-2025-12-11")`

218 

219 - `GPT_5_2_CHAT_LATEST("gpt-5.2-chat-latest")`

220 

221 - `GPT_5_2_PRO("gpt-5.2-pro")`

222 

223 - `GPT_5_2_PRO_2025_12_11("gpt-5.2-pro-2025-12-11")`

224 

225 - `GPT_5_1("gpt-5.1")`

226 

227 - `GPT_5_1_2025_11_13("gpt-5.1-2025-11-13")`

228 

229 - `GPT_5_1_CODEX("gpt-5.1-codex")`

230 

231 - `GPT_5_1_MINI("gpt-5.1-mini")`

232 

233 - `GPT_5_1_CHAT_LATEST("gpt-5.1-chat-latest")`

234 

235 - `GPT_5("gpt-5")`

236 

237 - `GPT_5_MINI("gpt-5-mini")`

238 

239 - `GPT_5_NANO("gpt-5-nano")`

240 

241 - `GPT_5_2025_08_07("gpt-5-2025-08-07")`

242 

243 - `GPT_5_MINI_2025_08_07("gpt-5-mini-2025-08-07")`

244 

245 - `GPT_5_NANO_2025_08_07("gpt-5-nano-2025-08-07")`

246 

247 - `GPT_5_CHAT_LATEST("gpt-5-chat-latest")`

248 

249 - `GPT_4_1("gpt-4.1")`

250 

251 - `GPT_4_1_MINI("gpt-4.1-mini")`

252 

253 - `GPT_4_1_NANO("gpt-4.1-nano")`

254 

255 - `GPT_4_1_2025_04_14("gpt-4.1-2025-04-14")`

256 

257 - `GPT_4_1_MINI_2025_04_14("gpt-4.1-mini-2025-04-14")`

258 

259 - `GPT_4_1_NANO_2025_04_14("gpt-4.1-nano-2025-04-14")`

260 

261 - `O4_MINI("o4-mini")`

262 

263 - `O4_MINI_2025_04_16("o4-mini-2025-04-16")`

264 

265 - `O3("o3")`

266 

267 - `O3_2025_04_16("o3-2025-04-16")`

268 

269 - `O3_MINI("o3-mini")`

270 

271 - `O3_MINI_2025_01_31("o3-mini-2025-01-31")`

272 

273 - `O1("o1")`

274 

275 - `O1_2024_12_17("o1-2024-12-17")`

276 

277 - `O1_PREVIEW("o1-preview")`

278 

279 - `O1_PREVIEW_2024_09_12("o1-preview-2024-09-12")`

280 

281 - `O1_MINI("o1-mini")`

282 

283 - `O1_MINI_2024_09_12("o1-mini-2024-09-12")`

284 

285 - `GPT_4O("gpt-4o")`

286 

287 - `GPT_4O_2024_11_20("gpt-4o-2024-11-20")`

288 

289 - `GPT_4O_2024_08_06("gpt-4o-2024-08-06")`

290 

291 - `GPT_4O_2024_05_13("gpt-4o-2024-05-13")`

292 

293 - `GPT_4O_AUDIO_PREVIEW("gpt-4o-audio-preview")`

294 

295 - `GPT_4O_AUDIO_PREVIEW_2024_10_01("gpt-4o-audio-preview-2024-10-01")`

296 

297 - `GPT_4O_AUDIO_PREVIEW_2024_12_17("gpt-4o-audio-preview-2024-12-17")`

298 

299 - `GPT_4O_AUDIO_PREVIEW_2025_06_03("gpt-4o-audio-preview-2025-06-03")`

300 

301 - `GPT_4O_MINI_AUDIO_PREVIEW("gpt-4o-mini-audio-preview")`

302 

303 - `GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17("gpt-4o-mini-audio-preview-2024-12-17")`

304 

305 - `GPT_4O_SEARCH_PREVIEW("gpt-4o-search-preview")`

306 

307 - `GPT_4O_MINI_SEARCH_PREVIEW("gpt-4o-mini-search-preview")`

308 

309 - `GPT_4O_SEARCH_PREVIEW_2025_03_11("gpt-4o-search-preview-2025-03-11")`

310 

311 - `GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11("gpt-4o-mini-search-preview-2025-03-11")`

312 

313 - `CHATGPT_4O_LATEST("chatgpt-4o-latest")`

314 

315 - `CODEX_MINI_LATEST("codex-mini-latest")`

316 

317 - `GPT_4O_MINI("gpt-4o-mini")`

318 

319 - `GPT_4O_MINI_2024_07_18("gpt-4o-mini-2024-07-18")`

320 

321 - `GPT_4_TURBO("gpt-4-turbo")`

322 

323 - `GPT_4_TURBO_2024_04_09("gpt-4-turbo-2024-04-09")`

324 

325 - `GPT_4_0125_PREVIEW("gpt-4-0125-preview")`

326 

327 - `GPT_4_TURBO_PREVIEW("gpt-4-turbo-preview")`

328 

329 - `GPT_4_1106_PREVIEW("gpt-4-1106-preview")`

330 

331 - `GPT_4_VISION_PREVIEW("gpt-4-vision-preview")`

332 

333 - `GPT_4("gpt-4")`

334 

335 - `GPT_4_0314("gpt-4-0314")`

336 

337 - `GPT_4_0613("gpt-4-0613")`

338 

339 - `GPT_4_32K("gpt-4-32k")`

340 

341 - `GPT_4_32K_0314("gpt-4-32k-0314")`

342 

343 - `GPT_4_32K_0613("gpt-4-32k-0613")`

344 

345 - `GPT_3_5_TURBO("gpt-3.5-turbo")`

346 

347 - `GPT_3_5_TURBO_16K("gpt-3.5-turbo-16k")`

348 

349 - `GPT_3_5_TURBO_0301("gpt-3.5-turbo-0301")`

350 

351 - `GPT_3_5_TURBO_0613("gpt-3.5-turbo-0613")`

352 

353 - `GPT_3_5_TURBO_1106("gpt-3.5-turbo-1106")`

354 

355 - `GPT_3_5_TURBO_0125("gpt-3.5-turbo-0125")`

356 

357 - `GPT_3_5_TURBO_16K_0613("gpt-3.5-turbo-16k-0613")`

358 

359### Comparison Filter

360 

361- `class ComparisonFilter:`

362 

363 A filter used to compare a specified attribute key to a given value using a defined comparison operation.

364 

365 - `String key`

366 

367 The key to compare against the value.

368 

369 - `Type type`

370 

371 Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`, `nin`.

372 

373 - `eq`: equals

374 - `ne`: not equal

375 - `gt`: greater than

376 - `gte`: greater than or equal

377 - `lt`: less than

378 - `lte`: less than or equal

379 - `in`: in

380 - `nin`: not in

381 

382 - `EQ("eq")`

383 

384 - `NE("ne")`

385 

386 - `GT("gt")`

387 

388 - `GTE("gte")`

389 

390 - `LT("lt")`

391 

392 - `LTE("lte")`

393 

394 - `IN("in")`

395 

396 - `NIN("nin")`

397 

398 - `Value value`

399 

400 The value to compare against the attribute key; supports string, number, or boolean types.

401 

402 - `String`

403 

404 - `double`

405 

406 - `boolean`

407 

408 - `List<ComparisonFilterValueItem>`

409 

410 - `String`

411 

412 - `double`

413 

414### Compound Filter

415 

416- `class CompoundFilter:`

417 

418 Combine multiple filters using `and` or `or`.

419 

420 - `List<Filter> filters`

421 

422 Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`.

423 

424 - `class ComparisonFilter:`

425 

426 A filter used to compare a specified attribute key to a given value using a defined comparison operation.

427 

428 - `String key`

429 

430 The key to compare against the value.

431 

432 - `Type type`

433 

434 Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`, `nin`.

435 

436 - `eq`: equals

437 - `ne`: not equal

438 - `gt`: greater than

439 - `gte`: greater than or equal

440 - `lt`: less than

441 - `lte`: less than or equal

442 - `in`: in

443 - `nin`: not in

444 

445 - `EQ("eq")`

446 

447 - `NE("ne")`

448 

449 - `GT("gt")`

450 

451 - `GTE("gte")`

452 

453 - `LT("lt")`

454 

455 - `LTE("lte")`

456 

457 - `IN("in")`

458 

459 - `NIN("nin")`

460 

461 - `Value value`

462 

463 The value to compare against the attribute key; supports string, number, or boolean types.

464 

465 - `String`

466 

467 - `double`

468 

469 - `boolean`

470 

471 - `List<ComparisonFilterValueItem>`

472 

473 - `String`

474 

475 - `double`

476 

477 - `JsonValue`

478 

479 - `Type type`

480 

481 Type of operation: `and` or `or`.

482 

483 - `AND("and")`

484 

485 - `OR("or")`

486 

487### Custom Tool Input Format

488 

489- `class CustomToolInputFormat: A class that can be one of several variants.union`

490 

491 The input format for the custom tool. Default is unconstrained text.

492 

493 - `JsonValue;`

494 

495 - `JsonValue; type "text"constant`

496 

497 Unconstrained text format. Always `text`.

498 

499 - `TEXT("text")`

500 

501 - `Grammar`

502 

503 - `String definition`

504 

505 The grammar definition.

506 

507 - `Syntax syntax`

508 

509 The syntax of the grammar definition. One of `lark` or `regex`.

510 

511 - `LARK("lark")`

512 

513 - `REGEX("regex")`

514 

515 - `JsonValue; type "grammar"constant`

516 

517 Grammar format. Always `grammar`.

518 

519 - `GRAMMAR("grammar")`

520 

521### Error Object

522 

523- `class ErrorObject:`

524 

525 - `Optional<String> code`

526 

527 - `String message`

528 

529 - `Optional<String> param`

530 

531 - `String type`

532 

533### Function Definition

534 

535- `class FunctionDefinition:`

536 

537 - `String name`

538 

539 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.

540 

541 - `Optional<String> description`

542 

543 A description of what the function does, used by the model to choose when and how to call the function.

544 

545 - `Optional<FunctionParameters> parameters`

546 

547 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.

548 

549 Omitting `parameters` defines a function with an empty parameter list.

550 

551 - `Optional<Boolean> strict`

552 

553 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).

554 

555### Function Parameters

556 

557- `class FunctionParameters:`

558 

559 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.

560 

561 Omitting `parameters` defines a function with an empty parameter list.

562 

563### OAuth Error Code

564 

565- `enum OAuthErrorCode:`

566 

567 - `INVALID_GRANT("invalid_grant")`

568 

569 - `INVALID_SUBJECT_TOKEN("invalid_subject_token")`

570 

571### Reasoning

572 

573- `class Reasoning:`

574 

575 **gpt-5 and o-series models only**

576 

577 Configuration options for

578 [reasoning models](https://platform.openai.com/docs/guides/reasoning).

579 

580 - `Optional<ReasoningEffort> effort`

581 

582 Constrains effort on reasoning for

583 [reasoning models](https://platform.openai.com/docs/guides/reasoning).

584 Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing

585 reasoning effort can result in faster responses and fewer tokens used

586 on reasoning in a response.

587 

588 - `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.

589 - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.

590 - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.

591 - `xhigh` is supported for all models after `gpt-5.1-codex-max`.

592 

593 - `NONE("none")`

594 

595 - `MINIMAL("minimal")`

596 

597 - `LOW("low")`

598 

599 - `MEDIUM("medium")`

600 

601 - `HIGH("high")`

602 

603 - `XHIGH("xhigh")`

604 

605 - `Optional<GenerateSummary> generateSummary`

606 

607 **Deprecated:** use `summary` instead.

608 

609 A summary of the reasoning performed by the model. This can be

610 useful for debugging and understanding the model's reasoning process.

611 One of `auto`, `concise`, or `detailed`.

612 

613 - `AUTO("auto")`

614 

615 - `CONCISE("concise")`

616 

617 - `DETAILED("detailed")`

618 

619 - `Optional<Summary> summary`

620 

621 A summary of the reasoning performed by the model. This can be

622 useful for debugging and understanding the model's reasoning process.

623 One of `auto`, `concise`, or `detailed`.

624 

625 `concise` is supported for `computer-use-preview` models and all reasoning models after `gpt-5`.

626 

627 - `AUTO("auto")`

628 

629 - `CONCISE("concise")`

630 

631 - `DETAILED("detailed")`

632 

633### Reasoning Effort

634 

635- `enum ReasoningEffort:`

636 

637 Constrains effort on reasoning for

638 [reasoning models](https://platform.openai.com/docs/guides/reasoning).

639 Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing

640 reasoning effort can result in faster responses and fewer tokens used

641 on reasoning in a response.

642 

643 - `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.

644 - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.

645 - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.

646 - `xhigh` is supported for all models after `gpt-5.1-codex-max`.

647 

648 - `NONE("none")`

649 

650 - `MINIMAL("minimal")`

651 

652 - `LOW("low")`

653 

654 - `MEDIUM("medium")`

655 

656 - `HIGH("high")`

657 

658 - `XHIGH("xhigh")`

659 

660### Response Format JSON Object

661 

662- `class ResponseFormatJsonObject:`

663 

664 JSON object response format. An older method of generating JSON responses.

665 Using `json_schema` is recommended for models that support it. Note that the

666 model will not generate JSON without a system or user message instructing it

667 to do so.

668 

669 - `JsonValue; type "json_object"constant`

670 

671 The type of response format being defined. Always `json_object`.

672 

673 - `JSON_OBJECT("json_object")`

674 

675### Response Format JSON Schema

676 

677- `class ResponseFormatJsonSchema:`

678 

679 JSON Schema response format. Used to generate structured JSON responses.

680 Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).

681 

682 - `JsonSchema jsonSchema`

683 

684 Structured Outputs configuration options, including a JSON Schema.

685 

686 - `String name`

687 

688 The name of the response format. Must be a-z, A-Z, 0-9, or contain

689 underscores and dashes, with a maximum length of 64.

690 

691 - `Optional<String> description`

692 

693 A description of what the response format is for, used by the model to

694 determine how to respond in the format.

695 

696 - `Optional<Schema> schema`

697 

698 The schema for the response format, described as a JSON Schema object.

699 Learn how to build JSON schemas [here](https://json-schema.org/).

700 

701 - `Optional<Boolean> strict`

702 

703 Whether to enable strict schema adherence when generating the output.

704 If set to true, the model will always follow the exact schema defined

705 in the `schema` field. Only a subset of JSON Schema is supported when

706 `strict` is `true`. To learn more, read the [Structured Outputs

707 guide](https://platform.openai.com/docs/guides/structured-outputs).

708 

709 - `JsonValue; type "json_schema"constant`

710 

711 The type of response format being defined. Always `json_schema`.

712 

713 - `JSON_SCHEMA("json_schema")`

714 

715### Response Format Text

716 

717- `class ResponseFormatText:`

718 

719 Default response format. Used to generate text responses.

720 

721 - `JsonValue; type "text"constant`

722 

723 The type of response format being defined. Always `text`.

724 

725 - `TEXT("text")`

726 

727### Response Format Text Grammar

728 

729- `class ResponseFormatTextGrammar:`

730 

731 A custom grammar for the model to follow when generating text.

732 Learn more in the [custom grammars guide](https://platform.openai.com/docs/guides/custom-grammars).

733 

734 - `String grammar`

735 

736 The custom grammar for the model to follow.

737 

738 - `JsonValue; type "grammar"constant`

739 

740 The type of response format being defined. Always `grammar`.

741 

742 - `GRAMMAR("grammar")`

743 

744### Response Format Text Python

745 

746- `class ResponseFormatTextPython:`

747 

748 Configure the model to generate valid Python code. See the

749 [custom grammars guide](https://platform.openai.com/docs/guides/custom-grammars) for more details.

750 

751 - `JsonValue; type "python"constant`

752 

753 The type of response format being defined. Always `python`.

754 

755 - `PYTHON("python")`

756 

757### Responses Model

758 

759- `class ResponsesModel: A class that can be one of several variants.union`

760 

761 - `String`

762 

763 - `enum ChatModel:`

764 

765 - `GPT_5_4("gpt-5.4")`

766 

767 - `GPT_5_4_MINI("gpt-5.4-mini")`

768 

769 - `GPT_5_4_NANO("gpt-5.4-nano")`

770 

771 - `GPT_5_4_MINI_2026_03_17("gpt-5.4-mini-2026-03-17")`

772 

773 - `GPT_5_4_NANO_2026_03_17("gpt-5.4-nano-2026-03-17")`

774 

775 - `GPT_5_3_CHAT_LATEST("gpt-5.3-chat-latest")`

776 

777 - `GPT_5_2("gpt-5.2")`

778 

779 - `GPT_5_2_2025_12_11("gpt-5.2-2025-12-11")`

780 

781 - `GPT_5_2_CHAT_LATEST("gpt-5.2-chat-latest")`

782 

783 - `GPT_5_2_PRO("gpt-5.2-pro")`

784 

785 - `GPT_5_2_PRO_2025_12_11("gpt-5.2-pro-2025-12-11")`

786 

787 - `GPT_5_1("gpt-5.1")`

788 

789 - `GPT_5_1_2025_11_13("gpt-5.1-2025-11-13")`

790 

791 - `GPT_5_1_CODEX("gpt-5.1-codex")`

792 

793 - `GPT_5_1_MINI("gpt-5.1-mini")`

794 

795 - `GPT_5_1_CHAT_LATEST("gpt-5.1-chat-latest")`

796 

797 - `GPT_5("gpt-5")`

798 

799 - `GPT_5_MINI("gpt-5-mini")`

800 

801 - `GPT_5_NANO("gpt-5-nano")`

802 

803 - `GPT_5_2025_08_07("gpt-5-2025-08-07")`

804 

805 - `GPT_5_MINI_2025_08_07("gpt-5-mini-2025-08-07")`

806 

807 - `GPT_5_NANO_2025_08_07("gpt-5-nano-2025-08-07")`

808 

809 - `GPT_5_CHAT_LATEST("gpt-5-chat-latest")`

810 

811 - `GPT_4_1("gpt-4.1")`

812 

813 - `GPT_4_1_MINI("gpt-4.1-mini")`

814 

815 - `GPT_4_1_NANO("gpt-4.1-nano")`

816 

817 - `GPT_4_1_2025_04_14("gpt-4.1-2025-04-14")`

818 

819 - `GPT_4_1_MINI_2025_04_14("gpt-4.1-mini-2025-04-14")`

820 

821 - `GPT_4_1_NANO_2025_04_14("gpt-4.1-nano-2025-04-14")`

822 

823 - `O4_MINI("o4-mini")`

824 

825 - `O4_MINI_2025_04_16("o4-mini-2025-04-16")`

826 

827 - `O3("o3")`

828 

829 - `O3_2025_04_16("o3-2025-04-16")`

830 

831 - `O3_MINI("o3-mini")`

832 

833 - `O3_MINI_2025_01_31("o3-mini-2025-01-31")`

834 

835 - `O1("o1")`

836 

837 - `O1_2024_12_17("o1-2024-12-17")`

838 

839 - `O1_PREVIEW("o1-preview")`

840 

841 - `O1_PREVIEW_2024_09_12("o1-preview-2024-09-12")`

842 

843 - `O1_MINI("o1-mini")`

844 

845 - `O1_MINI_2024_09_12("o1-mini-2024-09-12")`

846 

847 - `GPT_4O("gpt-4o")`

848 

849 - `GPT_4O_2024_11_20("gpt-4o-2024-11-20")`

850 

851 - `GPT_4O_2024_08_06("gpt-4o-2024-08-06")`

852 

853 - `GPT_4O_2024_05_13("gpt-4o-2024-05-13")`

854 

855 - `GPT_4O_AUDIO_PREVIEW("gpt-4o-audio-preview")`

856 

857 - `GPT_4O_AUDIO_PREVIEW_2024_10_01("gpt-4o-audio-preview-2024-10-01")`

858 

859 - `GPT_4O_AUDIO_PREVIEW_2024_12_17("gpt-4o-audio-preview-2024-12-17")`

860 

861 - `GPT_4O_AUDIO_PREVIEW_2025_06_03("gpt-4o-audio-preview-2025-06-03")`

862 

863 - `GPT_4O_MINI_AUDIO_PREVIEW("gpt-4o-mini-audio-preview")`

864 

865 - `GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17("gpt-4o-mini-audio-preview-2024-12-17")`

866 

867 - `GPT_4O_SEARCH_PREVIEW("gpt-4o-search-preview")`

868 

869 - `GPT_4O_MINI_SEARCH_PREVIEW("gpt-4o-mini-search-preview")`

870 

871 - `GPT_4O_SEARCH_PREVIEW_2025_03_11("gpt-4o-search-preview-2025-03-11")`

872 

873 - `GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11("gpt-4o-mini-search-preview-2025-03-11")`

874 

875 - `CHATGPT_4O_LATEST("chatgpt-4o-latest")`

876 

877 - `CODEX_MINI_LATEST("codex-mini-latest")`

878 

879 - `GPT_4O_MINI("gpt-4o-mini")`

880 

881 - `GPT_4O_MINI_2024_07_18("gpt-4o-mini-2024-07-18")`

882 

883 - `GPT_4_TURBO("gpt-4-turbo")`

884 

885 - `GPT_4_TURBO_2024_04_09("gpt-4-turbo-2024-04-09")`

886 

887 - `GPT_4_0125_PREVIEW("gpt-4-0125-preview")`

888 

889 - `GPT_4_TURBO_PREVIEW("gpt-4-turbo-preview")`

890 

891 - `GPT_4_1106_PREVIEW("gpt-4-1106-preview")`

892 

893 - `GPT_4_VISION_PREVIEW("gpt-4-vision-preview")`

894 

895 - `GPT_4("gpt-4")`

896 

897 - `GPT_4_0314("gpt-4-0314")`

898 

899 - `GPT_4_0613("gpt-4-0613")`

900 

901 - `GPT_4_32K("gpt-4-32k")`

902 

903 - `GPT_4_32K_0314("gpt-4-32k-0314")`

904 

905 - `GPT_4_32K_0613("gpt-4-32k-0613")`

906 

907 - `GPT_3_5_TURBO("gpt-3.5-turbo")`

908 

909 - `GPT_3_5_TURBO_16K("gpt-3.5-turbo-16k")`

910 

911 - `GPT_3_5_TURBO_0301("gpt-3.5-turbo-0301")`

912 

913 - `GPT_3_5_TURBO_0613("gpt-3.5-turbo-0613")`

914 

915 - `GPT_3_5_TURBO_1106("gpt-3.5-turbo-1106")`

916 

917 - `GPT_3_5_TURBO_0125("gpt-3.5-turbo-0125")`

918 

919 - `GPT_3_5_TURBO_16K_0613("gpt-3.5-turbo-16k-0613")`

920 

921 - `ResponsesOnlyModel`

922 

923 - `O1_PRO("o1-pro")`

924 

925 - `O1_PRO_2025_03_19("o1-pro-2025-03-19")`

926 

927 - `O3_PRO("o3-pro")`

928 

929 - `O3_PRO_2025_06_10("o3-pro-2025-06-10")`

930 

931 - `O3_DEEP_RESEARCH("o3-deep-research")`

932 

933 - `O3_DEEP_RESEARCH_2025_06_26("o3-deep-research-2025-06-26")`

934 

935 - `O4_MINI_DEEP_RESEARCH("o4-mini-deep-research")`

936 

937 - `O4_MINI_DEEP_RESEARCH_2025_06_26("o4-mini-deep-research-2025-06-26")`

938 

939 - `COMPUTER_USE_PREVIEW("computer-use-preview")`

940 

941 - `COMPUTER_USE_PREVIEW_2025_03_11("computer-use-preview-2025-03-11")`

942 

943 - `GPT_5_CODEX("gpt-5-codex")`

944 

945 - `GPT_5_PRO("gpt-5-pro")`

946 

947 - `GPT_5_PRO_2025_10_06("gpt-5-pro-2025-10-06")`

948 

949 - `GPT_5_1_CODEX_MAX("gpt-5.1-codex-max")`

Details

1## Create speech

2 

3`HttpResponse audio().speech().create(SpeechCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/audio/speech`

6 

7Generates audio from the input text.

8 

9Returns the audio file content, or a stream of audio events.

10 

11### Parameters

12 

13- `SpeechCreateParams params`

14 

15 - `String input`

16 

17 The text to generate audio for. The maximum length is 4096 characters.

18 

19 - `SpeechModel model`

20 

21 One of the available [TTS models](https://platform.openai.com/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.

22 

23 - `Voice voice`

24 

25 The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ "id": "voice_1234" }`. Previews of the voices are available in the [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).

26 

27 - `String`

28 

29 - `enum UnionMember1:`

30 

31 - `ALLOY("alloy")`

32 

33 - `ASH("ash")`

34 

35 - `BALLAD("ballad")`

36 

37 - `CORAL("coral")`

38 

39 - `ECHO("echo")`

40 

41 - `SAGE("sage")`

42 

43 - `SHIMMER("shimmer")`

44 

45 - `VERSE("verse")`

46 

47 - `MARIN("marin")`

48 

49 - `CEDAR("cedar")`

50 

51 - `class Id:`

52 

53 Custom voice reference.

54 

55 - `String id`

56 

57 The custom voice ID, e.g. `voice_1234`.

58 

59 - `Optional<String> instructions`

60 

61 Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.

62 

63 - `Optional<ResponseFormat> responseFormat`

64 

65 The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.

66 

67 - `MP3("mp3")`

68 

69 - `OPUS("opus")`

70 

71 - `AAC("aac")`

72 

73 - `FLAC("flac")`

74 

75 - `WAV("wav")`

76 

77 - `PCM("pcm")`

78 

79 - `Optional<Double> speed`

80 

81 The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.

82 

83 - `Optional<StreamFormat> streamFormat`

84 

85 The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.

86 

87 - `SSE("sse")`

88 

89 - `AUDIO("audio")`

90 

91### Example

92 

93```java

94package com.openai.example;

95 

96import com.openai.client.OpenAIClient;

97import com.openai.client.okhttp.OpenAIOkHttpClient;

98import com.openai.core.http.HttpResponse;

99import com.openai.models.audio.speech.SpeechCreateParams;

100import com.openai.models.audio.speech.SpeechModel;

101 

102public final class Main {

103 private Main() {}

104 

105 public static void main(String[] args) {

106 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

107 

108 SpeechCreateParams params = SpeechCreateParams.builder()

109 .input("input")

110 .model(SpeechModel.TTS_1)

111 .voice(SpeechCreateParams.Voice.UnionMember1.ALLOY)

112 .build();

113 HttpResponse speech = client.audio().speech().create(params);

114 }

115}

116```

Details

1## Create transcription

2 

3`TranscriptionCreateResponse audio().transcriptions().create(TranscriptionCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/audio/transcriptions`

6 

7Transcribes audio into the input language.

8 

9Returns a transcription object in `json`, `diarized_json`, or `verbose_json`

10format, or a stream of transcript events.

11 

12### Parameters

13 

14- `TranscriptionCreateParams params`

15 

16 - `String file`

17 

18 The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.

19 

20 - `AudioModel model`

21 

22 ID of the model to use. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1` (which is powered by our open source Whisper V2 model), and `gpt-4o-transcribe-diarize`.

23 

24 - `Optional<ChunkingStrategy> chunkingStrategy`

25 

26 Controls how the audio is cut into chunks. When set to `"auto"`, the server first normalizes loudness and then uses voice activity detection (VAD) to choose boundaries. `server_vad` object can be provided to tweak VAD detection parameters manually. If unset, the audio is transcribed as a single block. Required when using `gpt-4o-transcribe-diarize` for inputs longer than 30 seconds.

27 

28 - `JsonValue;`

29 

30 - `AUTO("auto")`

31 

32 - `class VadConfig:`

33 

34 - `Type type`

35 

36 Must be set to `server_vad` to enable manual chunking using server side VAD.

37 

38 - `SERVER_VAD("server_vad")`

39 

40 - `Optional<Long> prefixPaddingMs`

41 

42 Amount of audio to include before the VAD detected speech (in

43 milliseconds).

44 

45 - `Optional<Long> silenceDurationMs`

46 

47 Duration of silence to detect speech stop (in milliseconds).

48 With shorter values the model will respond more quickly,

49 but may jump in on short pauses from the user.

50 

51 - `Optional<Double> threshold`

52 

53 Sensitivity threshold (0.0 to 1.0) for voice activity detection. A

54 higher threshold will require louder audio to activate the model, and

55 thus might perform better in noisy environments.

56 

57 - `Optional<List<TranscriptionInclude>> include`

58 

59 Additional information to include in the transcription response.

60 `logprobs` will return the log probabilities of the tokens in the

61 response to understand the model's confidence in the transcription.

62 `logprobs` only works with response_format set to `json` and only with

63 the models `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is not supported when using `gpt-4o-transcribe-diarize`.

64 

65 - `LOGPROBS("logprobs")`

66 

67 - `Optional<List<String>> knownSpeakerNames`

68 

69 Optional list of speaker names that correspond to the audio samples provided in `known_speaker_references[]`. Each entry should be a short identifier (for example `customer` or `agent`). Up to 4 speakers are supported.

70 

71 - `Optional<List<String>> knownSpeakerReferences`

72 

73 Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`.

74 

75 - `Optional<String> language`

76 

77 The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency.

78 

79 - `Optional<String> prompt`

80 

81 An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting) should match the audio language. This field is not supported when using `gpt-4o-transcribe-diarize`.

82 

83 - `Optional<AudioResponseFormat> responseFormat`

84 

85 The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`. For `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and `diarized_json`, with `diarized_json` required to receive speaker annotations.

86 

87 - `Optional<Double> temperature`

88 

89 The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.

90 

91 - `Optional<List<TimestampGranularity>> timestampGranularities`

92 

93 The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.

94 This option is not available for `gpt-4o-transcribe-diarize`.

95 

96 - `WORD("word")`

97 

98 - `SEGMENT("segment")`

99 

100### Returns

101 

102- `class TranscriptionCreateResponse: A class that can be one of several variants.union`

103 

104 Represents a transcription response returned by model, based on the provided input.

105 

106 - `class Transcription:`

107 

108 Represents a transcription response returned by model, based on the provided input.

109 

110 - `String text`

111 

112 The transcribed text.

113 

114 - `Optional<List<Logprob>> logprobs`

115 

116 The log probabilities of the tokens in the transcription. Only returned with the models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added to the `include` array.

117 

118 - `Optional<String> token`

119 

120 The token in the transcription.

121 

122 - `Optional<List<Double>> bytes`

123 

124 The bytes of the token.

125 

126 - `Optional<Double> logprob`

127 

128 The log probability of the token.

129 

130 - `Optional<Usage> usage`

131 

132 Token usage statistics for the request.

133 

134 - `class Tokens:`

135 

136 Usage statistics for models billed by token usage.

137 

138 - `long inputTokens`

139 

140 Number of input tokens billed for this request.

141 

142 - `long outputTokens`

143 

144 Number of output tokens generated.

145 

146 - `long totalTokens`

147 

148 Total number of tokens used (input + output).

149 

150 - `JsonValue; type "tokens"constant`

151 

152 The type of the usage object. Always `tokens` for this variant.

153 

154 - `TOKENS("tokens")`

155 

156 - `Optional<InputTokenDetails> inputTokenDetails`

157 

158 Details about the input tokens billed for this request.

159 

160 - `Optional<Long> audioTokens`

161 

162 Number of audio tokens billed for this request.

163 

164 - `Optional<Long> textTokens`

165 

166 Number of text tokens billed for this request.

167 

168 - `class Duration:`

169 

170 Usage statistics for models billed by audio input duration.

171 

172 - `double seconds`

173 

174 Duration of the input audio in seconds.

175 

176 - `JsonValue; type "duration"constant`

177 

178 The type of the usage object. Always `duration` for this variant.

179 

180 - `DURATION("duration")`

181 

182 - `class TranscriptionDiarized:`

183 

184 Represents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.

185 

186 - `double duration`

187 

188 Duration of the input audio in seconds.

189 

190 - `List<TranscriptionDiarizedSegment> segments`

191 

192 Segments of the transcript annotated with timestamps and speaker labels.

193 

194 - `String id`

195 

196 Unique identifier for the segment.

197 

198 - `double end`

199 

200 End timestamp of the segment in seconds.

201 

202 - `String speaker`

203 

204 Speaker label for this segment. When known speakers are provided, the label matches `known_speaker_names[]`. Otherwise speakers are labeled sequentially using capital letters (`A`, `B`, ...).

205 

206 - `double start`

207 

208 Start timestamp of the segment in seconds.

209 

210 - `String text`

211 

212 Transcript text for this segment.

213 

214 - `JsonValue; type "transcript.text.segment"constant`

215 

216 The type of the segment. Always `transcript.text.segment`.

217 

218 - `TRANSCRIPT_TEXT_SEGMENT("transcript.text.segment")`

219 

220 - `JsonValue; task "transcribe"constant`

221 

222 The type of task that was run. Always `transcribe`.

223 

224 - `TRANSCRIBE("transcribe")`

225 

226 - `String text`

227 

228 The concatenated transcript text for the entire audio input.

229 

230 - `Optional<Usage> usage`

231 

232 Token or duration usage statistics for the request.

233 

234 - `class Tokens:`

235 

236 Usage statistics for models billed by token usage.

237 

238 - `long inputTokens`

239 

240 Number of input tokens billed for this request.

241 

242 - `long outputTokens`

243 

244 Number of output tokens generated.

245 

246 - `long totalTokens`

247 

248 Total number of tokens used (input + output).

249 

250 - `JsonValue; type "tokens"constant`

251 

252 The type of the usage object. Always `tokens` for this variant.

253 

254 - `TOKENS("tokens")`

255 

256 - `Optional<InputTokenDetails> inputTokenDetails`

257 

258 Details about the input tokens billed for this request.

259 

260 - `Optional<Long> audioTokens`

261 

262 Number of audio tokens billed for this request.

263 

264 - `Optional<Long> textTokens`

265 

266 Number of text tokens billed for this request.

267 

268 - `class Duration:`

269 

270 Usage statistics for models billed by audio input duration.

271 

272 - `double seconds`

273 

274 Duration of the input audio in seconds.

275 

276 - `JsonValue; type "duration"constant`

277 

278 The type of the usage object. Always `duration` for this variant.

279 

280 - `DURATION("duration")`

281 

282 - `class TranscriptionVerbose:`

283 

284 Represents a verbose json transcription response returned by model, based on the provided input.

285 

286 - `double duration`

287 

288 The duration of the input audio.

289 

290 - `String language`

291 

292 The language of the input audio.

293 

294 - `String text`

295 

296 The transcribed text.

297 

298 - `Optional<List<TranscriptionSegment>> segments`

299 

300 Segments of the transcribed text and their corresponding details.

301 

302 - `long id`

303 

304 Unique identifier of the segment.

305 

306 - `double avgLogprob`

307 

308 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.

309 

310 - `double compressionRatio`

311 

312 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.

313 

314 - `double end`

315 

316 End time of the segment in seconds.

317 

318 - `double noSpeechProb`

319 

320 Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.

321 

322 - `long seek`

323 

324 Seek offset of the segment.

325 

326 - `double start`

327 

328 Start time of the segment in seconds.

329 

330 - `double temperature`

331 

332 Temperature parameter used for generating the segment.

333 

334 - `String text`

335 

336 Text content of the segment.

337 

338 - `List<long> tokens`

339 

340 Array of token IDs for the text content.

341 

342 - `Optional<Usage> usage`

343 

344 Usage statistics for models billed by audio input duration.

345 

346 - `double seconds`

347 

348 Duration of the input audio in seconds.

349 

350 - `JsonValue; type "duration"constant`

351 

352 The type of the usage object. Always `duration` for this variant.

353 

354 - `DURATION("duration")`

355 

356 - `Optional<List<TranscriptionWord>> words`

357 

358 Extracted words and their corresponding timestamps.

359 

360 - `double end`

361 

362 End time of the word in seconds.

363 

364 - `double start`

365 

366 Start time of the word in seconds.

367 

368 - `String word`

369 

370 The text content of the word.

371 

372### Example

373 

374```java

375package com.openai.example;

376 

377import com.openai.client.OpenAIClient;

378import com.openai.client.okhttp.OpenAIOkHttpClient;

379import com.openai.models.audio.AudioModel;

380import com.openai.models.audio.transcriptions.TranscriptionCreateParams;

381import com.openai.models.audio.transcriptions.TranscriptionCreateResponse;

382import java.io.ByteArrayInputStream;

383 

384public final class Main {

385 private Main() {}

386 

387 public static void main(String[] args) {

388 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

389 

390 TranscriptionCreateParams params = TranscriptionCreateParams.builder()

391 .file(new ByteArrayInputStream("Example data".getBytes()))

392 .model(AudioModel.GPT_4O_TRANSCRIBE)

393 .build();

394 TranscriptionCreateResponse transcription = client.audio().transcriptions().create(params);

395 }

396}

397```

398 

399#### Response

400 

401```json

402{

403 "text": "text",

404 "logprobs": [

405 {

406 "token": "token",

407 "bytes": [

408 0

409 ],

410 "logprob": 0

411 }

412 ],

413 "usage": {

414 "input_tokens": 0,

415 "output_tokens": 0,

416 "total_tokens": 0,

417 "type": "tokens",

418 "input_token_details": {

419 "audio_tokens": 0,

420 "text_tokens": 0

421 }

422 }

423}

424```

Details

1## Create translation

2 

3`TranslationCreateResponse audio().translations().create(TranslationCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/audio/translations`

6 

7Translates audio into English.

8 

9### Parameters

10 

11- `TranslationCreateParams params`

12 

13 - `String file`

14 

15 The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.

16 

17 - `AudioModel model`

18 

19 ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.

20 

21 - `Optional<String> prompt`

22 

23 An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting) should be in English.

24 

25 - `Optional<ResponseFormat> responseFormat`

26 

27 The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.

28 

29 - `JSON("json")`

30 

31 - `TEXT("text")`

32 

33 - `SRT("srt")`

34 

35 - `VERBOSE_JSON("verbose_json")`

36 

37 - `VTT("vtt")`

38 

39 - `Optional<Double> temperature`

40 

41 The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.

42 

43### Returns

44 

45- `class TranslationCreateResponse: A class that can be one of several variants.union`

46 

47 - `class Translation:`

48 

49 - `String text`

50 

51 - `class TranslationVerbose:`

52 

53 - `double duration`

54 

55 The duration of the input audio.

56 

57 - `String language`

58 

59 The language of the output translation (always `english`).

60 

61 - `String text`

62 

63 The translated text.

64 

65 - `Optional<List<TranscriptionSegment>> segments`

66 

67 Segments of the translated text and their corresponding details.

68 

69 - `long id`

70 

71 Unique identifier of the segment.

72 

73 - `double avgLogprob`

74 

75 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.

76 

77 - `double compressionRatio`

78 

79 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.

80 

81 - `double end`

82 

83 End time of the segment in seconds.

84 

85 - `double noSpeechProb`

86 

87 Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.

88 

89 - `long seek`

90 

91 Seek offset of the segment.

92 

93 - `double start`

94 

95 Start time of the segment in seconds.

96 

97 - `double temperature`

98 

99 Temperature parameter used for generating the segment.

100 

101 - `String text`

102 

103 Text content of the segment.

104 

105 - `List<long> tokens`

106 

107 Array of token IDs for the text content.

108 

109### Example

110 

111```java

112package com.openai.example;

113 

114import com.openai.client.OpenAIClient;

115import com.openai.client.okhttp.OpenAIOkHttpClient;

116import com.openai.models.audio.AudioModel;

117import com.openai.models.audio.translations.TranslationCreateParams;

118import com.openai.models.audio.translations.TranslationCreateResponse;

119import java.io.ByteArrayInputStream;

120 

121public final class Main {

122 private Main() {}

123 

124 public static void main(String[] args) {

125 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

126 

127 TranslationCreateParams params = TranslationCreateParams.builder()

128 .file(new ByteArrayInputStream("Example data".getBytes()))

129 .model(AudioModel.WHISPER_1)

130 .build();

131 TranslationCreateResponse translation = client.audio().translations().create(params);

132 }

133}

134```

135 

136#### Response

137 

138```json

139{

140 "text": "text"

141}

142```

Details

1## Create assistant

2 

3`Assistant beta().assistants().create(AssistantCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/assistants`

6 

7Create an assistant with a model and instructions.

8 

9### Parameters

10 

11- `AssistantCreateParams params`

12 

13 - `ChatModel model`

14 

15 ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them.

16 

17 - `Optional<String> description`

18 

19 The description of the assistant. The maximum length is 512 characters.

20 

21 - `Optional<String> instructions`

22 

23 The system instructions that the assistant uses. The maximum length is 256,000 characters.

24 

25 - `Optional<Metadata> metadata`

26 

27 Set of 16 key-value pairs that can be attached to an object. This can be

28 useful for storing additional information about the object in a structured

29 format, and querying for objects via API or the dashboard.

30 

31 Keys are strings with a maximum length of 64 characters. Values are strings

32 with a maximum length of 512 characters.

33 

34 - `Optional<String> name`

35 

36 The name of the assistant. The maximum length is 256 characters.

37 

38 - `Optional<ReasoningEffort> reasoningEffort`

39 

40 Constrains effort on reasoning for

41 [reasoning models](https://platform.openai.com/docs/guides/reasoning).

42 Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing

43 reasoning effort can result in faster responses and fewer tokens used

44 on reasoning in a response.

45 

46 - `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.

47 - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.

48 - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.

49 - `xhigh` is supported for all models after `gpt-5.1-codex-max`.

50 

51 - `Optional<AssistantResponseFormatOption> responseFormat`

52 

53 Specifies the format that the model must output. Compatible with [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

54 

55 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).

56 

57 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

58 

59 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

60 

61 - `Optional<Double> temperature`

62 

63 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.

64 

65 - `Optional<ToolResources> toolResources`

66 

67 A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

68 

69 - `Optional<CodeInterpreter> codeInterpreter`

70 

71 - `Optional<List<String>> fileIds`

72 

73 A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

74 

75 - `Optional<FileSearch> fileSearch`

76 

77 - `Optional<List<String>> vectorStoreIds`

78 

79 The [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

80 

81 - `Optional<List<VectorStore>> vectorStores`

82 

83 A helper to create a [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant.

84 

85 - `Optional<ChunkingStrategy> chunkingStrategy`

86 

87 The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.

88 

89 - `JsonValue;`

90 

91 - `JsonValue; type "auto"constant`

92 

93 Always `auto`.

94 

95 - `AUTO("auto")`

96 

97 - `class Static:`

98 

99 - `InnerStatic static_`

100 

101 - `long chunkOverlapTokens`

102 

103 The number of tokens that overlap between chunks. The default value is `400`.

104 

105 Note that the overlap must not exceed half of `max_chunk_size_tokens`.

106 

107 - `long maxChunkSizeTokens`

108 

109 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.

110 

111 - `JsonValue; type "static"constant`

112 

113 Always `static`.

114 

115 - `STATIC("static")`

116 

117 - `Optional<List<String>> fileIds`

118 

119 A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.

120 

121 - `Optional<Metadata> metadata`

122 

123 Set of 16 key-value pairs that can be attached to an object. This can be

124 useful for storing additional information about the object in a structured

125 format, and querying for objects via API or the dashboard.

126 

127 Keys are strings with a maximum length of 64 characters. Values are strings

128 with a maximum length of 512 characters.

129 

130 - `Optional<List<AssistantTool>> tools`

131 

132 A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.

133 

134 - `class CodeInterpreterTool:`

135 

136 - `JsonValue; type "code_interpreter"constant`

137 

138 The type of tool being defined: `code_interpreter`

139 

140 - `CODE_INTERPRETER("code_interpreter")`

141 

142 - `class FileSearchTool:`

143 

144 - `JsonValue; type "file_search"constant`

145 

146 The type of tool being defined: `file_search`

147 

148 - `FILE_SEARCH("file_search")`

149 

150 - `Optional<FileSearch> fileSearch`

151 

152 Overrides for the file search tool.

153 

154 - `Optional<Long> maxNumResults`

155 

156 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

157 

158 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

159 

160 - `Optional<RankingOptions> rankingOptions`

161 

162 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

163 

164 See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

165 

166 - `double scoreThreshold`

167 

168 The score threshold for the file search. All values must be a floating point number between 0 and 1.

169 

170 - `Optional<Ranker> ranker`

171 

172 The ranker to use for the file search. If not specified will use the `auto` ranker.

173 

174 - `AUTO("auto")`

175 

176 - `DEFAULT_2024_08_21("default_2024_08_21")`

177 

178 - `class FunctionTool:`

179 

180 - `FunctionDefinition function`

181 

182 - `String name`

183 

184 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.

185 

186 - `Optional<String> description`

187 

188 A description of what the function does, used by the model to choose when and how to call the function.

189 

190 - `Optional<FunctionParameters> parameters`

191 

192 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.

193 

194 Omitting `parameters` defines a function with an empty parameter list.

195 

196 - `Optional<Boolean> strict`

197 

198 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).

199 

200 - `JsonValue; type "function"constant`

201 

202 The type of tool being defined: `function`

203 

204 - `FUNCTION("function")`

205 

206 - `Optional<Double> topP`

207 

208 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

209 

210 We generally recommend altering this or temperature but not both.

211 

212### Returns

213 

214- `class Assistant:`

215 

216 Represents an `assistant` that can call the model and use tools.

217 

218 - `String id`

219 

220 The identifier, which can be referenced in API endpoints.

221 

222 - `long createdAt`

223 

224 The Unix timestamp (in seconds) for when the assistant was created.

225 

226 - `Optional<String> description`

227 

228 The description of the assistant. The maximum length is 512 characters.

229 

230 - `Optional<String> instructions`

231 

232 The system instructions that the assistant uses. The maximum length is 256,000 characters.

233 

234 - `Optional<Metadata> metadata`

235 

236 Set of 16 key-value pairs that can be attached to an object. This can be

237 useful for storing additional information about the object in a structured

238 format, and querying for objects via API or the dashboard.

239 

240 Keys are strings with a maximum length of 64 characters. Values are strings

241 with a maximum length of 512 characters.

242 

243 - `String model`

244 

245 ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them.

246 

247 - `Optional<String> name`

248 

249 The name of the assistant. The maximum length is 256 characters.

250 

251 - `JsonValue; object_ "assistant"constant`

252 

253 The object type, which is always `assistant`.

254 

255 - `ASSISTANT("assistant")`

256 

257 - `List<AssistantTool> tools`

258 

259 A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`.

260 

261 - `class CodeInterpreterTool:`

262 

263 - `JsonValue; type "code_interpreter"constant`

264 

265 The type of tool being defined: `code_interpreter`

266 

267 - `CODE_INTERPRETER("code_interpreter")`

268 

269 - `class FileSearchTool:`

270 

271 - `JsonValue; type "file_search"constant`

272 

273 The type of tool being defined: `file_search`

274 

275 - `FILE_SEARCH("file_search")`

276 

277 - `Optional<FileSearch> fileSearch`

278 

279 Overrides for the file search tool.

280 

281 - `Optional<Long> maxNumResults`

282 

283 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

284 

285 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

286 

287 - `Optional<RankingOptions> rankingOptions`

288 

289 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

290 

291 See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

292 

293 - `double scoreThreshold`

294 

295 The score threshold for the file search. All values must be a floating point number between 0 and 1.

296 

297 - `Optional<Ranker> ranker`

298 

299 The ranker to use for the file search. If not specified will use the `auto` ranker.

300 

301 - `AUTO("auto")`

302 

303 - `DEFAULT_2024_08_21("default_2024_08_21")`

304 

305 - `class FunctionTool:`

306 

307 - `FunctionDefinition function`

308 

309 - `String name`

310 

311 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.

312 

313 - `Optional<String> description`

314 

315 A description of what the function does, used by the model to choose when and how to call the function.

316 

317 - `Optional<FunctionParameters> parameters`

318 

319 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.

320 

321 Omitting `parameters` defines a function with an empty parameter list.

322 

323 - `Optional<Boolean> strict`

324 

325 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).

326 

327 - `JsonValue; type "function"constant`

328 

329 The type of tool being defined: `function`

330 

331 - `FUNCTION("function")`

332 

333 - `Optional<AssistantResponseFormatOption> responseFormat`

334 

335 Specifies the format that the model must output. Compatible with [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

336 

337 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).

338 

339 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

340 

341 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

342 

343 - `JsonValue;`

344 

345 - `AUTO("auto")`

346 

347 - `class ResponseFormatText:`

348 

349 Default response format. Used to generate text responses.

350 

351 - `JsonValue; type "text"constant`

352 

353 The type of response format being defined. Always `text`.

354 

355 - `TEXT("text")`

356 

357 - `class ResponseFormatJsonObject:`

358 

359 JSON object response format. An older method of generating JSON responses.

360 Using `json_schema` is recommended for models that support it. Note that the

361 model will not generate JSON without a system or user message instructing it

362 to do so.

363 

364 - `JsonValue; type "json_object"constant`

365 

366 The type of response format being defined. Always `json_object`.

367 

368 - `JSON_OBJECT("json_object")`

369 

370 - `class ResponseFormatJsonSchema:`

371 

372 JSON Schema response format. Used to generate structured JSON responses.

373 Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).

374 

375 - `JsonSchema jsonSchema`

376 

377 Structured Outputs configuration options, including a JSON Schema.

378 

379 - `String name`

380 

381 The name of the response format. Must be a-z, A-Z, 0-9, or contain

382 underscores and dashes, with a maximum length of 64.

383 

384 - `Optional<String> description`

385 

386 A description of what the response format is for, used by the model to

387 determine how to respond in the format.

388 

389 - `Optional<Schema> schema`

390 

391 The schema for the response format, described as a JSON Schema object.

392 Learn how to build JSON schemas [here](https://json-schema.org/).

393 

394 - `Optional<Boolean> strict`

395 

396 Whether to enable strict schema adherence when generating the output.

397 If set to true, the model will always follow the exact schema defined

398 in the `schema` field. Only a subset of JSON Schema is supported when

399 `strict` is `true`. To learn more, read the [Structured Outputs

400 guide](https://platform.openai.com/docs/guides/structured-outputs).

401 

402 - `JsonValue; type "json_schema"constant`

403 

404 The type of response format being defined. Always `json_schema`.

405 

406 - `JSON_SCHEMA("json_schema")`

407 

408 - `Optional<Double> temperature`

409 

410 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.

411 

412 - `Optional<ToolResources> toolResources`

413 

414 A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

415 

416 - `Optional<CodeInterpreter> codeInterpreter`

417 

418 - `Optional<List<String>> fileIds`

419 

420 A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool.

421 

422 - `Optional<FileSearch> fileSearch`

423 

424 - `Optional<List<String>> vectorStoreIds`

425 

426 The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

427 

428 - `Optional<Double> topP`

429 

430 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

431 

432 We generally recommend altering this or temperature but not both.

433 

434### Example

435 

436```java

437package com.openai.example;

438 

439import com.openai.client.OpenAIClient;

440import com.openai.client.okhttp.OpenAIOkHttpClient;

441import com.openai.models.ChatModel;

442import com.openai.models.beta.assistants.Assistant;

443import com.openai.models.beta.assistants.AssistantCreateParams;

444 

445public final class Main {

446 private Main() {}

447 

448 public static void main(String[] args) {

449 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

450 

451 AssistantCreateParams params = AssistantCreateParams.builder()

452 .model(ChatModel.GPT_4O)

453 .build();

454 Assistant assistant = client.beta().assistants().create(params);

455 }

456}

457```

458 

459#### Response

460 

461```json

462{

463 "id": "id",

464 "created_at": 0,

465 "description": "description",

466 "instructions": "instructions",

467 "metadata": {

468 "foo": "string"

469 },

470 "model": "model",

471 "name": "name",

472 "object": "assistant",

473 "tools": [

474 {

475 "type": "code_interpreter"

476 }

477 ],

478 "response_format": "auto",

479 "temperature": 1,

480 "tool_resources": {

481 "code_interpreter": {

482 "file_ids": [

483 "string"

484 ]

485 },

486 "file_search": {

487 "vector_store_ids": [

488 "string"

489 ]

490 }

491 },

492 "top_p": 1

493}

494```

Details

1## Create thread and run

2 

3`Run beta().threads().createAndRun(ThreadCreateAndRunParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/threads/runs`

6 

7Create a thread and run it in one request.

8 

9### Parameters

10 

11- `ThreadCreateAndRunParams params`

12 

13 - `String assistantId`

14 

15 The ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to execute this run.

16 

17 - `Optional<String> instructions`

18 

19 Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis.

20 

21 - `Optional<Long> maxCompletionTokens`

22 

23 The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.

24 

25 - `Optional<Long> maxPromptTokens`

26 

27 The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.

28 

29 - `Optional<Metadata> metadata`

30 

31 Set of 16 key-value pairs that can be attached to an object. This can be

32 useful for storing additional information about the object in a structured

33 format, and querying for objects via API or the dashboard.

34 

35 Keys are strings with a maximum length of 64 characters. Values are strings

36 with a maximum length of 512 characters.

37 

38 - `Optional<ChatModel> model`

39 

40 The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.

41 

42 - `Optional<Boolean> parallelToolCalls`

43 

44 Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

45 

46 - `Optional<AssistantResponseFormatOption> responseFormat`

47 

48 Specifies the format that the model must output. Compatible with [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

49 

50 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).

51 

52 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

53 

54 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

55 

56 - `Optional<Double> temperature`

57 

58 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.

59 

60 - `Optional<Thread> thread`

61 

62 Options to create a new thread. If no thread is provided when running a

63 request, an empty thread will be created.

64 

65 - `Optional<List<Message>> messages`

66 

67 A list of [messages](https://platform.openai.com/docs/api-reference/messages) to start the thread with.

68 

69 - `Content content`

70 

71 The text contents of the message.

72 

73 - `String`

74 

75 - `List<MessageContentPartParam>`

76 

77 - `class ImageFileContentBlock:`

78 

79 References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message.

80 

81 - `ImageFile imageFile`

82 

83 - `String fileId`

84 

85 The [File](https://platform.openai.com/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.

86 

87 - `Optional<Detail> detail`

88 

89 Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.

90 

91 - `AUTO("auto")`

92 

93 - `LOW("low")`

94 

95 - `HIGH("high")`

96 

97 - `JsonValue; type "image_file"constant`

98 

99 Always `image_file`.

100 

101 - `IMAGE_FILE("image_file")`

102 

103 - `class ImageUrlContentBlock:`

104 

105 References an image URL in the content of a message.

106 

107 - `ImageUrl imageUrl`

108 

109 - `String url`

110 

111 The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

112 

113 - `Optional<Detail> detail`

114 

115 Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`

116 

117 - `AUTO("auto")`

118 

119 - `LOW("low")`

120 

121 - `HIGH("high")`

122 

123 - `JsonValue; type "image_url"constant`

124 

125 The type of the content part.

126 

127 - `IMAGE_URL("image_url")`

128 

129 - `class TextContentBlockParam:`

130 

131 The text content that is part of a message.

132 

133 - `String text`

134 

135 Text content to be sent to the model

136 

137 - `JsonValue; type "text"constant`

138 

139 Always `text`.

140 

141 - `TEXT("text")`

142 

143 - `Role role`

144 

145 The role of the entity that is creating the message. Allowed values include:

146 

147 - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.

148 - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.

149 

150 - `USER("user")`

151 

152 - `ASSISTANT("assistant")`

153 

154 - `Optional<List<Attachment>> attachments`

155 

156 A list of files attached to the message, and the tools they should be added to.

157 

158 - `Optional<String> fileId`

159 

160 The ID of the file to attach to the message.

161 

162 - `Optional<List<Tool>> tools`

163 

164 The tools to add this file to.

165 

166 - `class CodeInterpreterTool:`

167 

168 - `JsonValue; type "code_interpreter"constant`

169 

170 The type of tool being defined: `code_interpreter`

171 

172 - `CODE_INTERPRETER("code_interpreter")`

173 

174 - `JsonValue;`

175 

176 - `JsonValue; type "file_search"constant`

177 

178 The type of tool being defined: `file_search`

179 

180 - `FILE_SEARCH("file_search")`

181 

182 - `Optional<Metadata> metadata`

183 

184 Set of 16 key-value pairs that can be attached to an object. This can be

185 useful for storing additional information about the object in a structured

186 format, and querying for objects via API or the dashboard.

187 

188 Keys are strings with a maximum length of 64 characters. Values are strings

189 with a maximum length of 512 characters.

190 

191 - `Optional<Metadata> metadata`

192 

193 Set of 16 key-value pairs that can be attached to an object. This can be

194 useful for storing additional information about the object in a structured

195 format, and querying for objects via API or the dashboard.

196 

197 Keys are strings with a maximum length of 64 characters. Values are strings

198 with a maximum length of 512 characters.

199 

200 - `Optional<ToolResources> toolResources`

201 

202 A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

203 

204 - `Optional<CodeInterpreter> codeInterpreter`

205 

206 - `Optional<List<String>> fileIds`

207 

208 A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

209 

210 - `Optional<FileSearch> fileSearch`

211 

212 - `Optional<List<String>> vectorStoreIds`

213 

214 The [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread.

215 

216 - `Optional<List<VectorStore>> vectorStores`

217 

218 A helper to create a [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread.

219 

220 - `Optional<ChunkingStrategy> chunkingStrategy`

221 

222 The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy.

223 

224 - `JsonValue;`

225 

226 - `JsonValue; type "auto"constant`

227 

228 Always `auto`.

229 

230 - `AUTO("auto")`

231 

232 - `class Static:`

233 

234 - `InnerStatic static_`

235 

236 - `long chunkOverlapTokens`

237 

238 The number of tokens that overlap between chunks. The default value is `400`.

239 

240 Note that the overlap must not exceed half of `max_chunk_size_tokens`.

241 

242 - `long maxChunkSizeTokens`

243 

244 The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`.

245 

246 - `JsonValue; type "static"constant`

247 

248 Always `static`.

249 

250 - `STATIC("static")`

251 

252 - `Optional<List<String>> fileIds`

253 

254 A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to add to the vector store. For vector stores created before Nov 2025, there can be a maximum of 10,000 files in a vector store. For vector stores created starting in Nov 2025, the limit is 100,000,000 files.

255 

256 - `Optional<Metadata> metadata`

257 

258 Set of 16 key-value pairs that can be attached to an object. This can be

259 useful for storing additional information about the object in a structured

260 format, and querying for objects via API or the dashboard.

261 

262 Keys are strings with a maximum length of 64 characters. Values are strings

263 with a maximum length of 512 characters.

264 

265 - `Optional<AssistantToolChoiceOption> toolChoice`

266 

267 Controls which (if any) tool is called by the model.

268 `none` means the model will not call any tools and instead generates a message.

269 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

270 `required` means the model must call one or more tools before responding to the user.

271 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

272 

273 - `Optional<ToolResources> toolResources`

274 

275 A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs.

276 

277 - `Optional<CodeInterpreter> codeInterpreter`

278 

279 - `Optional<List<String>> fileIds`

280 

281 A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool.

282 

283 - `Optional<FileSearch> fileSearch`

284 

285 - `Optional<List<String>> vectorStoreIds`

286 

287 The ID of the [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant.

288 

289 - `Optional<List<AssistantTool>> tools`

290 

291 Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.

292 

293 - `class CodeInterpreterTool:`

294 

295 - `class FileSearchTool:`

296 

297 - `JsonValue; type "file_search"constant`

298 

299 The type of tool being defined: `file_search`

300 

301 - `FILE_SEARCH("file_search")`

302 

303 - `Optional<FileSearch> fileSearch`

304 

305 Overrides for the file search tool.

306 

307 - `Optional<Long> maxNumResults`

308 

309 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

310 

311 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

312 

313 - `Optional<RankingOptions> rankingOptions`

314 

315 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

316 

317 See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

318 

319 - `double scoreThreshold`

320 

321 The score threshold for the file search. All values must be a floating point number between 0 and 1.

322 

323 - `Optional<Ranker> ranker`

324 

325 The ranker to use for the file search. If not specified will use the `auto` ranker.

326 

327 - `AUTO("auto")`

328 

329 - `DEFAULT_2024_08_21("default_2024_08_21")`

330 

331 - `class FunctionTool:`

332 

333 - `FunctionDefinition function`

334 

335 - `String name`

336 

337 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.

338 

339 - `Optional<String> description`

340 

341 A description of what the function does, used by the model to choose when and how to call the function.

342 

343 - `Optional<FunctionParameters> parameters`

344 

345 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.

346 

347 Omitting `parameters` defines a function with an empty parameter list.

348 

349 - `Optional<Boolean> strict`

350 

351 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).

352 

353 - `JsonValue; type "function"constant`

354 

355 The type of tool being defined: `function`

356 

357 - `FUNCTION("function")`

358 

359 - `Optional<Double> topP`

360 

361 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

362 

363 We generally recommend altering this or temperature but not both.

364 

365 - `Optional<TruncationStrategy> truncationStrategy`

366 

367 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

368 

369 - `Type type`

370 

371 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

372 

373 - `AUTO("auto")`

374 

375 - `LAST_MESSAGES("last_messages")`

376 

377 - `Optional<Long> lastMessages`

378 

379 The number of most recent messages from the thread when constructing the context for the run.

380 

381### Returns

382 

383- `class Run:`

384 

385 Represents an execution run on a [thread](https://platform.openai.com/docs/api-reference/threads).

386 

387 - `String id`

388 

389 The identifier, which can be referenced in API endpoints.

390 

391 - `String assistantId`

392 

393 The ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for execution of this run.

394 

395 - `Optional<Long> cancelledAt`

396 

397 The Unix timestamp (in seconds) for when the run was cancelled.

398 

399 - `Optional<Long> completedAt`

400 

401 The Unix timestamp (in seconds) for when the run was completed.

402 

403 - `long createdAt`

404 

405 The Unix timestamp (in seconds) for when the run was created.

406 

407 - `Optional<Long> expiresAt`

408 

409 The Unix timestamp (in seconds) for when the run will expire.

410 

411 - `Optional<Long> failedAt`

412 

413 The Unix timestamp (in seconds) for when the run failed.

414 

415 - `Optional<IncompleteDetails> incompleteDetails`

416 

417 Details on why the run is incomplete. Will be `null` if the run is not incomplete.

418 

419 - `Optional<Reason> reason`

420 

421 The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

422 

423 - `MAX_COMPLETION_TOKENS("max_completion_tokens")`

424 

425 - `MAX_PROMPT_TOKENS("max_prompt_tokens")`

426 

427 - `String instructions`

428 

429 The instructions that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run.

430 

431 - `Optional<LastError> lastError`

432 

433 The last error associated with this run. Will be `null` if there are no errors.

434 

435 - `Code code`

436 

437 One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.

438 

439 - `SERVER_ERROR("server_error")`

440 

441 - `RATE_LIMIT_EXCEEDED("rate_limit_exceeded")`

442 

443 - `INVALID_PROMPT("invalid_prompt")`

444 

445 - `String message`

446 

447 A human-readable description of the error.

448 

449 - `Optional<Long> maxCompletionTokens`

450 

451 The maximum number of completion tokens specified to have been used over the course of the run.

452 

453 - `Optional<Long> maxPromptTokens`

454 

455 The maximum number of prompt tokens specified to have been used over the course of the run.

456 

457 - `Optional<Metadata> metadata`

458 

459 Set of 16 key-value pairs that can be attached to an object. This can be

460 useful for storing additional information about the object in a structured

461 format, and querying for objects via API or the dashboard.

462 

463 Keys are strings with a maximum length of 64 characters. Values are strings

464 with a maximum length of 512 characters.

465 

466 - `String model`

467 

468 The model that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run.

469 

470 - `JsonValue; object_ "thread.run"constant`

471 

472 The object type, which is always `thread.run`.

473 

474 - `THREAD_RUN("thread.run")`

475 

476 - `boolean parallelToolCalls`

477 

478 Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

479 

480 - `Optional<RequiredAction> requiredAction`

481 

482 Details on the action required to continue the run. Will be `null` if no action is required.

483 

484 - `SubmitToolOutputs submitToolOutputs`

485 

486 Details on the tool outputs needed for this run to continue.

487 

488 - `List<RequiredActionFunctionToolCall> toolCalls`

489 

490 A list of the relevant tool calls.

491 

492 - `String id`

493 

494 The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) endpoint.

495 

496 - `Function function`

497 

498 The function definition.

499 

500 - `String arguments`

501 

502 The arguments that the model expects you to pass to the function.

503 

504 - `String name`

505 

506 The name of the function.

507 

508 - `JsonValue; type "function"constant`

509 

510 The type of tool call the output is required for. For now, this is always `function`.

511 

512 - `FUNCTION("function")`

513 

514 - `JsonValue; type "submit_tool_outputs"constant`

515 

516 For now, this is always `submit_tool_outputs`.

517 

518 - `SUBMIT_TOOL_OUTPUTS("submit_tool_outputs")`

519 

520 - `Optional<AssistantResponseFormatOption> responseFormat`

521 

522 Specifies the format that the model must output. Compatible with [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

523 

524 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).

525 

526 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

527 

528 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

529 

530 - `JsonValue;`

531 

532 - `AUTO("auto")`

533 

534 - `class ResponseFormatText:`

535 

536 Default response format. Used to generate text responses.

537 

538 - `JsonValue; type "text"constant`

539 

540 The type of response format being defined. Always `text`.

541 

542 - `TEXT("text")`

543 

544 - `class ResponseFormatJsonObject:`

545 

546 JSON object response format. An older method of generating JSON responses.

547 Using `json_schema` is recommended for models that support it. Note that the

548 model will not generate JSON without a system or user message instructing it

549 to do so.

550 

551 - `JsonValue; type "json_object"constant`

552 

553 The type of response format being defined. Always `json_object`.

554 

555 - `JSON_OBJECT("json_object")`

556 

557 - `class ResponseFormatJsonSchema:`

558 

559 JSON Schema response format. Used to generate structured JSON responses.

560 Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).

561 

562 - `JsonSchema jsonSchema`

563 

564 Structured Outputs configuration options, including a JSON Schema.

565 

566 - `String name`

567 

568 The name of the response format. Must be a-z, A-Z, 0-9, or contain

569 underscores and dashes, with a maximum length of 64.

570 

571 - `Optional<String> description`

572 

573 A description of what the response format is for, used by the model to

574 determine how to respond in the format.

575 

576 - `Optional<Schema> schema`

577 

578 The schema for the response format, described as a JSON Schema object.

579 Learn how to build JSON schemas [here](https://json-schema.org/).

580 

581 - `Optional<Boolean> strict`

582 

583 Whether to enable strict schema adherence when generating the output.

584 If set to true, the model will always follow the exact schema defined

585 in the `schema` field. Only a subset of JSON Schema is supported when

586 `strict` is `true`. To learn more, read the [Structured Outputs

587 guide](https://platform.openai.com/docs/guides/structured-outputs).

588 

589 - `JsonValue; type "json_schema"constant`

590 

591 The type of response format being defined. Always `json_schema`.

592 

593 - `JSON_SCHEMA("json_schema")`

594 

595 - `Optional<Long> startedAt`

596 

597 The Unix timestamp (in seconds) for when the run was started.

598 

599 - `RunStatus status`

600 

601 The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.

602 

603 - `QUEUED("queued")`

604 

605 - `IN_PROGRESS("in_progress")`

606 

607 - `REQUIRES_ACTION("requires_action")`

608 

609 - `CANCELLING("cancelling")`

610 

611 - `CANCELLED("cancelled")`

612 

613 - `FAILED("failed")`

614 

615 - `COMPLETED("completed")`

616 

617 - `INCOMPLETE("incomplete")`

618 

619 - `EXPIRED("expired")`

620 

621 - `String threadId`

622 

623 The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was executed on as a part of this run.

624 

625 - `Optional<AssistantToolChoiceOption> toolChoice`

626 

627 Controls which (if any) tool is called by the model.

628 `none` means the model will not call any tools and instead generates a message.

629 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

630 `required` means the model must call one or more tools before responding to the user.

631 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

632 

633 - `Auto`

634 

635 - `NONE("none")`

636 

637 - `AUTO("auto")`

638 

639 - `REQUIRED("required")`

640 

641 - `class AssistantToolChoice:`

642 

643 Specifies a tool the model should use. Use to force the model to call a specific tool.

644 

645 - `Type type`

646 

647 The type of the tool. If type is `function`, the function name must be set

648 

649 - `FUNCTION("function")`

650 

651 - `CODE_INTERPRETER("code_interpreter")`

652 

653 - `FILE_SEARCH("file_search")`

654 

655 - `Optional<AssistantToolChoiceFunction> function`

656 

657 - `String name`

658 

659 The name of the function to call.

660 

661 - `List<AssistantTool> tools`

662 

663 The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run.

664 

665 - `class CodeInterpreterTool:`

666 

667 - `JsonValue; type "code_interpreter"constant`

668 

669 The type of tool being defined: `code_interpreter`

670 

671 - `CODE_INTERPRETER("code_interpreter")`

672 

673 - `class FileSearchTool:`

674 

675 - `JsonValue; type "file_search"constant`

676 

677 The type of tool being defined: `file_search`

678 

679 - `FILE_SEARCH("file_search")`

680 

681 - `Optional<FileSearch> fileSearch`

682 

683 Overrides for the file search tool.

684 

685 - `Optional<Long> maxNumResults`

686 

687 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

688 

689 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

690 

691 - `Optional<RankingOptions> rankingOptions`

692 

693 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

694 

695 See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

696 

697 - `double scoreThreshold`

698 

699 The score threshold for the file search. All values must be a floating point number between 0 and 1.

700 

701 - `Optional<Ranker> ranker`

702 

703 The ranker to use for the file search. If not specified will use the `auto` ranker.

704 

705 - `AUTO("auto")`

706 

707 - `DEFAULT_2024_08_21("default_2024_08_21")`

708 

709 - `class FunctionTool:`

710 

711 - `FunctionDefinition function`

712 

713 - `String name`

714 

715 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.

716 

717 - `Optional<String> description`

718 

719 A description of what the function does, used by the model to choose when and how to call the function.

720 

721 - `Optional<FunctionParameters> parameters`

722 

723 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.

724 

725 Omitting `parameters` defines a function with an empty parameter list.

726 

727 - `Optional<Boolean> strict`

728 

729 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).

730 

731 - `JsonValue; type "function"constant`

732 

733 The type of tool being defined: `function`

734 

735 - `FUNCTION("function")`

736 

737 - `Optional<TruncationStrategy> truncationStrategy`

738 

739 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

740 

741 - `Type type`

742 

743 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

744 

745 - `AUTO("auto")`

746 

747 - `LAST_MESSAGES("last_messages")`

748 

749 - `Optional<Long> lastMessages`

750 

751 The number of most recent messages from the thread when constructing the context for the run.

752 

753 - `Optional<Usage> usage`

754 

755 Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).

756 

757 - `long completionTokens`

758 

759 Number of completion tokens used over the course of the run.

760 

761 - `long promptTokens`

762 

763 Number of prompt tokens used over the course of the run.

764 

765 - `long totalTokens`

766 

767 Total number of tokens used (prompt + completion).

768 

769 - `Optional<Double> temperature`

770 

771 The sampling temperature used for this run. If not set, defaults to 1.

772 

773 - `Optional<Double> topP`

774 

775 The nucleus sampling value used for this run. If not set, defaults to 1.

776 

777### Example

778 

779```java

780package com.openai.example;

781 

782import com.openai.client.OpenAIClient;

783import com.openai.client.okhttp.OpenAIOkHttpClient;

784import com.openai.models.beta.threads.ThreadCreateAndRunParams;

785import com.openai.models.beta.threads.runs.Run;

786 

787public final class Main {

788 private Main() {}

789 

790 public static void main(String[] args) {

791 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

792 

793 ThreadCreateAndRunParams params = ThreadCreateAndRunParams.builder()

794 .assistantId("assistant_id")

795 .build();

796 Run run = client.beta().threads().createAndRun(params);

797 }

798}

799```

800 

801#### Response

802 

803```json

804{

805 "id": "id",

806 "assistant_id": "assistant_id",

807 "cancelled_at": 0,

808 "completed_at": 0,

809 "created_at": 0,

810 "expires_at": 0,

811 "failed_at": 0,

812 "incomplete_details": {

813 "reason": "max_completion_tokens"

814 },

815 "instructions": "instructions",

816 "last_error": {

817 "code": "server_error",

818 "message": "message"

819 },

820 "max_completion_tokens": 256,

821 "max_prompt_tokens": 256,

822 "metadata": {

823 "foo": "string"

824 },

825 "model": "model",

826 "object": "thread.run",

827 "parallel_tool_calls": true,

828 "required_action": {

829 "submit_tool_outputs": {

830 "tool_calls": [

831 {

832 "id": "id",

833 "function": {

834 "arguments": "arguments",

835 "name": "name"

836 },

837 "type": "function"

838 }

839 ]

840 },

841 "type": "submit_tool_outputs"

842 },

843 "response_format": "auto",

844 "started_at": 0,

845 "status": "queued",

846 "thread_id": "thread_id",

847 "tool_choice": "none",

848 "tools": [

849 {

850 "type": "code_interpreter"

851 }

852 ],

853 "truncation_strategy": {

854 "type": "auto",

855 "last_messages": 1

856 },

857 "usage": {

858 "completion_tokens": 0,

859 "prompt_tokens": 0,

860 "total_tokens": 0

861 },

862 "temperature": 0,

863 "top_p": 0

864}

865```

Details

1## Create run

2 

3`Run beta().threads().runs().create(RunCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/threads/{thread_id}/runs`

6 

7Create a run.

8 

9### Parameters

10 

11- `RunCreateParams params`

12 

13 - `Optional<String> threadId`

14 

15 - `Optional<List<RunStepInclude>> include`

16 

17 A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content.

18 

19 See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

20 

21 - `STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT("step_details.tool_calls[*].file_search.results[*].content")`

22 

23 - `String assistantId`

24 

25 The ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to execute this run.

26 

27 - `Optional<String> additionalInstructions`

28 

29 Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions.

30 

31 - `Optional<List<AdditionalMessage>> additionalMessages`

32 

33 Adds additional messages to the thread before creating the run.

34 

35 - `Content content`

36 

37 The text contents of the message.

38 

39 - `String`

40 

41 - `List<MessageContentPartParam>`

42 

43 - `class ImageFileContentBlock:`

44 

45 References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message.

46 

47 - `ImageFile imageFile`

48 

49 - `String fileId`

50 

51 The [File](https://platform.openai.com/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content.

52 

53 - `Optional<Detail> detail`

54 

55 Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`.

56 

57 - `AUTO("auto")`

58 

59 - `LOW("low")`

60 

61 - `HIGH("high")`

62 

63 - `JsonValue; type "image_file"constant`

64 

65 Always `image_file`.

66 

67 - `IMAGE_FILE("image_file")`

68 

69 - `class ImageUrlContentBlock:`

70 

71 References an image URL in the content of a message.

72 

73 - `ImageUrl imageUrl`

74 

75 - `String url`

76 

77 The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp.

78 

79 - `Optional<Detail> detail`

80 

81 Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto`

82 

83 - `AUTO("auto")`

84 

85 - `LOW("low")`

86 

87 - `HIGH("high")`

88 

89 - `JsonValue; type "image_url"constant`

90 

91 The type of the content part.

92 

93 - `IMAGE_URL("image_url")`

94 

95 - `class TextContentBlockParam:`

96 

97 The text content that is part of a message.

98 

99 - `String text`

100 

101 Text content to be sent to the model

102 

103 - `JsonValue; type "text"constant`

104 

105 Always `text`.

106 

107 - `TEXT("text")`

108 

109 - `Role role`

110 

111 The role of the entity that is creating the message. Allowed values include:

112 

113 - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages.

114 - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.

115 

116 - `USER("user")`

117 

118 - `ASSISTANT("assistant")`

119 

120 - `Optional<List<Attachment>> attachments`

121 

122 A list of files attached to the message, and the tools they should be added to.

123 

124 - `Optional<String> fileId`

125 

126 The ID of the file to attach to the message.

127 

128 - `Optional<List<Tool>> tools`

129 

130 The tools to add this file to.

131 

132 - `class CodeInterpreterTool:`

133 

134 - `JsonValue; type "code_interpreter"constant`

135 

136 The type of tool being defined: `code_interpreter`

137 

138 - `CODE_INTERPRETER("code_interpreter")`

139 

140 - `JsonValue;`

141 

142 - `JsonValue; type "file_search"constant`

143 

144 The type of tool being defined: `file_search`

145 

146 - `FILE_SEARCH("file_search")`

147 

148 - `Optional<Metadata> metadata`

149 

150 Set of 16 key-value pairs that can be attached to an object. This can be

151 useful for storing additional information about the object in a structured

152 format, and querying for objects via API or the dashboard.

153 

154 Keys are strings with a maximum length of 64 characters. Values are strings

155 with a maximum length of 512 characters.

156 

157 - `Optional<String> instructions`

158 

159 Overrides the [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis.

160 

161 - `Optional<Long> maxCompletionTokens`

162 

163 The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.

164 

165 - `Optional<Long> maxPromptTokens`

166 

167 The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.

168 

169 - `Optional<Metadata> metadata`

170 

171 Set of 16 key-value pairs that can be attached to an object. This can be

172 useful for storing additional information about the object in a structured

173 format, and querying for objects via API or the dashboard.

174 

175 Keys are strings with a maximum length of 64 characters. Values are strings

176 with a maximum length of 512 characters.

177 

178 - `Optional<ChatModel> model`

179 

180 The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.

181 

182 - `Optional<Boolean> parallelToolCalls`

183 

184 Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

185 

186 - `Optional<ReasoningEffort> reasoningEffort`

187 

188 Constrains effort on reasoning for

189 [reasoning models](https://platform.openai.com/docs/guides/reasoning).

190 Currently supported values are `none`, `minimal`, `low`, `medium`, `high`, and `xhigh`. Reducing

191 reasoning effort can result in faster responses and fewer tokens used

192 on reasoning in a response.

193 

194 - `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.

195 - All models before `gpt-5.1` default to `medium` reasoning effort, and do not support `none`.

196 - The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.

197 - `xhigh` is supported for all models after `gpt-5.1-codex-max`.

198 

199 - `Optional<AssistantResponseFormatOption> responseFormat`

200 

201 Specifies the format that the model must output. Compatible with [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

202 

203 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).

204 

205 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

206 

207 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

208 

209 - `Optional<Double> temperature`

210 

211 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.

212 

213 - `Optional<AssistantToolChoiceOption> toolChoice`

214 

215 Controls which (if any) tool is called by the model.

216 `none` means the model will not call any tools and instead generates a message.

217 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

218 `required` means the model must call one or more tools before responding to the user.

219 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

220 

221 - `Optional<List<AssistantTool>> tools`

222 

223 Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.

224 

225 - `class CodeInterpreterTool:`

226 

227 - `class FileSearchTool:`

228 

229 - `JsonValue; type "file_search"constant`

230 

231 The type of tool being defined: `file_search`

232 

233 - `FILE_SEARCH("file_search")`

234 

235 - `Optional<FileSearch> fileSearch`

236 

237 Overrides for the file search tool.

238 

239 - `Optional<Long> maxNumResults`

240 

241 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

242 

243 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

244 

245 - `Optional<RankingOptions> rankingOptions`

246 

247 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

248 

249 See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

250 

251 - `double scoreThreshold`

252 

253 The score threshold for the file search. All values must be a floating point number between 0 and 1.

254 

255 - `Optional<Ranker> ranker`

256 

257 The ranker to use for the file search. If not specified will use the `auto` ranker.

258 

259 - `AUTO("auto")`

260 

261 - `DEFAULT_2024_08_21("default_2024_08_21")`

262 

263 - `class FunctionTool:`

264 

265 - `FunctionDefinition function`

266 

267 - `String name`

268 

269 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.

270 

271 - `Optional<String> description`

272 

273 A description of what the function does, used by the model to choose when and how to call the function.

274 

275 - `Optional<FunctionParameters> parameters`

276 

277 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.

278 

279 Omitting `parameters` defines a function with an empty parameter list.

280 

281 - `Optional<Boolean> strict`

282 

283 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).

284 

285 - `JsonValue; type "function"constant`

286 

287 The type of tool being defined: `function`

288 

289 - `FUNCTION("function")`

290 

291 - `Optional<Double> topP`

292 

293 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

294 

295 We generally recommend altering this or temperature but not both.

296 

297 - `Optional<TruncationStrategy> truncationStrategy`

298 

299 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

300 

301 - `Type type`

302 

303 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

304 

305 - `AUTO("auto")`

306 

307 - `LAST_MESSAGES("last_messages")`

308 

309 - `Optional<Long> lastMessages`

310 

311 The number of most recent messages from the thread when constructing the context for the run.

312 

313### Returns

314 

315- `class Run:`

316 

317 Represents an execution run on a [thread](https://platform.openai.com/docs/api-reference/threads).

318 

319 - `String id`

320 

321 The identifier, which can be referenced in API endpoints.

322 

323 - `String assistantId`

324 

325 The ID of the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for execution of this run.

326 

327 - `Optional<Long> cancelledAt`

328 

329 The Unix timestamp (in seconds) for when the run was cancelled.

330 

331 - `Optional<Long> completedAt`

332 

333 The Unix timestamp (in seconds) for when the run was completed.

334 

335 - `long createdAt`

336 

337 The Unix timestamp (in seconds) for when the run was created.

338 

339 - `Optional<Long> expiresAt`

340 

341 The Unix timestamp (in seconds) for when the run will expire.

342 

343 - `Optional<Long> failedAt`

344 

345 The Unix timestamp (in seconds) for when the run failed.

346 

347 - `Optional<IncompleteDetails> incompleteDetails`

348 

349 Details on why the run is incomplete. Will be `null` if the run is not incomplete.

350 

351 - `Optional<Reason> reason`

352 

353 The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

354 

355 - `MAX_COMPLETION_TOKENS("max_completion_tokens")`

356 

357 - `MAX_PROMPT_TOKENS("max_prompt_tokens")`

358 

359 - `String instructions`

360 

361 The instructions that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run.

362 

363 - `Optional<LastError> lastError`

364 

365 The last error associated with this run. Will be `null` if there are no errors.

366 

367 - `Code code`

368 

369 One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.

370 

371 - `SERVER_ERROR("server_error")`

372 

373 - `RATE_LIMIT_EXCEEDED("rate_limit_exceeded")`

374 

375 - `INVALID_PROMPT("invalid_prompt")`

376 

377 - `String message`

378 

379 A human-readable description of the error.

380 

381 - `Optional<Long> maxCompletionTokens`

382 

383 The maximum number of completion tokens specified to have been used over the course of the run.

384 

385 - `Optional<Long> maxPromptTokens`

386 

387 The maximum number of prompt tokens specified to have been used over the course of the run.

388 

389 - `Optional<Metadata> metadata`

390 

391 Set of 16 key-value pairs that can be attached to an object. This can be

392 useful for storing additional information about the object in a structured

393 format, and querying for objects via API or the dashboard.

394 

395 Keys are strings with a maximum length of 64 characters. Values are strings

396 with a maximum length of 512 characters.

397 

398 - `String model`

399 

400 The model that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run.

401 

402 - `JsonValue; object_ "thread.run"constant`

403 

404 The object type, which is always `thread.run`.

405 

406 - `THREAD_RUN("thread.run")`

407 

408 - `boolean parallelToolCalls`

409 

410 Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.

411 

412 - `Optional<RequiredAction> requiredAction`

413 

414 Details on the action required to continue the run. Will be `null` if no action is required.

415 

416 - `SubmitToolOutputs submitToolOutputs`

417 

418 Details on the tool outputs needed for this run to continue.

419 

420 - `List<RequiredActionFunctionToolCall> toolCalls`

421 

422 A list of the relevant tool calls.

423 

424 - `String id`

425 

426 The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs) endpoint.

427 

428 - `Function function`

429 

430 The function definition.

431 

432 - `String arguments`

433 

434 The arguments that the model expects you to pass to the function.

435 

436 - `String name`

437 

438 The name of the function.

439 

440 - `JsonValue; type "function"constant`

441 

442 The type of tool call the output is required for. For now, this is always `function`.

443 

444 - `FUNCTION("function")`

445 

446 - `JsonValue; type "submit_tool_outputs"constant`

447 

448 For now, this is always `submit_tool_outputs`.

449 

450 - `SUBMIT_TOOL_OUTPUTS("submit_tool_outputs")`

451 

452 - `Optional<AssistantResponseFormatOption> responseFormat`

453 

454 Specifies the format that the model must output. Compatible with [GPT-4o](https://platform.openai.com/docs/models#gpt-4o), [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

455 

456 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).

457 

458 Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

459 

460 **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.

461 

462 - `JsonValue;`

463 

464 - `AUTO("auto")`

465 

466 - `class ResponseFormatText:`

467 

468 Default response format. Used to generate text responses.

469 

470 - `JsonValue; type "text"constant`

471 

472 The type of response format being defined. Always `text`.

473 

474 - `TEXT("text")`

475 

476 - `class ResponseFormatJsonObject:`

477 

478 JSON object response format. An older method of generating JSON responses.

479 Using `json_schema` is recommended for models that support it. Note that the

480 model will not generate JSON without a system or user message instructing it

481 to do so.

482 

483 - `JsonValue; type "json_object"constant`

484 

485 The type of response format being defined. Always `json_object`.

486 

487 - `JSON_OBJECT("json_object")`

488 

489 - `class ResponseFormatJsonSchema:`

490 

491 JSON Schema response format. Used to generate structured JSON responses.

492 Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).

493 

494 - `JsonSchema jsonSchema`

495 

496 Structured Outputs configuration options, including a JSON Schema.

497 

498 - `String name`

499 

500 The name of the response format. Must be a-z, A-Z, 0-9, or contain

501 underscores and dashes, with a maximum length of 64.

502 

503 - `Optional<String> description`

504 

505 A description of what the response format is for, used by the model to

506 determine how to respond in the format.

507 

508 - `Optional<Schema> schema`

509 

510 The schema for the response format, described as a JSON Schema object.

511 Learn how to build JSON schemas [here](https://json-schema.org/).

512 

513 - `Optional<Boolean> strict`

514 

515 Whether to enable strict schema adherence when generating the output.

516 If set to true, the model will always follow the exact schema defined

517 in the `schema` field. Only a subset of JSON Schema is supported when

518 `strict` is `true`. To learn more, read the [Structured Outputs

519 guide](https://platform.openai.com/docs/guides/structured-outputs).

520 

521 - `JsonValue; type "json_schema"constant`

522 

523 The type of response format being defined. Always `json_schema`.

524 

525 - `JSON_SCHEMA("json_schema")`

526 

527 - `Optional<Long> startedAt`

528 

529 The Unix timestamp (in seconds) for when the run was started.

530 

531 - `RunStatus status`

532 

533 The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`.

534 

535 - `QUEUED("queued")`

536 

537 - `IN_PROGRESS("in_progress")`

538 

539 - `REQUIRES_ACTION("requires_action")`

540 

541 - `CANCELLING("cancelling")`

542 

543 - `CANCELLED("cancelled")`

544 

545 - `FAILED("failed")`

546 

547 - `COMPLETED("completed")`

548 

549 - `INCOMPLETE("incomplete")`

550 

551 - `EXPIRED("expired")`

552 

553 - `String threadId`

554 

555 The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) that was executed on as a part of this run.

556 

557 - `Optional<AssistantToolChoiceOption> toolChoice`

558 

559 Controls which (if any) tool is called by the model.

560 `none` means the model will not call any tools and instead generates a message.

561 `auto` is the default value and means the model can pick between generating a message or calling one or more tools.

562 `required` means the model must call one or more tools before responding to the user.

563 Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.

564 

565 - `Auto`

566 

567 - `NONE("none")`

568 

569 - `AUTO("auto")`

570 

571 - `REQUIRED("required")`

572 

573 - `class AssistantToolChoice:`

574 

575 Specifies a tool the model should use. Use to force the model to call a specific tool.

576 

577 - `Type type`

578 

579 The type of the tool. If type is `function`, the function name must be set

580 

581 - `FUNCTION("function")`

582 

583 - `CODE_INTERPRETER("code_interpreter")`

584 

585 - `FILE_SEARCH("file_search")`

586 

587 - `Optional<AssistantToolChoiceFunction> function`

588 

589 - `String name`

590 

591 The name of the function to call.

592 

593 - `List<AssistantTool> tools`

594 

595 The list of tools that the [assistant](https://platform.openai.com/docs/api-reference/assistants) used for this run.

596 

597 - `class CodeInterpreterTool:`

598 

599 - `JsonValue; type "code_interpreter"constant`

600 

601 The type of tool being defined: `code_interpreter`

602 

603 - `CODE_INTERPRETER("code_interpreter")`

604 

605 - `class FileSearchTool:`

606 

607 - `JsonValue; type "file_search"constant`

608 

609 The type of tool being defined: `file_search`

610 

611 - `FILE_SEARCH("file_search")`

612 

613 - `Optional<FileSearch> fileSearch`

614 

615 Overrides for the file search tool.

616 

617 - `Optional<Long> maxNumResults`

618 

619 The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive.

620 

621 Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

622 

623 - `Optional<RankingOptions> rankingOptions`

624 

625 The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0.

626 

627 See the [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings) for more information.

628 

629 - `double scoreThreshold`

630 

631 The score threshold for the file search. All values must be a floating point number between 0 and 1.

632 

633 - `Optional<Ranker> ranker`

634 

635 The ranker to use for the file search. If not specified will use the `auto` ranker.

636 

637 - `AUTO("auto")`

638 

639 - `DEFAULT_2024_08_21("default_2024_08_21")`

640 

641 - `class FunctionTool:`

642 

643 - `FunctionDefinition function`

644 

645 - `String name`

646 

647 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.

648 

649 - `Optional<String> description`

650 

651 A description of what the function does, used by the model to choose when and how to call the function.

652 

653 - `Optional<FunctionParameters> parameters`

654 

655 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.

656 

657 Omitting `parameters` defines a function with an empty parameter list.

658 

659 - `Optional<Boolean> strict`

660 

661 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).

662 

663 - `JsonValue; type "function"constant`

664 

665 The type of tool being defined: `function`

666 

667 - `FUNCTION("function")`

668 

669 - `Optional<TruncationStrategy> truncationStrategy`

670 

671 Controls for how a thread will be truncated prior to the run. Use this to control the initial context window of the run.

672 

673 - `Type type`

674 

675 The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`.

676 

677 - `AUTO("auto")`

678 

679 - `LAST_MESSAGES("last_messages")`

680 

681 - `Optional<Long> lastMessages`

682 

683 The number of most recent messages from the thread when constructing the context for the run.

684 

685 - `Optional<Usage> usage`

686 

687 Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.).

688 

689 - `long completionTokens`

690 

691 Number of completion tokens used over the course of the run.

692 

693 - `long promptTokens`

694 

695 Number of prompt tokens used over the course of the run.

696 

697 - `long totalTokens`

698 

699 Total number of tokens used (prompt + completion).

700 

701 - `Optional<Double> temperature`

702 

703 The sampling temperature used for this run. If not set, defaults to 1.

704 

705 - `Optional<Double> topP`

706 

707 The nucleus sampling value used for this run. If not set, defaults to 1.

708 

709### Example

710 

711```java

712package com.openai.example;

713 

714import com.openai.client.OpenAIClient;

715import com.openai.client.okhttp.OpenAIOkHttpClient;

716import com.openai.models.beta.threads.runs.Run;

717import com.openai.models.beta.threads.runs.RunCreateParams;

718 

719public final class Main {

720 private Main() {}

721 

722 public static void main(String[] args) {

723 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

724 

725 RunCreateParams params = RunCreateParams.builder()

726 .threadId("thread_id")

727 .assistantId("assistant_id")

728 .build();

729 Run run = client.beta().threads().runs().create(params);

730 }

731}

732```

733 

734#### Response

735 

736```json

737{

738 "id": "id",

739 "assistant_id": "assistant_id",

740 "cancelled_at": 0,

741 "completed_at": 0,

742 "created_at": 0,

743 "expires_at": 0,

744 "failed_at": 0,

745 "incomplete_details": {

746 "reason": "max_completion_tokens"

747 },

748 "instructions": "instructions",

749 "last_error": {

750 "code": "server_error",

751 "message": "message"

752 },

753 "max_completion_tokens": 256,

754 "max_prompt_tokens": 256,

755 "metadata": {

756 "foo": "string"

757 },

758 "model": "model",

759 "object": "thread.run",

760 "parallel_tool_calls": true,

761 "required_action": {

762 "submit_tool_outputs": {

763 "tool_calls": [

764 {

765 "id": "id",

766 "function": {

767 "arguments": "arguments",

768 "name": "name"

769 },

770 "type": "function"

771 }

772 ]

773 },

774 "type": "submit_tool_outputs"

775 },

776 "response_format": "auto",

777 "started_at": 0,

778 "status": "queued",

779 "thread_id": "thread_id",

780 "tool_choice": "none",

781 "tools": [

782 {

783 "type": "code_interpreter"

784 }

785 ],

786 "truncation_strategy": {

787 "type": "auto",

788 "last_messages": 1

789 },

790 "usage": {

791 "completion_tokens": 0,

792 "prompt_tokens": 0,

793 "total_tokens": 0

794 },

795 "temperature": 0,

796 "top_p": 0

797}

798```

Details

379 characteristics, and price points. Refer to the [model guide](https://platform.openai.com/docs/models)379 characteristics, and price points. Refer to the [model guide](https://platform.openai.com/docs/models)

380 to browse and compare available models.380 to browse and compare available models.

381 381 

382 - `GPT_5_4("gpt-5.4")`

383 

384 - `GPT_5_4_MINI("gpt-5.4-mini")`

385 

386 - `GPT_5_4_NANO("gpt-5.4-nano")`

387 

388 - `GPT_5_4_MINI_2026_03_17("gpt-5.4-mini-2026-03-17")`

389 

390 - `GPT_5_4_NANO_2026_03_17("gpt-5.4-nano-2026-03-17")`

391 

392 - `GPT_5_3_CHAT_LATEST("gpt-5.3-chat-latest")`

393 

394 - `GPT_5_2("gpt-5.2")`

395 

396 - `GPT_5_2_2025_12_11("gpt-5.2-2025-12-11")`

397 

398 - `GPT_5_2_CHAT_LATEST("gpt-5.2-chat-latest")`

399 

400 - `GPT_5_2_PRO("gpt-5.2-pro")`

401 

402 - `GPT_5_2_PRO_2025_12_11("gpt-5.2-pro-2025-12-11")`

403 

404 - `GPT_5_1("gpt-5.1")`

405 

406 - `GPT_5_1_2025_11_13("gpt-5.1-2025-11-13")`

407 

408 - `GPT_5_1_CODEX("gpt-5.1-codex")`

409 

410 - `GPT_5_1_MINI("gpt-5.1-mini")`

411 

412 - `GPT_5_1_CHAT_LATEST("gpt-5.1-chat-latest")`

413 

414 - `GPT_5("gpt-5")`

415 

416 - `GPT_5_MINI("gpt-5-mini")`

417 

418 - `GPT_5_NANO("gpt-5-nano")`

419 

420 - `GPT_5_2025_08_07("gpt-5-2025-08-07")`

421 

422 - `GPT_5_MINI_2025_08_07("gpt-5-mini-2025-08-07")`

423 

424 - `GPT_5_NANO_2025_08_07("gpt-5-nano-2025-08-07")`

425 

426 - `GPT_5_CHAT_LATEST("gpt-5-chat-latest")`

427 

428 - `GPT_4_1("gpt-4.1")`

429 

430 - `GPT_4_1_MINI("gpt-4.1-mini")`

431 

432 - `GPT_4_1_NANO("gpt-4.1-nano")`

433 

434 - `GPT_4_1_2025_04_14("gpt-4.1-2025-04-14")`

435 

436 - `GPT_4_1_MINI_2025_04_14("gpt-4.1-mini-2025-04-14")`

437 

438 - `GPT_4_1_NANO_2025_04_14("gpt-4.1-nano-2025-04-14")`

439 

440 - `O4_MINI("o4-mini")`

441 

442 - `O4_MINI_2025_04_16("o4-mini-2025-04-16")`

443 

444 - `O3("o3")`

445 

446 - `O3_2025_04_16("o3-2025-04-16")`

447 

448 - `O3_MINI("o3-mini")`

449 

450 - `O3_MINI_2025_01_31("o3-mini-2025-01-31")`

451 

452 - `O1("o1")`

453 

454 - `O1_2024_12_17("o1-2024-12-17")`

455 

456 - `O1_PREVIEW("o1-preview")`

457 

458 - `O1_PREVIEW_2024_09_12("o1-preview-2024-09-12")`

459 

460 - `O1_MINI("o1-mini")`

461 

462 - `O1_MINI_2024_09_12("o1-mini-2024-09-12")`

463 

464 - `GPT_4O("gpt-4o")`

465 

466 - `GPT_4O_2024_11_20("gpt-4o-2024-11-20")`

467 

468 - `GPT_4O_2024_08_06("gpt-4o-2024-08-06")`

469 

470 - `GPT_4O_2024_05_13("gpt-4o-2024-05-13")`

471 

472 - `GPT_4O_AUDIO_PREVIEW("gpt-4o-audio-preview")`

473 

474 - `GPT_4O_AUDIO_PREVIEW_2024_10_01("gpt-4o-audio-preview-2024-10-01")`

475 

476 - `GPT_4O_AUDIO_PREVIEW_2024_12_17("gpt-4o-audio-preview-2024-12-17")`

477 

478 - `GPT_4O_AUDIO_PREVIEW_2025_06_03("gpt-4o-audio-preview-2025-06-03")`

479 

480 - `GPT_4O_MINI_AUDIO_PREVIEW("gpt-4o-mini-audio-preview")`

481 

482 - `GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17("gpt-4o-mini-audio-preview-2024-12-17")`

483 

484 - `GPT_4O_SEARCH_PREVIEW("gpt-4o-search-preview")`

485 

486 - `GPT_4O_MINI_SEARCH_PREVIEW("gpt-4o-mini-search-preview")`

487 

488 - `GPT_4O_SEARCH_PREVIEW_2025_03_11("gpt-4o-search-preview-2025-03-11")`

489 

490 - `GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11("gpt-4o-mini-search-preview-2025-03-11")`

491 

492 - `CHATGPT_4O_LATEST("chatgpt-4o-latest")`

493 

494 - `CODEX_MINI_LATEST("codex-mini-latest")`

495 

496 - `GPT_4O_MINI("gpt-4o-mini")`

497 

498 - `GPT_4O_MINI_2024_07_18("gpt-4o-mini-2024-07-18")`

499 

500 - `GPT_4_TURBO("gpt-4-turbo")`

501 

502 - `GPT_4_TURBO_2024_04_09("gpt-4-turbo-2024-04-09")`

503 

504 - `GPT_4_0125_PREVIEW("gpt-4-0125-preview")`

505 

506 - `GPT_4_TURBO_PREVIEW("gpt-4-turbo-preview")`

507 

508 - `GPT_4_1106_PREVIEW("gpt-4-1106-preview")`

509 

510 - `GPT_4_VISION_PREVIEW("gpt-4-vision-preview")`

511 

512 - `GPT_4("gpt-4")`

513 

514 - `GPT_4_0314("gpt-4-0314")`

515 

516 - `GPT_4_0613("gpt-4-0613")`

517 

518 - `GPT_4_32K("gpt-4-32k")`

519 

520 - `GPT_4_32K_0314("gpt-4-32k-0314")`

521 

522 - `GPT_4_32K_0613("gpt-4-32k-0613")`

523 

524 - `GPT_3_5_TURBO("gpt-3.5-turbo")`

525 

526 - `GPT_3_5_TURBO_16K("gpt-3.5-turbo-16k")`

527 

528 - `GPT_3_5_TURBO_0301("gpt-3.5-turbo-0301")`

529 

530 - `GPT_3_5_TURBO_0613("gpt-3.5-turbo-0613")`

531 

532 - `GPT_3_5_TURBO_1106("gpt-3.5-turbo-1106")`

533 

534 - `GPT_3_5_TURBO_0125("gpt-3.5-turbo-0125")`

535 

536 - `GPT_3_5_TURBO_16K_0613("gpt-3.5-turbo-16k-0613")`

537 

538 - `Optional<ChatCompletionAudioParam> audio`382 - `Optional<ChatCompletionAudioParam> audio`

539 383 

540 Parameters for audio output. Required when audio output is requested with384 Parameters for audio output. Required when audio output is requested with

Details

1## Create embeddings

2 

3`CreateEmbeddingResponse embeddings().create(EmbeddingCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/embeddings`

6 

7Creates an embedding vector representing the input text.

8 

9### Parameters

10 

11- `EmbeddingCreateParams params`

12 

13 - `Input input`

14 

15 Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for all embedding models), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. In addition to the per-input token limit, all embedding models enforce a maximum of 300,000 tokens summed across all inputs in a single request.

16 

17 - `String`

18 

19 - `List<String>`

20 

21 - `List<long>`

22 

23 - `List<List<long>>`

24 

25 - `EmbeddingModel model`

26 

27 ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them.

28 

29 - `Optional<Long> dimensions`

30 

31 The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models.

32 

33 - `Optional<EncodingFormat> encodingFormat`

34 

35 The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/).

36 

37 - `FLOAT("float")`

38 

39 - `BASE64("base64")`

40 

41 - `Optional<String> user`

42 

43 A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

44 

45### Returns

46 

47- `class CreateEmbeddingResponse:`

48 

49 - `List<Embedding> data`

50 

51 The list of embeddings generated by the model.

52 

53 - `List<double> embedding`

54 

55 The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](https://platform.openai.com/docs/guides/embeddings).

56 

57 - `long index`

58 

59 The index of the embedding in the list of embeddings.

60 

61 - `JsonValue; object_ "embedding"constant`

62 

63 The object type, which is always "embedding".

64 

65 - `EMBEDDING("embedding")`

66 

67 - `String model`

68 

69 The name of the model used to generate the embedding.

70 

71 - `JsonValue; object_ "list"constant`

72 

73 The object type, which is always "list".

74 

75 - `LIST("list")`

76 

77 - `Usage usage`

78 

79 The usage information for the request.

80 

81 - `long promptTokens`

82 

83 The number of tokens used by the prompt.

84 

85 - `long totalTokens`

86 

87 The total number of tokens used by the request.

88 

89### Example

90 

91```java

92package com.openai.example;

93 

94import com.openai.client.OpenAIClient;

95import com.openai.client.okhttp.OpenAIOkHttpClient;

96import com.openai.models.embeddings.CreateEmbeddingResponse;

97import com.openai.models.embeddings.EmbeddingCreateParams;

98import com.openai.models.embeddings.EmbeddingModel;

99 

100public final class Main {

101 private Main() {}

102 

103 public static void main(String[] args) {

104 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

105 

106 EmbeddingCreateParams params = EmbeddingCreateParams.builder()

107 .input("The quick brown fox jumped over the lazy dog")

108 .model(EmbeddingModel.TEXT_EMBEDDING_3_SMALL)

109 .build();

110 CreateEmbeddingResponse createEmbeddingResponse = client.embeddings().create(params);

111 }

112}

113```

114 

115#### Response

116 

117```json

118{

119 "data": [

120 {

121 "embedding": [

122 0

123 ],

124 "index": 0,

125 "object": "embedding"

126 }

127 ],

128 "model": "model",

129 "object": "list",

130 "usage": {

131 "prompt_tokens": 0,

132 "total_tokens": 0

133 }

134}

135```

Details

1## Create image variation

2 

3`ImagesResponse images().createVariation(ImageCreateVariationParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/images/variations`

6 

7Creates a variation of a given image. This endpoint only supports `dall-e-2`.

8 

9### Parameters

10 

11- `ImageCreateVariationParams params`

12 

13 - `String image`

14 

15 The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.

16 

17 - `Optional<ImageModel> model`

18 

19 The model to use for image generation. Only `dall-e-2` is supported at this time.

20 

21 - `Optional<Long> n`

22 

23 The number of images to generate. Must be between 1 and 10.

24 

25 - `Optional<ResponseFormat> responseFormat`

26 

27 The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated.

28 

29 - `URL("url")`

30 

31 - `B64_JSON("b64_json")`

32 

33 - `Optional<Size> size`

34 

35 The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.

36 

37 - `_256X256("256x256")`

38 

39 - `_512X512("512x512")`

40 

41 - `_1024X1024("1024x1024")`

42 

43 - `Optional<String> user`

44 

45 A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

46 

47### Returns

48 

49- `class ImagesResponse:`

50 

51 The response from the image generation endpoint.

52 

53 - `long created`

54 

55 The Unix timestamp (in seconds) of when the image was created.

56 

57 - `Optional<Background> background`

58 

59 The background parameter used for the image generation. Either `transparent` or `opaque`.

60 

61 - `TRANSPARENT("transparent")`

62 

63 - `OPAQUE("opaque")`

64 

65 - `Optional<List<Image>> data`

66 

67 The list of generated images.

68 

69 - `Optional<String> b64Json`

70 

71 The base64-encoded JSON of the generated image. Returned by default for the GPT image models, and only present if `response_format` is set to `b64_json` for `dall-e-2` and `dall-e-3`.

72 

73 - `Optional<String> revisedPrompt`

74 

75 For `dall-e-3` only, the revised prompt that was used to generate the image.

76 

77 - `Optional<String> url`

78 

79 When using `dall-e-2` or `dall-e-3`, the URL of the generated image if `response_format` is set to `url` (default value). Unsupported for the GPT image models.

80 

81 - `Optional<OutputFormat> outputFormat`

82 

83 The output format of the image generation. Either `png`, `webp`, or `jpeg`.

84 

85 - `PNG("png")`

86 

87 - `WEBP("webp")`

88 

89 - `JPEG("jpeg")`

90 

91 - `Optional<Quality> quality`

92 

93 The quality of the image generated. Either `low`, `medium`, or `high`.

94 

95 - `LOW("low")`

96 

97 - `MEDIUM("medium")`

98 

99 - `HIGH("high")`

100 

101 - `Optional<Size> size`

102 

103 The size of the image generated. Either `1024x1024`, `1024x1536`, or `1536x1024`.

104 

105 - `_1024X1024("1024x1024")`

106 

107 - `_1024X1536("1024x1536")`

108 

109 - `_1536X1024("1536x1024")`

110 

111 - `Optional<Usage> usage`

112 

113 For `gpt-image-1` only, the token usage information for the image generation.

114 

115 - `long inputTokens`

116 

117 The number of tokens (images and text) in the input prompt.

118 

119 - `InputTokensDetails inputTokensDetails`

120 

121 The input tokens detailed information for the image generation.

122 

123 - `long imageTokens`

124 

125 The number of image tokens in the input prompt.

126 

127 - `long textTokens`

128 

129 The number of text tokens in the input prompt.

130 

131 - `long outputTokens`

132 

133 The number of output tokens generated by the model.

134 

135 - `long totalTokens`

136 

137 The total number of tokens (images and text) used for the image generation.

138 

139 - `Optional<OutputTokensDetails> outputTokensDetails`

140 

141 The output token details for the image generation.

142 

143 - `long imageTokens`

144 

145 The number of image output tokens generated by the model.

146 

147 - `long textTokens`

148 

149 The number of text output tokens generated by the model.

150 

151### Example

152 

153```java

154package com.openai.example;

155 

156import com.openai.client.OpenAIClient;

157import com.openai.client.okhttp.OpenAIOkHttpClient;

158import com.openai.models.images.ImageCreateVariationParams;

159import com.openai.models.images.ImagesResponse;

160import java.io.ByteArrayInputStream;

161 

162public final class Main {

163 private Main() {}

164 

165 public static void main(String[] args) {

166 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

167 

168 ImageCreateVariationParams params = ImageCreateVariationParams.builder()

169 .image(new ByteArrayInputStream("Example data".getBytes()))

170 .build();

171 ImagesResponse imagesResponse = client.images().createVariation(params);

172 }

173}

174```

175 

176#### Response

177 

178```json

179{

180 "created": 0,

181 "background": "transparent",

182 "data": [

183 {

184 "b64_json": "b64_json",

185 "revised_prompt": "revised_prompt",

186 "url": "https://example.com"

187 }

188 ],

189 "output_format": "png",

190 "quality": "low",

191 "size": "1024x1024",

192 "usage": {

193 "input_tokens": 0,

194 "input_tokens_details": {

195 "image_tokens": 0,

196 "text_tokens": 0

197 },

198 "output_tokens": 0,

199 "total_tokens": 0,

200 "output_tokens_details": {

201 "image_tokens": 0,

202 "text_tokens": 0

203 }

204 }

205}

206```

Details

1## Create image edit

2 

3`ImagesResponse images().edit(ImageEditParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/images/edits`

6 

7Creates an edited or extended image given one or more source images and a prompt. This endpoint supports GPT Image models (`gpt-image-1.5`, `gpt-image-1`, `gpt-image-1-mini`, and `chatgpt-image-latest`) and `dall-e-2`.

8 

9### Parameters

10 

11- `ImageEditParams params`

12 

13 - `Image image`

14 

15 The image(s) to edit. Must be a supported image file or an array of images.

16 

17 For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`,

18 `gpt-image-1.5`, `gpt-image-2`, `gpt-image-2-2026-04-21`, and

19 `chatgpt-image-latest`), each image should be a `png`, `webp`, or

20 `jpg` file less than 50MB. You can provide up to 16 images.

21 

22 For `dall-e-2`, you can only provide one image, and it should be a

23 square `png` file less than 4MB.

24 

25 - `String`

26 

27 - `List<String>`

28 

29 - `String prompt`

30 

31 A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2`, and 32000 characters for the GPT image models.

32 

33 - `Optional<Background> background`

34 

35 Allows to set transparency for the background of the generated image(s).

36 This parameter is only supported for GPT image models that support

37 transparent backgrounds. Must be one of `transparent`, `opaque`, or

38 `auto` (default value). When `auto` is used, the model will

39 automatically determine the best background for the image.

40 

41 `gpt-image-2` and `gpt-image-2-2026-04-21` do not support

42 transparent backgrounds. Requests with `background` set to

43 `transparent` will return an error for these models; use `opaque` or

44 `auto` instead.

45 

46 If `transparent`, the output format needs to support transparency,

47 so it should be set to either `png` (default value) or `webp`.

48 

49 - `TRANSPARENT("transparent")`

50 

51 - `OPAQUE("opaque")`

52 

53 - `AUTO("auto")`

54 

55 - `Optional<InputFidelity> inputFidelity`

56 

57 Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1` and `gpt-image-1.5` and later models, unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.

58 

59 - `HIGH("high")`

60 

61 - `LOW("low")`

62 

63 - `Optional<String> mask`

64 

65 An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. If there are multiple images provided, the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.

66 

67 - `Optional<ImageModel> model`

68 

69 The model to use for image generation. One of `dall-e-2` or a GPT image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to `gpt-image-1.5`.

70 

71 - `Optional<Long> n`

72 

73 The number of images to generate. Must be between 1 and 10.

74 

75 - `Optional<Long> outputCompression`

76 

77 The compression level (0-100%) for the generated images. This parameter

78 is only supported for the GPT image models with the `webp` or `jpeg` output

79 formats, and defaults to 100.

80 

81 - `Optional<OutputFormat> outputFormat`

82 

83 The format in which the generated images are returned. This parameter is

84 only supported for the GPT image models. Must be one of `png`, `jpeg`, or `webp`.

85 The default value is `png`.

86 

87 - `PNG("png")`

88 

89 - `JPEG("jpeg")`

90 

91 - `WEBP("webp")`

92 

93 - `Optional<Long> partialImages`

94 

95 The number of partial images to generate. This parameter is used for

96 streaming responses that return partial images. Value must be between 0 and 3.

97 When set to 0, the response will be a single image sent in one streaming event.

98 

99 Note that the final image may be sent before the full number of partial images

100 are generated if the full image is generated more quickly.

101 

102 - `Optional<Quality> quality`

103 

104 The quality of the image that will be generated for GPT image models. Defaults to `auto`.

105 

106 - `STANDARD("standard")`

107 

108 - `LOW("low")`

109 

110 - `MEDIUM("medium")`

111 

112 - `HIGH("high")`

113 

114 - `AUTO("auto")`

115 

116 - `Optional<ResponseFormat> responseFormat`

117 

118 The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. This parameter is only supported for `dall-e-2` (default is `url` for `dall-e-2`), as GPT image models always return base64-encoded images.

119 

120 - `URL("url")`

121 

122 - `B64_JSON("b64_json")`

123 

124 - `Optional<Size> size`

125 

126 The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`.

127 

128 - `_256X256("256x256")`

129 

130 - `_512X512("512x512")`

131 

132 - `_1024X1024("1024x1024")`

133 

134 - `_1536X1024("1536x1024")`

135 

136 - `_1024X1536("1024x1536")`

137 

138 - `AUTO("auto")`

139 

140 - `Optional<String> user`

141 

142 A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

143 

144### Returns

145 

146- `class ImagesResponse:`

147 

148 The response from the image generation endpoint.

149 

150 - `long created`

151 

152 The Unix timestamp (in seconds) of when the image was created.

153 

154 - `Optional<Background> background`

155 

156 The background parameter used for the image generation. Either `transparent` or `opaque`.

157 

158 - `TRANSPARENT("transparent")`

159 

160 - `OPAQUE("opaque")`

161 

162 - `Optional<List<Image>> data`

163 

164 The list of generated images.

165 

166 - `Optional<String> b64Json`

167 

168 The base64-encoded JSON of the generated image. Returned by default for the GPT image models, and only present if `response_format` is set to `b64_json` for `dall-e-2` and `dall-e-3`.

169 

170 - `Optional<String> revisedPrompt`

171 

172 For `dall-e-3` only, the revised prompt that was used to generate the image.

173 

174 - `Optional<String> url`

175 

176 When using `dall-e-2` or `dall-e-3`, the URL of the generated image if `response_format` is set to `url` (default value). Unsupported for the GPT image models.

177 

178 - `Optional<OutputFormat> outputFormat`

179 

180 The output format of the image generation. Either `png`, `webp`, or `jpeg`.

181 

182 - `PNG("png")`

183 

184 - `WEBP("webp")`

185 

186 - `JPEG("jpeg")`

187 

188 - `Optional<Quality> quality`

189 

190 The quality of the image generated. Either `low`, `medium`, or `high`.

191 

192 - `LOW("low")`

193 

194 - `MEDIUM("medium")`

195 

196 - `HIGH("high")`

197 

198 - `Optional<Size> size`

199 

200 The size of the image generated. Either `1024x1024`, `1024x1536`, or `1536x1024`.

201 

202 - `_1024X1024("1024x1024")`

203 

204 - `_1024X1536("1024x1536")`

205 

206 - `_1536X1024("1536x1024")`

207 

208 - `Optional<Usage> usage`

209 

210 For `gpt-image-1` only, the token usage information for the image generation.

211 

212 - `long inputTokens`

213 

214 The number of tokens (images and text) in the input prompt.

215 

216 - `InputTokensDetails inputTokensDetails`

217 

218 The input tokens detailed information for the image generation.

219 

220 - `long imageTokens`

221 

222 The number of image tokens in the input prompt.

223 

224 - `long textTokens`

225 

226 The number of text tokens in the input prompt.

227 

228 - `long outputTokens`

229 

230 The number of output tokens generated by the model.

231 

232 - `long totalTokens`

233 

234 The total number of tokens (images and text) used for the image generation.

235 

236 - `Optional<OutputTokensDetails> outputTokensDetails`

237 

238 The output token details for the image generation.

239 

240 - `long imageTokens`

241 

242 The number of image output tokens generated by the model.

243 

244 - `long textTokens`

245 

246 The number of text output tokens generated by the model.

247 

248### Example

249 

250```java

251package com.openai.example;

252 

253import com.openai.client.OpenAIClient;

254import com.openai.client.okhttp.OpenAIOkHttpClient;

255import com.openai.models.images.ImageEditParams;

256import com.openai.models.images.ImagesResponse;

257import java.io.ByteArrayInputStream;

258import java.io.InputStream;

259 

260public final class Main {

261 private Main() {}

262 

263 public static void main(String[] args) {

264 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

265 

266 ImageEditParams params = ImageEditParams.builder()

267 .image(new ByteArrayInputStream("Example data".getBytes()))

268 .prompt("A cute baby sea otter wearing a beret")

269 .build();

270 ImagesResponse imagesResponse = client.images().edit(params);

271 }

272}

273```

274 

275#### Response

276 

277```json

278{

279 "created": 0,

280 "background": "transparent",

281 "data": [

282 {

283 "b64_json": "b64_json",

284 "revised_prompt": "revised_prompt",

285 "url": "https://example.com"

286 }

287 ],

288 "output_format": "png",

289 "quality": "low",

290 "size": "1024x1024",

291 "usage": {

292 "input_tokens": 0,

293 "input_tokens_details": {

294 "image_tokens": 0,

295 "text_tokens": 0

296 },

297 "output_tokens": 0,

298 "total_tokens": 0,

299 "output_tokens_details": {

300 "image_tokens": 0,

301 "text_tokens": 0

302 }

303 }

304}

305```

Details

1## Create image

2 

3`ImagesResponse images().generate(ImageGenerateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/images/generations`

6 

7Creates an image given a prompt. [Learn more](https://platform.openai.com/docs/guides/images).

8 

9### Parameters

10 

11- `ImageGenerateParams params`

12 

13 - `String prompt`

14 

15 A text description of the desired image(s). The maximum length is 32000 characters for the GPT image models, 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`.

16 

17 - `Optional<Background> background`

18 

19 Allows to set transparency for the background of the generated image(s).

20 This parameter is only supported for GPT image models that support

21 transparent backgrounds. Must be one of `transparent`, `opaque`, or

22 `auto` (default value). When `auto` is used, the model will

23 automatically determine the best background for the image.

24 

25 `gpt-image-2` and `gpt-image-2-2026-04-21` do not support

26 transparent backgrounds. Requests with `background` set to

27 `transparent` will return an error for these models; use `opaque` or

28 `auto` instead.

29 

30 If `transparent`, the output format needs to support transparency,

31 so it should be set to either `png` (default value) or `webp`.

32 

33 - `TRANSPARENT("transparent")`

34 

35 - `OPAQUE("opaque")`

36 

37 - `AUTO("auto")`

38 

39 - `Optional<ImageModel> model`

40 

41 The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, or `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific to the GPT image models is used.

42 

43 - `Optional<Moderation> moderation`

44 

45 Control the content-moderation level for images generated by the GPT image models. Must be either `low` for less restrictive filtering or `auto` (default value).

46 

47 - `LOW("low")`

48 

49 - `AUTO("auto")`

50 

51 - `Optional<Long> n`

52 

53 The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported.

54 

55 - `Optional<Long> outputCompression`

56 

57 The compression level (0-100%) for the generated images. This parameter is only supported for the GPT image models with the `webp` or `jpeg` output formats, and defaults to 100.

58 

59 - `Optional<OutputFormat> outputFormat`

60 

61 The format in which the generated images are returned. This parameter is only supported for the GPT image models. Must be one of `png`, `jpeg`, or `webp`.

62 

63 - `PNG("png")`

64 

65 - `JPEG("jpeg")`

66 

67 - `WEBP("webp")`

68 

69 - `Optional<Long> partialImages`

70 

71 The number of partial images to generate. This parameter is used for

72 streaming responses that return partial images. Value must be between 0 and 3.

73 When set to 0, the response will be a single image sent in one streaming event.

74 

75 Note that the final image may be sent before the full number of partial images

76 are generated if the full image is generated more quickly.

77 

78 - `Optional<Quality> quality`

79 

80 The quality of the image that will be generated.

81 

82 - `auto` (default value) will automatically select the best quality for the given model.

83 - `high`, `medium` and `low` are supported for the GPT image models.

84 - `hd` and `standard` are supported for `dall-e-3`.

85 - `standard` is the only option for `dall-e-2`.

86 

87 - `STANDARD("standard")`

88 

89 - `HD("hd")`

90 

91 - `LOW("low")`

92 

93 - `MEDIUM("medium")`

94 

95 - `HIGH("high")`

96 

97 - `AUTO("auto")`

98 

99 - `Optional<ResponseFormat> responseFormat`

100 

101 The format in which generated images with `dall-e-2` and `dall-e-3` are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. This parameter isn't supported for the GPT image models, which always return base64-encoded images.

102 

103 - `URL("url")`

104 

105 - `B64_JSON("b64_json")`

106 

107 - `Optional<Size> size`

108 

109 The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`.

110 

111 - `AUTO("auto")`

112 

113 - `_1024X1024("1024x1024")`

114 

115 - `_1536X1024("1536x1024")`

116 

117 - `_1024X1536("1024x1536")`

118 

119 - `_256X256("256x256")`

120 

121 - `_512X512("512x512")`

122 

123 - `_1792X1024("1792x1024")`

124 

125 - `_1024X1792("1024x1792")`

126 

127 - `Optional<Style> style`

128 

129 The style of the generated images. This parameter is only supported for `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images.

130 

131 - `VIVID("vivid")`

132 

133 - `NATURAL("natural")`

134 

135 - `Optional<String> user`

136 

137 A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

138 

139### Returns

140 

141- `class ImagesResponse:`

142 

143 The response from the image generation endpoint.

144 

145 - `long created`

146 

147 The Unix timestamp (in seconds) of when the image was created.

148 

149 - `Optional<Background> background`

150 

151 The background parameter used for the image generation. Either `transparent` or `opaque`.

152 

153 - `TRANSPARENT("transparent")`

154 

155 - `OPAQUE("opaque")`

156 

157 - `Optional<List<Image>> data`

158 

159 The list of generated images.

160 

161 - `Optional<String> b64Json`

162 

163 The base64-encoded JSON of the generated image. Returned by default for the GPT image models, and only present if `response_format` is set to `b64_json` for `dall-e-2` and `dall-e-3`.

164 

165 - `Optional<String> revisedPrompt`

166 

167 For `dall-e-3` only, the revised prompt that was used to generate the image.

168 

169 - `Optional<String> url`

170 

171 When using `dall-e-2` or `dall-e-3`, the URL of the generated image if `response_format` is set to `url` (default value). Unsupported for the GPT image models.

172 

173 - `Optional<OutputFormat> outputFormat`

174 

175 The output format of the image generation. Either `png`, `webp`, or `jpeg`.

176 

177 - `PNG("png")`

178 

179 - `WEBP("webp")`

180 

181 - `JPEG("jpeg")`

182 

183 - `Optional<Quality> quality`

184 

185 The quality of the image generated. Either `low`, `medium`, or `high`.

186 

187 - `LOW("low")`

188 

189 - `MEDIUM("medium")`

190 

191 - `HIGH("high")`

192 

193 - `Optional<Size> size`

194 

195 The size of the image generated. Either `1024x1024`, `1024x1536`, or `1536x1024`.

196 

197 - `_1024X1024("1024x1024")`

198 

199 - `_1024X1536("1024x1536")`

200 

201 - `_1536X1024("1536x1024")`

202 

203 - `Optional<Usage> usage`

204 

205 For `gpt-image-1` only, the token usage information for the image generation.

206 

207 - `long inputTokens`

208 

209 The number of tokens (images and text) in the input prompt.

210 

211 - `InputTokensDetails inputTokensDetails`

212 

213 The input tokens detailed information for the image generation.

214 

215 - `long imageTokens`

216 

217 The number of image tokens in the input prompt.

218 

219 - `long textTokens`

220 

221 The number of text tokens in the input prompt.

222 

223 - `long outputTokens`

224 

225 The number of output tokens generated by the model.

226 

227 - `long totalTokens`

228 

229 The total number of tokens (images and text) used for the image generation.

230 

231 - `Optional<OutputTokensDetails> outputTokensDetails`

232 

233 The output token details for the image generation.

234 

235 - `long imageTokens`

236 

237 The number of image output tokens generated by the model.

238 

239 - `long textTokens`

240 

241 The number of text output tokens generated by the model.

242 

243### Example

244 

245```java

246package com.openai.example;

247 

248import com.openai.client.OpenAIClient;

249import com.openai.client.okhttp.OpenAIOkHttpClient;

250import com.openai.models.images.ImageGenerateParams;

251import com.openai.models.images.ImagesResponse;

252 

253public final class Main {

254 private Main() {}

255 

256 public static void main(String[] args) {

257 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

258 

259 ImageGenerateParams params = ImageGenerateParams.builder()

260 .prompt("A cute baby sea otter")

261 .build();

262 ImagesResponse imagesResponse = client.images().generate(params);

263 }

264}

265```

266 

267#### Response

268 

269```json

270{

271 "created": 0,

272 "background": "transparent",

273 "data": [

274 {

275 "b64_json": "b64_json",

276 "revised_prompt": "revised_prompt",

277 "url": "https://example.com"

278 }

279 ],

280 "output_format": "png",

281 "quality": "low",

282 "size": "1024x1024",

283 "usage": {

284 "input_tokens": 0,

285 "input_tokens_details": {

286 "image_tokens": 0,

287 "text_tokens": 0

288 },

289 "output_tokens": 0,

290 "total_tokens": 0,

291 "output_tokens_details": {

292 "image_tokens": 0,

293 "text_tokens": 0

294 }

295 }

296}

297```

Details

1## Create moderation

2 

3`ModerationCreateResponse moderations().create(ModerationCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/moderations`

6 

7Classifies if text and/or image inputs are potentially harmful. Learn

8more in the [moderation guide](https://platform.openai.com/docs/guides/moderation).

9 

10### Parameters

11 

12- `ModerationCreateParams params`

13 

14 - `Input input`

15 

16 Input (or inputs) to classify. Can be a single string, an array of strings, or

17 an array of multi-modal input objects similar to other models.

18 

19 - `String`

20 

21 - `List<String>`

22 

23 - `List<ModerationMultiModalInput>`

24 

25 - `class ModerationImageUrlInput:`

26 

27 An object describing an image to classify.

28 

29 - `ImageUrl imageUrl`

30 

31 Contains either an image URL or a data URL for a base64 encoded image.

32 

33 - `String url`

34 

35 Either a URL of the image or the base64 encoded image data.

36 

37 - `JsonValue; type "image_url"constant`

38 

39 Always `image_url`.

40 

41 - `IMAGE_URL("image_url")`

42 

43 - `class ModerationTextInput:`

44 

45 An object describing text to classify.

46 

47 - `String text`

48 

49 A string of text to classify.

50 

51 - `JsonValue; type "text"constant`

52 

53 Always `text`.

54 

55 - `TEXT("text")`

56 

57 - `Optional<ModerationModel> model`

58 

59 The content moderation model you would like to use. Learn more in

60 [the moderation guide](https://platform.openai.com/docs/guides/moderation), and learn about

61 available models [here](https://platform.openai.com/docs/models#moderation).

62 

63### Returns

64 

65- `class ModerationCreateResponse:`

66 

67 Represents if a given text input is potentially harmful.

68 

69 - `String id`

70 

71 The unique identifier for the moderation request.

72 

73 - `String model`

74 

75 The model used to generate the moderation results.

76 

77 - `List<Moderation> results`

78 

79 A list of moderation objects.

80 

81 - `Categories categories`

82 

83 A list of the categories, and whether they are flagged or not.

84 

85 - `boolean harassment`

86 

87 Content that expresses, incites, or promotes harassing language towards any target.

88 

89 - `boolean harassmentThreatening`

90 

91 Harassment content that also includes violence or serious harm towards any target.

92 

93 - `boolean hate`

94 

95 Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment.

96 

97 - `boolean hateThreatening`

98 

99 Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste.

100 

101 - `Optional<Boolean> illicit`

102 

103 Content that includes instructions or advice that facilitate the planning or execution of wrongdoing, or that gives advice or instruction on how to commit illicit acts. For example, "how to shoplift" would fit this category.

104 

105 - `Optional<Boolean> illicitViolent`

106 

107 Content that includes instructions or advice that facilitate the planning or execution of wrongdoing that also includes violence, or that gives advice or instruction on the procurement of any weapon.

108 

109 - `boolean selfHarm`

110 

111 Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.

112 

113 - `boolean selfHarmInstructions`

114 

115 Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts.

116 

117 - `boolean selfHarmIntent`

118 

119 Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders.

120 

121 - `boolean sexual`

122 

123 Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).

124 

125 - `boolean sexualMinors`

126 

127 Sexual content that includes an individual who is under 18 years old.

128 

129 - `boolean violence`

130 

131 Content that depicts death, violence, or physical injury.

132 

133 - `boolean violenceGraphic`

134 

135 Content that depicts death, violence, or physical injury in graphic detail.

136 

137 - `CategoryAppliedInputTypes categoryAppliedInputTypes`

138 

139 A list of the categories along with the input type(s) that the score applies to.

140 

141 - `List<Harassment> harassment`

142 

143 The applied input type(s) for the category 'harassment'.

144 

145 - `TEXT("text")`

146 

147 - `List<HarassmentThreatening> harassmentThreatening`

148 

149 The applied input type(s) for the category 'harassment/threatening'.

150 

151 - `TEXT("text")`

152 

153 - `List<Hate> hate`

154 

155 The applied input type(s) for the category 'hate'.

156 

157 - `TEXT("text")`

158 

159 - `List<HateThreatening> hateThreatening`

160 

161 The applied input type(s) for the category 'hate/threatening'.

162 

163 - `TEXT("text")`

164 

165 - `List<Illicit> illicit`

166 

167 The applied input type(s) for the category 'illicit'.

168 

169 - `TEXT("text")`

170 

171 - `List<IllicitViolent> illicitViolent`

172 

173 The applied input type(s) for the category 'illicit/violent'.

174 

175 - `TEXT("text")`

176 

177 - `List<SelfHarm> selfHarm`

178 

179 The applied input type(s) for the category 'self-harm'.

180 

181 - `TEXT("text")`

182 

183 - `IMAGE("image")`

184 

185 - `List<SelfHarmInstruction> selfHarmInstructions`

186 

187 The applied input type(s) for the category 'self-harm/instructions'.

188 

189 - `TEXT("text")`

190 

191 - `IMAGE("image")`

192 

193 - `List<SelfHarmIntent> selfHarmIntent`

194 

195 The applied input type(s) for the category 'self-harm/intent'.

196 

197 - `TEXT("text")`

198 

199 - `IMAGE("image")`

200 

201 - `List<Sexual> sexual`

202 

203 The applied input type(s) for the category 'sexual'.

204 

205 - `TEXT("text")`

206 

207 - `IMAGE("image")`

208 

209 - `List<SexualMinor> sexualMinors`

210 

211 The applied input type(s) for the category 'sexual/minors'.

212 

213 - `TEXT("text")`

214 

215 - `List<Violence> violence`

216 

217 The applied input type(s) for the category 'violence'.

218 

219 - `TEXT("text")`

220 

221 - `IMAGE("image")`

222 

223 - `List<ViolenceGraphic> violenceGraphic`

224 

225 The applied input type(s) for the category 'violence/graphic'.

226 

227 - `TEXT("text")`

228 

229 - `IMAGE("image")`

230 

231 - `CategoryScores categoryScores`

232 

233 A list of the categories along with their scores as predicted by model.

234 

235 - `double harassment`

236 

237 The score for the category 'harassment'.

238 

239 - `double harassmentThreatening`

240 

241 The score for the category 'harassment/threatening'.

242 

243 - `double hate`

244 

245 The score for the category 'hate'.

246 

247 - `double hateThreatening`

248 

249 The score for the category 'hate/threatening'.

250 

251 - `double illicit`

252 

253 The score for the category 'illicit'.

254 

255 - `double illicitViolent`

256 

257 The score for the category 'illicit/violent'.

258 

259 - `double selfHarm`

260 

261 The score for the category 'self-harm'.

262 

263 - `double selfHarmInstructions`

264 

265 The score for the category 'self-harm/instructions'.

266 

267 - `double selfHarmIntent`

268 

269 The score for the category 'self-harm/intent'.

270 

271 - `double sexual`

272 

273 The score for the category 'sexual'.

274 

275 - `double sexualMinors`

276 

277 The score for the category 'sexual/minors'.

278 

279 - `double violence`

280 

281 The score for the category 'violence'.

282 

283 - `double violenceGraphic`

284 

285 The score for the category 'violence/graphic'.

286 

287 - `boolean flagged`

288 

289 Whether any of the below categories are flagged.

290 

291### Example

292 

293```java

294package com.openai.example;

295 

296import com.openai.client.OpenAIClient;

297import com.openai.client.okhttp.OpenAIOkHttpClient;

298import com.openai.models.moderations.ModerationCreateParams;

299import com.openai.models.moderations.ModerationCreateResponse;

300 

301public final class Main {

302 private Main() {}

303 

304 public static void main(String[] args) {

305 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

306 

307 ModerationCreateParams params = ModerationCreateParams.builder()

308 .input("I want to kill them.")

309 .build();

310 ModerationCreateResponse moderation = client.moderations().create(params);

311 }

312}

313```

314 

315#### Response

316 

317```json

318{

319 "id": "id",

320 "model": "model",

321 "results": [

322 {

323 "categories": {

324 "harassment": true,

325 "harassment/threatening": true,

326 "hate": true,

327 "hate/threatening": true,

328 "illicit": true,

329 "illicit/violent": true,

330 "self-harm": true,

331 "self-harm/instructions": true,

332 "self-harm/intent": true,

333 "sexual": true,

334 "sexual/minors": true,

335 "violence": true,

336 "violence/graphic": true

337 },

338 "category_applied_input_types": {

339 "harassment": [

340 "text"

341 ],

342 "harassment/threatening": [

343 "text"

344 ],

345 "hate": [

346 "text"

347 ],

348 "hate/threatening": [

349 "text"

350 ],

351 "illicit": [

352 "text"

353 ],

354 "illicit/violent": [

355 "text"

356 ],

357 "self-harm": [

358 "text"

359 ],

360 "self-harm/instructions": [

361 "text"

362 ],

363 "self-harm/intent": [

364 "text"

365 ],

366 "sexual": [

367 "text"

368 ],

369 "sexual/minors": [

370 "text"

371 ],

372 "violence": [

373 "text"

374 ],

375 "violence/graphic": [

376 "text"

377 ]

378 },

379 "category_scores": {

380 "harassment": 0,

381 "harassment/threatening": 0,

382 "hate": 0,

383 "hate/threatening": 0,

384 "illicit": 0,

385 "illicit/violent": 0,

386 "self-harm": 0,

387 "self-harm/instructions": 0,

388 "self-harm/intent": 0,

389 "sexual": 0,

390 "sexual/minors": 0,

391 "violence": 0,

392 "violence/graphic": 0

393 },

394 "flagged": true

395 }

396 ]

397}

398```

Details

1## Create client secret

2 

3`ClientSecretCreateResponse realtime().clientSecrets().create(ClientSecretCreateParamsparams = ClientSecretCreateParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/realtime/client_secrets`

6 

7Create a Realtime client secret with an associated session configuration.

8 

9Client secrets are short-lived tokens that can be passed to a client app,

10such as a web frontend or mobile client, which grants access to the Realtime API without

11leaking your main API key. You can configure a custom TTL for each client secret.

12 

13You can also attach session configuration options to the client secret, which will be

14applied to any sessions created using that client secret, but these can also be overridden

15by the client connection.

16 

17[Learn more about authentication with client secrets over WebRTC](https://platform.openai.com/docs/guides/realtime-webrtc).

18 

19Returns the created client secret and the effective session object. The client secret is a string that looks like `ek_1234`.

20 

21### Parameters

22 

23- `ClientSecretCreateParams params`

24 

25 - `Optional<ExpiresAfter> expiresAfter`

26 

27 Configuration for the client secret expiration. Expiration refers to the time after which

28 a client secret will no longer be valid for creating sessions. The session itself may

29 continue after that time once started. A secret can be used to create multiple sessions

30 until it expires.

31 

32 - `Optional<Anchor> anchor`

33 

34 The anchor point for the client secret expiration, meaning that `seconds` will be added to the `created_at` time of the client secret to produce an expiration timestamp. Only `created_at` is currently supported.

35 

36 - `CREATED_AT("created_at")`

37 

38 - `Optional<Long> seconds`

39 

40 The number of seconds from the anchor point to the expiration. Select a value between `10` and `7200` (2 hours). This default to 600 seconds (10 minutes) if not specified.

41 

42 - `Optional<Session> session`

43 

44 Session configuration to use for the client secret. Choose either a realtime

45 session or a transcription session.

46 

47 - `class RealtimeSessionCreateRequest:`

48 

49 Realtime session object configuration.

50 

51 - `JsonValue; type "realtime"constant`

52 

53 The type of session to create. Always `realtime` for the Realtime API.

54 

55 - `REALTIME("realtime")`

56 

57 - `Optional<RealtimeAudioConfig> audio`

58 

59 Configuration for input and output audio.

60 

61 - `Optional<RealtimeAudioConfigInput> input`

62 

63 - `Optional<RealtimeAudioFormats> format`

64 

65 The format of the input audio.

66 

67 - `AudioPcm`

68 

69 - `Optional<Rate> rate`

70 

71 The sample rate of the audio. Always `24000`.

72 

73 - `_24000(24000)`

74 

75 - `Optional<Type> type`

76 

77 The audio format. Always `audio/pcm`.

78 

79 - `AUDIO_PCM("audio/pcm")`

80 

81 - `AudioPcmu`

82 

83 - `Optional<Type> type`

84 

85 The audio format. Always `audio/pcmu`.

86 

87 - `AUDIO_PCMU("audio/pcmu")`

88 

89 - `AudioPcma`

90 

91 - `Optional<Type> type`

92 

93 The audio format. Always `audio/pcma`.

94 

95 - `AUDIO_PCMA("audio/pcma")`

96 

97 - `Optional<NoiseReduction> noiseReduction`

98 

99 Configuration for input audio noise reduction. This can be set to `null` to turn off.

100 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

101 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

102 

103 - `Optional<NoiseReductionType> type`

104 

105 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

106 

107 - `NEAR_FIELD("near_field")`

108 

109 - `FAR_FIELD("far_field")`

110 

111 - `Optional<AudioTranscription> transcription`

112 

113 Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.

114 

115 - `Optional<Delay> delay`

116 

117 Controls how long the model waits before emitting transcription text.

118 Higher values can improve transcription accuracy at the cost of latency.

119 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

120 

121 - `MINIMAL("minimal")`

122 

123 - `LOW("low")`

124 

125 - `MEDIUM("medium")`

126 

127 - `HIGH("high")`

128 

129 - `XHIGH("xhigh")`

130 

131 - `Optional<String> language`

132 

133 The language of the input audio. Supplying the input language in

134 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

135 will improve accuracy and latency.

136 

137 - `Optional<Model> model`

138 

139 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

140 

141 - `WHISPER_1("whisper-1")`

142 

143 - `GPT_4O_MINI_TRANSCRIBE("gpt-4o-mini-transcribe")`

144 

145 - `GPT_4O_MINI_TRANSCRIBE_2025_12_15("gpt-4o-mini-transcribe-2025-12-15")`

146 

147 - `GPT_4O_TRANSCRIBE("gpt-4o-transcribe")`

148 

149 - `GPT_4O_TRANSCRIBE_DIARIZE("gpt-4o-transcribe-diarize")`

150 

151 - `GPT_REALTIME_WHISPER("gpt-realtime-whisper")`

152 

153 - `Optional<String> prompt`

154 

155 An optional text to guide the model's style or continue a previous audio

156 segment.

157 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).

158 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

159 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

160 

161 - `Optional<RealtimeAudioInputTurnDetection> turnDetection`

162 

163 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

164 

165 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

166 

167 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

168 

169 For `gpt-realtime-whisper` transcription sessions, turn detection must be

170 set to `null`; VAD is not supported.

171 

172 - `ServerVad`

173 

174 - `JsonValue; type "server_vad"constant`

175 

176 Type of turn detection, `server_vad` to turn on simple Server VAD.

177 

178 - `SERVER_VAD("server_vad")`

179 

180 - `Optional<Boolean> createResponse`

181 

182 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

183 

184 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

185 

186 - `Optional<Long> idleTimeoutMs`

187 

188 Optional timeout after which a model response will be triggered automatically. This is

189 useful for situations in which a long pause from the user is unexpected, such as a phone

190 call. The model will effectively prompt the user to continue the conversation based

191 on the current context.

192 

193 The timeout value will be applied after the last model response's audio has finished playing,

194 i.e. it's set to the `response.done` time plus audio playback duration.

195 

196 An `input_audio_buffer.timeout_triggered` event (plus events

197 associated with the Response) will be emitted when the timeout is reached.

198 Idle timeout is currently only supported for `server_vad` mode.

199 

200 - `Optional<Boolean> interruptResponse`

201 

202 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

203 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

204 

205 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

206 

207 - `Optional<Long> prefixPaddingMs`

208 

209 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

210 milliseconds). Defaults to 300ms.

211 

212 - `Optional<Long> silenceDurationMs`

213 

214 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

215 to 500ms. With shorter values the model will respond more quickly,

216 but may jump in on short pauses from the user.

217 

218 - `Optional<Double> threshold`

219 

220 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

221 higher threshold will require louder audio to activate the model, and

222 thus might perform better in noisy environments.

223 

224 - `SemanticVad`

225 

226 - `JsonValue; type "semantic_vad"constant`

227 

228 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

229 

230 - `SEMANTIC_VAD("semantic_vad")`

231 

232 - `Optional<Boolean> createResponse`

233 

234 Whether or not to automatically generate a response when a VAD stop event occurs.

235 

236 - `Optional<Eagerness> eagerness`

237 

238 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

239 

240 - `LOW("low")`

241 

242 - `MEDIUM("medium")`

243 

244 - `HIGH("high")`

245 

246 - `AUTO("auto")`

247 

248 - `Optional<Boolean> interruptResponse`

249 

250 Whether or not to automatically interrupt any ongoing response with output to the default

251 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

252 

253 - `Optional<RealtimeAudioConfigOutput> output`

254 

255 - `Optional<RealtimeAudioFormats> format`

256 

257 The format of the output audio.

258 

259 - `Optional<Double> speed`

260 

261 The speed of the model's spoken response as a multiple of the original speed.

262 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.

263 

264 This parameter is a post-processing adjustment to the audio after it is generated, it's

265 also possible to prompt the model to speak faster or slower.

266 

267 - `Optional<Voice> voice`

268 

269 The voice the model uses to respond. Supported built-in voices are

270 `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,

271 `marin`, and `cedar`. You may also provide a custom voice object with

272 an `id`, for example `{ "id": "voice_1234" }`. Voice cannot be changed

273 during the session once the model has responded with audio at least once.

274 We recommend `marin` and `cedar` for best quality.

275 

276 - `String`

277 

278 - `enum UnionMember1:`

279 

280 - `ALLOY("alloy")`

281 

282 - `ASH("ash")`

283 

284 - `BALLAD("ballad")`

285 

286 - `CORAL("coral")`

287 

288 - `ECHO("echo")`

289 

290 - `SAGE("sage")`

291 

292 - `SHIMMER("shimmer")`

293 

294 - `VERSE("verse")`

295 

296 - `MARIN("marin")`

297 

298 - `CEDAR("cedar")`

299 

300 - `class Id:`

301 

302 Custom voice reference.

303 

304 - `String id`

305 

306 The custom voice ID, e.g. `voice_1234`.

307 

308 - `Optional<List<Include>> include`

309 

310 Additional fields to include in server outputs.

311 

312 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

313 

314 - `ITEM_INPUT_AUDIO_TRANSCRIPTION_LOGPROBS("item.input_audio_transcription.logprobs")`

315 

316 - `Optional<String> instructions`

317 

318 The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.

319 

320 Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.

321 

322 - `Optional<MaxOutputTokens> maxOutputTokens`

323 

324 Maximum number of output tokens for a single assistant response,

325 inclusive of tool calls. Provide an integer between 1 and 4096 to

326 limit output tokens, or `inf` for the maximum available tokens for a

327 given model. Defaults to `inf`.

328 

329 - `long`

330 

331 - `JsonValue;`

332 

333 - `INF("inf")`

334 

335 - `Optional<Model> model`

336 

337 The Realtime model used for this session.

338 

339 - `GPT_REALTIME("gpt-realtime")`

340 

341 - `GPT_REALTIME_1_5("gpt-realtime-1.5")`

342 

343 - `GPT_REALTIME_2("gpt-realtime-2")`

344 

345 - `GPT_REALTIME_2025_08_28("gpt-realtime-2025-08-28")`

346 

347 - `GPT_4O_REALTIME_PREVIEW("gpt-4o-realtime-preview")`

348 

349 - `GPT_4O_REALTIME_PREVIEW_2024_10_01("gpt-4o-realtime-preview-2024-10-01")`

350 

351 - `GPT_4O_REALTIME_PREVIEW_2024_12_17("gpt-4o-realtime-preview-2024-12-17")`

352 

353 - `GPT_4O_REALTIME_PREVIEW_2025_06_03("gpt-4o-realtime-preview-2025-06-03")`

354 

355 - `GPT_4O_MINI_REALTIME_PREVIEW("gpt-4o-mini-realtime-preview")`

356 

357 - `GPT_4O_MINI_REALTIME_PREVIEW_2024_12_17("gpt-4o-mini-realtime-preview-2024-12-17")`

358 

359 - `GPT_REALTIME_MINI("gpt-realtime-mini")`

360 

361 - `GPT_REALTIME_MINI_2025_10_06("gpt-realtime-mini-2025-10-06")`

362 

363 - `GPT_REALTIME_MINI_2025_12_15("gpt-realtime-mini-2025-12-15")`

364 

365 - `GPT_AUDIO_1_5("gpt-audio-1.5")`

366 

367 - `GPT_AUDIO_MINI("gpt-audio-mini")`

368 

369 - `GPT_AUDIO_MINI_2025_10_06("gpt-audio-mini-2025-10-06")`

370 

371 - `GPT_AUDIO_MINI_2025_12_15("gpt-audio-mini-2025-12-15")`

372 

373 - `Optional<List<OutputModality>> outputModalities`

374 

375 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating

376 that the model will respond with audio plus a transcript. `["text"]` can be used to make

377 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.

378 

379 - `TEXT("text")`

380 

381 - `AUDIO("audio")`

382 

383 - `Optional<Boolean> parallelToolCalls`

384 

385 Whether the model may call multiple tools in parallel. Only supported by

386 reasoning Realtime models such as `gpt-realtime-2`.

387 

388 - `Optional<ResponsePrompt> prompt`

389 

390 Reference to a prompt template and its variables.

391 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).

392 

393 - `String id`

394 

395 The unique identifier of the prompt template to use.

396 

397 - `Optional<Variables> variables`

398 

399 Optional map of values to substitute in for variables in your

400 prompt. The substitution values can either be strings, or other

401 Response input types like images or files.

402 

403 - `String`

404 

405 - `class ResponseInputText:`

406 

407 A text input to the model.

408 

409 - `String text`

410 

411 The text input to the model.

412 

413 - `JsonValue; type "input_text"constant`

414 

415 The type of the input item. Always `input_text`.

416 

417 - `INPUT_TEXT("input_text")`

418 

419 - `class ResponseInputImage:`

420 

421 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).

422 

423 - `Detail detail`

424 

425 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.

426 

427 - `LOW("low")`

428 

429 - `HIGH("high")`

430 

431 - `AUTO("auto")`

432 

433 - `ORIGINAL("original")`

434 

435 - `JsonValue; type "input_image"constant`

436 

437 The type of the input item. Always `input_image`.

438 

439 - `INPUT_IMAGE("input_image")`

440 

441 - `Optional<String> fileId`

442 

443 The ID of the file to be sent to the model.

444 

445 - `Optional<String> imageUrl`

446 

447 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.

448 

449 - `class ResponseInputFile:`

450 

451 A file input to the model.

452 

453 - `JsonValue; type "input_file"constant`

454 

455 The type of the input item. Always `input_file`.

456 

457 - `INPUT_FILE("input_file")`

458 

459 - `Optional<Detail> detail`

460 

461 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.

462 

463 - `LOW("low")`

464 

465 - `HIGH("high")`

466 

467 - `Optional<String> fileData`

468 

469 The content of the file to be sent to the model.

470 

471 - `Optional<String> fileId`

472 

473 The ID of the file to be sent to the model.

474 

475 - `Optional<String> fileUrl`

476 

477 The URL of the file to be sent to the model.

478 

479 - `Optional<String> filename`

480 

481 The name of the file to be sent to the model.

482 

483 - `Optional<String> version`

484 

485 Optional version of the prompt template.

486 

487 - `Optional<RealtimeReasoning> reasoning`

488 

489 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.

490 

491 - `Optional<RealtimeReasoningEffort> effort`

492 

493 Constrains effort on reasoning for reasoning-capable Realtime models such as

494 `gpt-realtime-2`.

495 

496 - `MINIMAL("minimal")`

497 

498 - `LOW("low")`

499 

500 - `MEDIUM("medium")`

501 

502 - `HIGH("high")`

503 

504 - `XHIGH("xhigh")`

505 

506 - `Optional<RealtimeToolChoiceConfig> toolChoice`

507 

508 How the model chooses tools. Provide one of the string modes or force a specific

509 function/MCP tool.

510 

511 - `enum ToolChoiceOptions:`

512 

513 Controls which (if any) tool is called by the model.

514 

515 `none` means the model will not call any tool and instead generates a message.

516 

517 `auto` means the model can pick between generating a message or calling one or

518 more tools.

519 

520 `required` means the model must call one or more tools.

521 

522 - `NONE("none")`

523 

524 - `AUTO("auto")`

525 

526 - `REQUIRED("required")`

527 

528 - `class ToolChoiceFunction:`

529 

530 Use this option to force the model to call a specific function.

531 

532 - `String name`

533 

534 The name of the function to call.

535 

536 - `JsonValue; type "function"constant`

537 

538 For function calling, the type is always `function`.

539 

540 - `FUNCTION("function")`

541 

542 - `class ToolChoiceMcp:`

543 

544 Use this option to force the model to call a specific tool on a remote MCP server.

545 

546 - `String serverLabel`

547 

548 The label of the MCP server to use.

549 

550 - `JsonValue; type "mcp"constant`

551 

552 For MCP tools, the type is always `mcp`.

553 

554 - `MCP("mcp")`

555 

556 - `Optional<String> name`

557 

558 The name of the tool to call on the server.

559 

560 - `Optional<List<RealtimeToolsConfigUnion>> tools`

561 

562 Tools available to the model.

563 

564 - `class RealtimeFunctionTool:`

565 

566 - `Optional<String> description`

567 

568 The description of the function, including guidance on when and how

569 to call it, and guidance about what to tell the user when calling

570 (if anything).

571 

572 - `Optional<String> name`

573 

574 The name of the function.

575 

576 - `Optional<JsonValue> parameters`

577 

578 Parameters of the function in JSON Schema.

579 

580 - `Optional<Type> type`

581 

582 The type of the tool, i.e. `function`.

583 

584 - `FUNCTION("function")`

585 

586 - `Mcp`

587 

588 - `String serverLabel`

589 

590 A label for this MCP server, used to identify it in tool calls.

591 

592 - `JsonValue; type "mcp"constant`

593 

594 The type of the MCP tool. Always `mcp`.

595 

596 - `MCP("mcp")`

597 

598 - `Optional<AllowedTools> allowedTools`

599 

600 List of allowed tool names or a filter object.

601 

602 - `List<String>`

603 

604 - `class McpToolFilter:`

605 

606 A filter object to specify which tools are allowed.

607 

608 - `Optional<Boolean> readOnly`

609 

610 Indicates whether or not a tool modifies data or is read-only. If an

611 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

612 it will match this filter.

613 

614 - `Optional<List<String>> toolNames`

615 

616 List of allowed tool names.

617 

618 - `Optional<String> authorization`

619 

620 An OAuth access token that can be used with a remote MCP server, either

621 with a custom MCP server URL or a service connector. Your application

622 must handle the OAuth authorization flow and provide the token here.

623 

624 - `Optional<ConnectorId> connectorId`

625 

626 Identifier for service connectors, like those available in ChatGPT. One of

627 `server_url` or `connector_id` must be provided. Learn more about service

628 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).

629 

630 Currently supported `connector_id` values are:

631 

632 - Dropbox: `connector_dropbox`

633 - Gmail: `connector_gmail`

634 - Google Calendar: `connector_googlecalendar`

635 - Google Drive: `connector_googledrive`

636 - Microsoft Teams: `connector_microsoftteams`

637 - Outlook Calendar: `connector_outlookcalendar`

638 - Outlook Email: `connector_outlookemail`

639 - SharePoint: `connector_sharepoint`

640 

641 - `CONNECTOR_DROPBOX("connector_dropbox")`

642 

643 - `CONNECTOR_GMAIL("connector_gmail")`

644 

645 - `CONNECTOR_GOOGLECALENDAR("connector_googlecalendar")`

646 

647 - `CONNECTOR_GOOGLEDRIVE("connector_googledrive")`

648 

649 - `CONNECTOR_MICROSOFTTEAMS("connector_microsoftteams")`

650 

651 - `CONNECTOR_OUTLOOKCALENDAR("connector_outlookcalendar")`

652 

653 - `CONNECTOR_OUTLOOKEMAIL("connector_outlookemail")`

654 

655 - `CONNECTOR_SHAREPOINT("connector_sharepoint")`

656 

657 - `Optional<Boolean> deferLoading`

658 

659 Whether this MCP tool is deferred and discovered via tool search.

660 

661 - `Optional<Headers> headers`

662 

663 Optional HTTP headers to send to the MCP server. Use for authentication

664 or other purposes.

665 

666 - `Optional<RequireApproval> requireApproval`

667 

668 Specify which of the MCP server's tools require approval.

669 

670 - `class McpToolApprovalFilter:`

671 

672 Specify which of the MCP server's tools require approval. Can be

673 `always`, `never`, or a filter object associated with tools

674 that require approval.

675 

676 - `Optional<Always> always`

677 

678 A filter object to specify which tools are allowed.

679 

680 - `Optional<Boolean> readOnly`

681 

682 Indicates whether or not a tool modifies data or is read-only. If an

683 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

684 it will match this filter.

685 

686 - `Optional<List<String>> toolNames`

687 

688 List of allowed tool names.

689 

690 - `Optional<Never> never`

691 

692 A filter object to specify which tools are allowed.

693 

694 - `Optional<Boolean> readOnly`

695 

696 Indicates whether or not a tool modifies data or is read-only. If an

697 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

698 it will match this filter.

699 

700 - `Optional<List<String>> toolNames`

701 

702 List of allowed tool names.

703 

704 - `enum McpToolApprovalSetting:`

705 

706 Specify a single approval policy for all tools. One of `always` or

707 `never`. When set to `always`, all tools will require approval. When

708 set to `never`, all tools will not require approval.

709 

710 - `ALWAYS("always")`

711 

712 - `NEVER("never")`

713 

714 - `Optional<String> serverDescription`

715 

716 Optional description of the MCP server, used to provide more context.

717 

718 - `Optional<String> serverUrl`

719 

720 The URL for the MCP server. One of `server_url` or `connector_id` must be

721 provided.

722 

723 - `Optional<RealtimeTracingConfig> tracing`

724 

725 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once

726 tracing is enabled for a session, the configuration cannot be modified.

727 

728 `auto` will create a trace for the session with default values for the

729 workflow name, group id, and metadata.

730 

731 - `JsonValue;`

732 

733 - `AUTO("auto")`

734 

735 - `TracingConfiguration`

736 

737 - `Optional<String> groupId`

738 

739 The group id to attach to this trace to enable filtering and

740 grouping in the Traces Dashboard.

741 

742 - `Optional<JsonValue> metadata`

743 

744 The arbitrary metadata to attach to this trace to enable

745 filtering in the Traces Dashboard.

746 

747 - `Optional<String> workflowName`

748 

749 The name of the workflow to attach to this trace. This is used to

750 name the trace in the Traces Dashboard.

751 

752 - `Optional<RealtimeTruncation> truncation`

753 

754 When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

755 

756 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

757 

758 Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

759 

760 Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.

761 

762 - `RealtimeTruncationStrategy`

763 

764 - `AUTO("auto")`

765 

766 - `DISABLED("disabled")`

767 

768 - `class RealtimeTruncationRetentionRatio:`

769 

770 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

771 

772 - `double retentionRatio`

773 

774 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.

775 

776 - `JsonValue; type "retention_ratio"constant`

777 

778 Use retention ratio truncation.

779 

780 - `RETENTION_RATIO("retention_ratio")`

781 

782 - `Optional<TokenLimits> tokenLimits`

783 

784 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.

785 

786 - `Optional<Long> postInstructions`

787 

788 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.

789 

790 - `class RealtimeTranscriptionSessionCreateRequest:`

791 

792 Realtime transcription session object configuration.

793 

794 - `JsonValue; type "transcription"constant`

795 

796 The type of session to create. Always `transcription` for transcription sessions.

797 

798 - `TRANSCRIPTION("transcription")`

799 

800 - `Optional<RealtimeTranscriptionSessionAudio> audio`

801 

802 Configuration for input and output audio.

803 

804 - `Optional<RealtimeTranscriptionSessionAudioInput> input`

805 

806 - `Optional<RealtimeAudioFormats> format`

807 

808 The PCM audio format. Only a 24kHz sample rate is supported.

809 

810 - `Optional<NoiseReduction> noiseReduction`

811 

812 Configuration for input audio noise reduction. This can be set to `null` to turn off.

813 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

814 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

815 

816 - `Optional<NoiseReductionType> type`

817 

818 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

819 

820 - `Optional<AudioTranscription> transcription`

821 

822 Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.

823 

824 - `Optional<RealtimeTranscriptionSessionAudioInputTurnDetection> turnDetection`

825 

826 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

827 

828 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

829 

830 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

831 

832 For `gpt-realtime-whisper` transcription sessions, turn detection must be

833 set to `null`; VAD is not supported.

834 

835 - `ServerVad`

836 

837 - `JsonValue; type "server_vad"constant`

838 

839 Type of turn detection, `server_vad` to turn on simple Server VAD.

840 

841 - `SERVER_VAD("server_vad")`

842 

843 - `Optional<Boolean> createResponse`

844 

845 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

846 

847 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

848 

849 - `Optional<Long> idleTimeoutMs`

850 

851 Optional timeout after which a model response will be triggered automatically. This is

852 useful for situations in which a long pause from the user is unexpected, such as a phone

853 call. The model will effectively prompt the user to continue the conversation based

854 on the current context.

855 

856 The timeout value will be applied after the last model response's audio has finished playing,

857 i.e. it's set to the `response.done` time plus audio playback duration.

858 

859 An `input_audio_buffer.timeout_triggered` event (plus events

860 associated with the Response) will be emitted when the timeout is reached.

861 Idle timeout is currently only supported for `server_vad` mode.

862 

863 - `Optional<Boolean> interruptResponse`

864 

865 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

866 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

867 

868 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

869 

870 - `Optional<Long> prefixPaddingMs`

871 

872 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

873 milliseconds). Defaults to 300ms.

874 

875 - `Optional<Long> silenceDurationMs`

876 

877 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

878 to 500ms. With shorter values the model will respond more quickly,

879 but may jump in on short pauses from the user.

880 

881 - `Optional<Double> threshold`

882 

883 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

884 higher threshold will require louder audio to activate the model, and

885 thus might perform better in noisy environments.

886 

887 - `SemanticVad`

888 

889 - `JsonValue; type "semantic_vad"constant`

890 

891 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

892 

893 - `SEMANTIC_VAD("semantic_vad")`

894 

895 - `Optional<Boolean> createResponse`

896 

897 Whether or not to automatically generate a response when a VAD stop event occurs.

898 

899 - `Optional<Eagerness> eagerness`

900 

901 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

902 

903 - `LOW("low")`

904 

905 - `MEDIUM("medium")`

906 

907 - `HIGH("high")`

908 

909 - `AUTO("auto")`

910 

911 - `Optional<Boolean> interruptResponse`

912 

913 Whether or not to automatically interrupt any ongoing response with output to the default

914 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

915 

916 - `Optional<List<Include>> include`

917 

918 Additional fields to include in server outputs.

919 

920 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

921 

922 - `ITEM_INPUT_AUDIO_TRANSCRIPTION_LOGPROBS("item.input_audio_transcription.logprobs")`

923 

924### Returns

925 

926- `class ClientSecretCreateResponse:`

927 

928 Response from creating a session and client secret for the Realtime API.

929 

930 - `long expiresAt`

931 

932 Expiration timestamp for the client secret, in seconds since epoch.

933 

934 - `Session session`

935 

936 The session configuration for either a realtime or transcription session.

937 

938 - `class RealtimeSessionCreateResponse:`

939 

940 A Realtime session configuration object.

941 

942 - `String id`

943 

944 Unique identifier for the session that looks like `sess_1234567890abcdef`.

945 

946 - `JsonValue; object_ "realtime.session"constant`

947 

948 The object type. Always `realtime.session`.

949 

950 - `REALTIME_SESSION("realtime.session")`

951 

952 - `JsonValue; type "realtime"constant`

953 

954 The type of session to create. Always `realtime` for the Realtime API.

955 

956 - `REALTIME("realtime")`

957 

958 - `Optional<Audio> audio`

959 

960 Configuration for input and output audio.

961 

962 - `Optional<Input> input`

963 

964 - `Optional<RealtimeAudioFormats> format`

965 

966 The format of the input audio.

967 

968 - `AudioPcm`

969 

970 - `Optional<Rate> rate`

971 

972 The sample rate of the audio. Always `24000`.

973 

974 - `_24000(24000)`

975 

976 - `Optional<Type> type`

977 

978 The audio format. Always `audio/pcm`.

979 

980 - `AUDIO_PCM("audio/pcm")`

981 

982 - `AudioPcmu`

983 

984 - `Optional<Type> type`

985 

986 The audio format. Always `audio/pcmu`.

987 

988 - `AUDIO_PCMU("audio/pcmu")`

989 

990 - `AudioPcma`

991 

992 - `Optional<Type> type`

993 

994 The audio format. Always `audio/pcma`.

995 

996 - `AUDIO_PCMA("audio/pcma")`

997 

998 - `Optional<NoiseReduction> noiseReduction`

999 

1000 Configuration for input audio noise reduction. This can be set to `null` to turn off.

1001 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

1002 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

1003 

1004 - `Optional<NoiseReductionType> type`

1005 

1006 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

1007 

1008 - `NEAR_FIELD("near_field")`

1009 

1010 - `FAR_FIELD("far_field")`

1011 

1012 - `Optional<AudioTranscription> transcription`

1013 

1014 - `Optional<Delay> delay`

1015 

1016 Controls how long the model waits before emitting transcription text.

1017 Higher values can improve transcription accuracy at the cost of latency.

1018 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

1019 

1020 - `MINIMAL("minimal")`

1021 

1022 - `LOW("low")`

1023 

1024 - `MEDIUM("medium")`

1025 

1026 - `HIGH("high")`

1027 

1028 - `XHIGH("xhigh")`

1029 

1030 - `Optional<String> language`

1031 

1032 The language of the input audio. Supplying the input language in

1033 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

1034 will improve accuracy and latency.

1035 

1036 - `Optional<Model> model`

1037 

1038 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

1039 

1040 - `WHISPER_1("whisper-1")`

1041 

1042 - `GPT_4O_MINI_TRANSCRIBE("gpt-4o-mini-transcribe")`

1043 

1044 - `GPT_4O_MINI_TRANSCRIBE_2025_12_15("gpt-4o-mini-transcribe-2025-12-15")`

1045 

1046 - `GPT_4O_TRANSCRIBE("gpt-4o-transcribe")`

1047 

1048 - `GPT_4O_TRANSCRIBE_DIARIZE("gpt-4o-transcribe-diarize")`

1049 

1050 - `GPT_REALTIME_WHISPER("gpt-realtime-whisper")`

1051 

1052 - `Optional<String> prompt`

1053 

1054 An optional text to guide the model's style or continue a previous audio

1055 segment.

1056 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).

1057 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

1058 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

1059 

1060 - `Optional<TurnDetection> turnDetection`

1061 

1062 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

1063 

1064 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

1065 

1066 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

1067 

1068 For `gpt-realtime-whisper` transcription sessions, turn detection must be

1069 set to `null`; VAD is not supported.

1070 

1071 - `class ServerVad:`

1072 

1073 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.

1074 

1075 - `JsonValue; type "server_vad"constant`

1076 

1077 Type of turn detection, `server_vad` to turn on simple Server VAD.

1078 

1079 - `SERVER_VAD("server_vad")`

1080 

1081 - `Optional<Boolean> createResponse`

1082 

1083 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

1084 

1085 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

1086 

1087 - `Optional<Long> idleTimeoutMs`

1088 

1089 Optional timeout after which a model response will be triggered automatically. This is

1090 useful for situations in which a long pause from the user is unexpected, such as a phone

1091 call. The model will effectively prompt the user to continue the conversation based

1092 on the current context.

1093 

1094 The timeout value will be applied after the last model response's audio has finished playing,

1095 i.e. it's set to the `response.done` time plus audio playback duration.

1096 

1097 An `input_audio_buffer.timeout_triggered` event (plus events

1098 associated with the Response) will be emitted when the timeout is reached.

1099 Idle timeout is currently only supported for `server_vad` mode.

1100 

1101 - `Optional<Boolean> interruptResponse`

1102 

1103 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

1104 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

1105 

1106 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

1107 

1108 - `Optional<Long> prefixPaddingMs`

1109 

1110 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

1111 milliseconds). Defaults to 300ms.

1112 

1113 - `Optional<Long> silenceDurationMs`

1114 

1115 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

1116 to 500ms. With shorter values the model will respond more quickly,

1117 but may jump in on short pauses from the user.

1118 

1119 - `Optional<Double> threshold`

1120 

1121 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

1122 higher threshold will require louder audio to activate the model, and

1123 thus might perform better in noisy environments.

1124 

1125 - `class SemanticVad:`

1126 

1127 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.

1128 

1129 - `JsonValue; type "semantic_vad"constant`

1130 

1131 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

1132 

1133 - `SEMANTIC_VAD("semantic_vad")`

1134 

1135 - `Optional<Boolean> createResponse`

1136 

1137 Whether or not to automatically generate a response when a VAD stop event occurs.

1138 

1139 - `Optional<Eagerness> eagerness`

1140 

1141 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

1142 

1143 - `LOW("low")`

1144 

1145 - `MEDIUM("medium")`

1146 

1147 - `HIGH("high")`

1148 

1149 - `AUTO("auto")`

1150 

1151 - `Optional<Boolean> interruptResponse`

1152 

1153 Whether or not to automatically interrupt any ongoing response with output to the default

1154 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

1155 

1156 - `Optional<Output> output`

1157 

1158 - `Optional<RealtimeAudioFormats> format`

1159 

1160 The format of the output audio.

1161 

1162 - `Optional<Double> speed`

1163 

1164 The speed of the model's spoken response as a multiple of the original speed.

1165 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.

1166 

1167 This parameter is a post-processing adjustment to the audio after it is generated, it's

1168 also possible to prompt the model to speak faster or slower.

1169 

1170 - `Optional<Voice> voice`

1171 

1172 The voice the model uses to respond. Voice cannot be changed during the

1173 session once the model has responded with audio at least once. Current

1174 voice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,

1175 `shimmer`, `verse`, `marin`, and `cedar`. We recommend `marin` and `cedar` for

1176 best quality.

1177 

1178 - `ALLOY("alloy")`

1179 

1180 - `ASH("ash")`

1181 

1182 - `BALLAD("ballad")`

1183 

1184 - `CORAL("coral")`

1185 

1186 - `ECHO("echo")`

1187 

1188 - `SAGE("sage")`

1189 

1190 - `SHIMMER("shimmer")`

1191 

1192 - `VERSE("verse")`

1193 

1194 - `MARIN("marin")`

1195 

1196 - `CEDAR("cedar")`

1197 

1198 - `Optional<Long> expiresAt`

1199 

1200 Expiration timestamp for the session, in seconds since epoch.

1201 

1202 - `Optional<List<Include>> include`

1203 

1204 Additional fields to include in server outputs.

1205 

1206 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

1207 

1208 - `ITEM_INPUT_AUDIO_TRANSCRIPTION_LOGPROBS("item.input_audio_transcription.logprobs")`

1209 

1210 - `Optional<String> instructions`

1211 

1212 The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.

1213 

1214 Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.

1215 

1216 - `Optional<MaxOutputTokens> maxOutputTokens`

1217 

1218 Maximum number of output tokens for a single assistant response,

1219 inclusive of tool calls. Provide an integer between 1 and 4096 to

1220 limit output tokens, or `inf` for the maximum available tokens for a

1221 given model. Defaults to `inf`.

1222 

1223 - `long`

1224 

1225 - `JsonValue;`

1226 

1227 - `INF("inf")`

1228 

1229 - `Optional<Model> model`

1230 

1231 The Realtime model used for this session.

1232 

1233 - `GPT_REALTIME("gpt-realtime")`

1234 

1235 - `GPT_REALTIME_1_5("gpt-realtime-1.5")`

1236 

1237 - `GPT_REALTIME_2("gpt-realtime-2")`

1238 

1239 - `GPT_REALTIME_2025_08_28("gpt-realtime-2025-08-28")`

1240 

1241 - `GPT_4O_REALTIME_PREVIEW("gpt-4o-realtime-preview")`

1242 

1243 - `GPT_4O_REALTIME_PREVIEW_2024_10_01("gpt-4o-realtime-preview-2024-10-01")`

1244 

1245 - `GPT_4O_REALTIME_PREVIEW_2024_12_17("gpt-4o-realtime-preview-2024-12-17")`

1246 

1247 - `GPT_4O_REALTIME_PREVIEW_2025_06_03("gpt-4o-realtime-preview-2025-06-03")`

1248 

1249 - `GPT_4O_MINI_REALTIME_PREVIEW("gpt-4o-mini-realtime-preview")`

1250 

1251 - `GPT_4O_MINI_REALTIME_PREVIEW_2024_12_17("gpt-4o-mini-realtime-preview-2024-12-17")`

1252 

1253 - `GPT_REALTIME_MINI("gpt-realtime-mini")`

1254 

1255 - `GPT_REALTIME_MINI_2025_10_06("gpt-realtime-mini-2025-10-06")`

1256 

1257 - `GPT_REALTIME_MINI_2025_12_15("gpt-realtime-mini-2025-12-15")`

1258 

1259 - `GPT_AUDIO_1_5("gpt-audio-1.5")`

1260 

1261 - `GPT_AUDIO_MINI("gpt-audio-mini")`

1262 

1263 - `GPT_AUDIO_MINI_2025_10_06("gpt-audio-mini-2025-10-06")`

1264 

1265 - `GPT_AUDIO_MINI_2025_12_15("gpt-audio-mini-2025-12-15")`

1266 

1267 - `Optional<List<OutputModality>> outputModalities`

1268 

1269 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating

1270 that the model will respond with audio plus a transcript. `["text"]` can be used to make

1271 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.

1272 

1273 - `TEXT("text")`

1274 

1275 - `AUDIO("audio")`

1276 

1277 - `Optional<ResponsePrompt> prompt`

1278 

1279 Reference to a prompt template and its variables.

1280 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).

1281 

1282 - `String id`

1283 

1284 The unique identifier of the prompt template to use.

1285 

1286 - `Optional<Variables> variables`

1287 

1288 Optional map of values to substitute in for variables in your

1289 prompt. The substitution values can either be strings, or other

1290 Response input types like images or files.

1291 

1292 - `String`

1293 

1294 - `class ResponseInputText:`

1295 

1296 A text input to the model.

1297 

1298 - `String text`

1299 

1300 The text input to the model.

1301 

1302 - `JsonValue; type "input_text"constant`

1303 

1304 The type of the input item. Always `input_text`.

1305 

1306 - `INPUT_TEXT("input_text")`

1307 

1308 - `class ResponseInputImage:`

1309 

1310 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).

1311 

1312 - `Detail detail`

1313 

1314 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.

1315 

1316 - `LOW("low")`

1317 

1318 - `HIGH("high")`

1319 

1320 - `AUTO("auto")`

1321 

1322 - `ORIGINAL("original")`

1323 

1324 - `JsonValue; type "input_image"constant`

1325 

1326 The type of the input item. Always `input_image`.

1327 

1328 - `INPUT_IMAGE("input_image")`

1329 

1330 - `Optional<String> fileId`

1331 

1332 The ID of the file to be sent to the model.

1333 

1334 - `Optional<String> imageUrl`

1335 

1336 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.

1337 

1338 - `class ResponseInputFile:`

1339 

1340 A file input to the model.

1341 

1342 - `JsonValue; type "input_file"constant`

1343 

1344 The type of the input item. Always `input_file`.

1345 

1346 - `INPUT_FILE("input_file")`

1347 

1348 - `Optional<Detail> detail`

1349 

1350 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.

1351 

1352 - `LOW("low")`

1353 

1354 - `HIGH("high")`

1355 

1356 - `Optional<String> fileData`

1357 

1358 The content of the file to be sent to the model.

1359 

1360 - `Optional<String> fileId`

1361 

1362 The ID of the file to be sent to the model.

1363 

1364 - `Optional<String> fileUrl`

1365 

1366 The URL of the file to be sent to the model.

1367 

1368 - `Optional<String> filename`

1369 

1370 The name of the file to be sent to the model.

1371 

1372 - `Optional<String> version`

1373 

1374 Optional version of the prompt template.

1375 

1376 - `Optional<RealtimeReasoning> reasoning`

1377 

1378 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.

1379 

1380 - `Optional<RealtimeReasoningEffort> effort`

1381 

1382 Constrains effort on reasoning for reasoning-capable Realtime models such as

1383 `gpt-realtime-2`.

1384 

1385 - `MINIMAL("minimal")`

1386 

1387 - `LOW("low")`

1388 

1389 - `MEDIUM("medium")`

1390 

1391 - `HIGH("high")`

1392 

1393 - `XHIGH("xhigh")`

1394 

1395 - `Optional<ToolChoice> toolChoice`

1396 

1397 How the model chooses tools. Provide one of the string modes or force a specific

1398 function/MCP tool.

1399 

1400 - `enum ToolChoiceOptions:`

1401 

1402 Controls which (if any) tool is called by the model.

1403 

1404 `none` means the model will not call any tool and instead generates a message.

1405 

1406 `auto` means the model can pick between generating a message or calling one or

1407 more tools.

1408 

1409 `required` means the model must call one or more tools.

1410 

1411 - `NONE("none")`

1412 

1413 - `AUTO("auto")`

1414 

1415 - `REQUIRED("required")`

1416 

1417 - `class ToolChoiceFunction:`

1418 

1419 Use this option to force the model to call a specific function.

1420 

1421 - `String name`

1422 

1423 The name of the function to call.

1424 

1425 - `JsonValue; type "function"constant`

1426 

1427 For function calling, the type is always `function`.

1428 

1429 - `FUNCTION("function")`

1430 

1431 - `class ToolChoiceMcp:`

1432 

1433 Use this option to force the model to call a specific tool on a remote MCP server.

1434 

1435 - `String serverLabel`

1436 

1437 The label of the MCP server to use.

1438 

1439 - `JsonValue; type "mcp"constant`

1440 

1441 For MCP tools, the type is always `mcp`.

1442 

1443 - `MCP("mcp")`

1444 

1445 - `Optional<String> name`

1446 

1447 The name of the tool to call on the server.

1448 

1449 - `Optional<List<Tool>> tools`

1450 

1451 Tools available to the model.

1452 

1453 - `class RealtimeFunctionTool:`

1454 

1455 - `Optional<String> description`

1456 

1457 The description of the function, including guidance on when and how

1458 to call it, and guidance about what to tell the user when calling

1459 (if anything).

1460 

1461 - `Optional<String> name`

1462 

1463 The name of the function.

1464 

1465 - `Optional<JsonValue> parameters`

1466 

1467 Parameters of the function in JSON Schema.

1468 

1469 - `Optional<Type> type`

1470 

1471 The type of the tool, i.e. `function`.

1472 

1473 - `FUNCTION("function")`

1474 

1475 - `class McpTool:`

1476 

1477 Give the model access to additional tools via remote Model Context Protocol

1478 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).

1479 

1480 - `String serverLabel`

1481 

1482 A label for this MCP server, used to identify it in tool calls.

1483 

1484 - `JsonValue; type "mcp"constant`

1485 

1486 The type of the MCP tool. Always `mcp`.

1487 

1488 - `MCP("mcp")`

1489 

1490 - `Optional<AllowedTools> allowedTools`

1491 

1492 List of allowed tool names or a filter object.

1493 

1494 - `List<String>`

1495 

1496 - `class McpToolFilter:`

1497 

1498 A filter object to specify which tools are allowed.

1499 

1500 - `Optional<Boolean> readOnly`

1501 

1502 Indicates whether or not a tool modifies data or is read-only. If an

1503 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1504 it will match this filter.

1505 

1506 - `Optional<List<String>> toolNames`

1507 

1508 List of allowed tool names.

1509 

1510 - `Optional<String> authorization`

1511 

1512 An OAuth access token that can be used with a remote MCP server, either

1513 with a custom MCP server URL or a service connector. Your application

1514 must handle the OAuth authorization flow and provide the token here.

1515 

1516 - `Optional<ConnectorId> connectorId`

1517 

1518 Identifier for service connectors, like those available in ChatGPT. One of

1519 `server_url` or `connector_id` must be provided. Learn more about service

1520 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).

1521 

1522 Currently supported `connector_id` values are:

1523 

1524 - Dropbox: `connector_dropbox`

1525 - Gmail: `connector_gmail`

1526 - Google Calendar: `connector_googlecalendar`

1527 - Google Drive: `connector_googledrive`

1528 - Microsoft Teams: `connector_microsoftteams`

1529 - Outlook Calendar: `connector_outlookcalendar`

1530 - Outlook Email: `connector_outlookemail`

1531 - SharePoint: `connector_sharepoint`

1532 

1533 - `CONNECTOR_DROPBOX("connector_dropbox")`

1534 

1535 - `CONNECTOR_GMAIL("connector_gmail")`

1536 

1537 - `CONNECTOR_GOOGLECALENDAR("connector_googlecalendar")`

1538 

1539 - `CONNECTOR_GOOGLEDRIVE("connector_googledrive")`

1540 

1541 - `CONNECTOR_MICROSOFTTEAMS("connector_microsoftteams")`

1542 

1543 - `CONNECTOR_OUTLOOKCALENDAR("connector_outlookcalendar")`

1544 

1545 - `CONNECTOR_OUTLOOKEMAIL("connector_outlookemail")`

1546 

1547 - `CONNECTOR_SHAREPOINT("connector_sharepoint")`

1548 

1549 - `Optional<Boolean> deferLoading`

1550 

1551 Whether this MCP tool is deferred and discovered via tool search.

1552 

1553 - `Optional<Headers> headers`

1554 

1555 Optional HTTP headers to send to the MCP server. Use for authentication

1556 or other purposes.

1557 

1558 - `Optional<RequireApproval> requireApproval`

1559 

1560 Specify which of the MCP server's tools require approval.

1561 

1562 - `class McpToolApprovalFilter:`

1563 

1564 Specify which of the MCP server's tools require approval. Can be

1565 `always`, `never`, or a filter object associated with tools

1566 that require approval.

1567 

1568 - `Optional<Always> always`

1569 

1570 A filter object to specify which tools are allowed.

1571 

1572 - `Optional<Boolean> readOnly`

1573 

1574 Indicates whether or not a tool modifies data or is read-only. If an

1575 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1576 it will match this filter.

1577 

1578 - `Optional<List<String>> toolNames`

1579 

1580 List of allowed tool names.

1581 

1582 - `Optional<Never> never`

1583 

1584 A filter object to specify which tools are allowed.

1585 

1586 - `Optional<Boolean> readOnly`

1587 

1588 Indicates whether or not a tool modifies data or is read-only. If an

1589 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1590 it will match this filter.

1591 

1592 - `Optional<List<String>> toolNames`

1593 

1594 List of allowed tool names.

1595 

1596 - `enum McpToolApprovalSetting:`

1597 

1598 Specify a single approval policy for all tools. One of `always` or

1599 `never`. When set to `always`, all tools will require approval. When

1600 set to `never`, all tools will not require approval.

1601 

1602 - `ALWAYS("always")`

1603 

1604 - `NEVER("never")`

1605 

1606 - `Optional<String> serverDescription`

1607 

1608 Optional description of the MCP server, used to provide more context.

1609 

1610 - `Optional<String> serverUrl`

1611 

1612 The URL for the MCP server. One of `server_url` or `connector_id` must be

1613 provided.

1614 

1615 - `Optional<Tracing> tracing`

1616 

1617 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once

1618 tracing is enabled for a session, the configuration cannot be modified.

1619 

1620 `auto` will create a trace for the session with default values for the

1621 workflow name, group id, and metadata.

1622 

1623 - `JsonValue;`

1624 

1625 - `AUTO("auto")`

1626 

1627 - `class TracingConfiguration:`

1628 

1629 Granular configuration for tracing.

1630 

1631 - `Optional<String> groupId`

1632 

1633 The group id to attach to this trace to enable filtering and

1634 grouping in the Traces Dashboard.

1635 

1636 - `Optional<JsonValue> metadata`

1637 

1638 The arbitrary metadata to attach to this trace to enable

1639 filtering in the Traces Dashboard.

1640 

1641 - `Optional<String> workflowName`

1642 

1643 The name of the workflow to attach to this trace. This is used to

1644 name the trace in the Traces Dashboard.

1645 

1646 - `Optional<RealtimeTruncation> truncation`

1647 

1648 When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

1649 

1650 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

1651 

1652 Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

1653 

1654 Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.

1655 

1656 - `RealtimeTruncationStrategy`

1657 

1658 - `AUTO("auto")`

1659 

1660 - `DISABLED("disabled")`

1661 

1662 - `class RealtimeTruncationRetentionRatio:`

1663 

1664 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

1665 

1666 - `double retentionRatio`

1667 

1668 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.

1669 

1670 - `JsonValue; type "retention_ratio"constant`

1671 

1672 Use retention ratio truncation.

1673 

1674 - `RETENTION_RATIO("retention_ratio")`

1675 

1676 - `Optional<TokenLimits> tokenLimits`

1677 

1678 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.

1679 

1680 - `Optional<Long> postInstructions`

1681 

1682 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.

1683 

1684 - `class RealtimeTranscriptionSessionCreateResponse:`

1685 

1686 A Realtime transcription session configuration object.

1687 

1688 - `String id`

1689 

1690 Unique identifier for the session that looks like `sess_1234567890abcdef`.

1691 

1692 - `String object_`

1693 

1694 The object type. Always `realtime.transcription_session`.

1695 

1696 - `JsonValue; type "transcription"constant`

1697 

1698 The type of session. Always `transcription` for transcription sessions.

1699 

1700 - `TRANSCRIPTION("transcription")`

1701 

1702 - `Optional<Audio> audio`

1703 

1704 Configuration for input audio for the session.

1705 

1706 - `Optional<Input> input`

1707 

1708 - `Optional<RealtimeAudioFormats> format`

1709 

1710 The PCM audio format. Only a 24kHz sample rate is supported.

1711 

1712 - `Optional<NoiseReduction> noiseReduction`

1713 

1714 Configuration for input audio noise reduction.

1715 

1716 - `Optional<NoiseReductionType> type`

1717 

1718 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

1719 

1720 - `Optional<AudioTranscription> transcription`

1721 

1722 - `Optional<RealtimeTranscriptionSessionTurnDetection> turnDetection`

1723 

1724 Configuration for turn detection. Can be set to `null` to turn off. Server

1725 VAD means that the model will detect the start and end of speech based on

1726 audio volume and respond at the end of user speech. For `gpt-realtime-whisper`, this must be `null`; VAD is not supported.

1727 

1728 - `Optional<Long> prefixPaddingMs`

1729 

1730 Amount of audio to include before the VAD detected speech (in

1731 milliseconds). Defaults to 300ms.

1732 

1733 - `Optional<Long> silenceDurationMs`

1734 

1735 Duration of silence to detect speech stop (in milliseconds). Defaults

1736 to 500ms. With shorter values the model will respond more quickly,

1737 but may jump in on short pauses from the user.

1738 

1739 - `Optional<Double> threshold`

1740 

1741 Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

1742 higher threshold will require louder audio to activate the model, and

1743 thus might perform better in noisy environments.

1744 

1745 - `Optional<String> type`

1746 

1747 Type of turn detection, only `server_vad` is currently supported.

1748 

1749 - `Optional<Long> expiresAt`

1750 

1751 Expiration timestamp for the session, in seconds since epoch.

1752 

1753 - `Optional<List<Include>> include`

1754 

1755 Additional fields to include in server outputs.

1756 

1757 - `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

1758 

1759 - `ITEM_INPUT_AUDIO_TRANSCRIPTION_LOGPROBS("item.input_audio_transcription.logprobs")`

1760 

1761 - `String value`

1762 

1763 The generated client secret value.

1764 

1765### Example

1766 

1767```java

1768package com.openai.example;

1769 

1770import com.openai.client.OpenAIClient;

1771import com.openai.client.okhttp.OpenAIOkHttpClient;

1772import com.openai.models.realtime.clientsecrets.ClientSecretCreateParams;

1773import com.openai.models.realtime.clientsecrets.ClientSecretCreateResponse;

1774 

1775public final class Main {

1776 private Main() {}

1777 

1778 public static void main(String[] args) {

1779 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

1780 

1781 ClientSecretCreateResponse clientSecret = client.realtime().clientSecrets().create();

1782 }

1783}

1784```

1785 

1786#### Response

1787 

1788```json

1789{

1790 "expires_at": 0,

1791 "session": {

1792 "id": "id",

1793 "object": "realtime.session",

1794 "type": "realtime",

1795 "audio": {

1796 "input": {

1797 "format": {

1798 "rate": 24000,

1799 "type": "audio/pcm"

1800 },

1801 "noise_reduction": {

1802 "type": "near_field"

1803 },

1804 "transcription": {

1805 "delay": "minimal",

1806 "language": "language",

1807 "model": "whisper-1",

1808 "prompt": "prompt"

1809 },

1810 "turn_detection": {

1811 "type": "server_vad",

1812 "create_response": true,

1813 "idle_timeout_ms": 5000,

1814 "interrupt_response": true,

1815 "prefix_padding_ms": 0,

1816 "silence_duration_ms": 0,

1817 "threshold": 0

1818 }

1819 },

1820 "output": {

1821 "format": {

1822 "rate": 24000,

1823 "type": "audio/pcm"

1824 },

1825 "speed": 0.25,

1826 "voice": "ash"

1827 }

1828 },

1829 "expires_at": 0,

1830 "include": [

1831 "item.input_audio_transcription.logprobs"

1832 ],

1833 "instructions": "instructions",

1834 "max_output_tokens": "inf",

1835 "model": "gpt-realtime",

1836 "output_modalities": [

1837 "text"

1838 ],

1839 "prompt": {

1840 "id": "id",

1841 "variables": {

1842 "foo": "string"

1843 },

1844 "version": "version"

1845 },

1846 "reasoning": {

1847 "effort": "minimal"

1848 },

1849 "tool_choice": "none",

1850 "tools": [

1851 {

1852 "description": "description",

1853 "name": "name",

1854 "parameters": {},

1855 "type": "function"

1856 }

1857 ],

1858 "tracing": "auto",

1859 "truncation": "auto"

1860 },

1861 "value": "value"

1862}

1863```

Details

1## Create video

2 

3`Video videos().create(VideoCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/videos`

6 

7Create a new video generation job from a prompt and optional reference assets.

8 

9### Parameters

10 

11- `VideoCreateParams params`

12 

13 - `String prompt`

14 

15 Text prompt that describes the video to generate.

16 

17 - `Optional<InputReference> inputReference`

18 

19 Optional reference asset upload or reference object that guides generation.

20 

21 - `String`

22 

23 - `class ImageInputReferenceParam:`

24 

25 - `Optional<String> fileId`

26 

27 - `Optional<String> imageUrl`

28 

29 A fully qualified URL or base64-encoded data URL.

30 

31 - `Optional<VideoModel> model`

32 

33 The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to `sora-2`.

34 

35 - `Optional<VideoSeconds> seconds`

36 

37 Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds.

38 

39 - `Optional<VideoSize> size`

40 

41 Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280.

42 

43### Returns

44 

45- `class Video:`

46 

47 Structured information describing a generated video job.

48 

49 - `String id`

50 

51 Unique identifier for the video job.

52 

53 - `Optional<Long> completedAt`

54 

55 Unix timestamp (seconds) for when the job completed, if finished.

56 

57 - `long createdAt`

58 

59 Unix timestamp (seconds) for when the job was created.

60 

61 - `Optional<VideoCreateError> error`

62 

63 Error payload that explains why generation failed, if applicable.

64 

65 - `String code`

66 

67 A machine-readable error code that was returned.

68 

69 - `String message`

70 

71 A human-readable description of the error that was returned.

72 

73 - `Optional<Long> expiresAt`

74 

75 Unix timestamp (seconds) for when the downloadable assets expire, if set.

76 

77 - `VideoModel model`

78 

79 The video generation model that produced the job.

80 

81 - `SORA_2("sora-2")`

82 

83 - `SORA_2_PRO("sora-2-pro")`

84 

85 - `SORA_2_2025_10_06("sora-2-2025-10-06")`

86 

87 - `SORA_2_PRO_2025_10_06("sora-2-pro-2025-10-06")`

88 

89 - `SORA_2_2025_12_08("sora-2-2025-12-08")`

90 

91 - `JsonValue; object_ "video"constant`

92 

93 The object type, which is always `video`.

94 

95 - `VIDEO("video")`

96 

97 - `long progress`

98 

99 Approximate completion percentage for the generation task.

100 

101 - `Optional<String> prompt`

102 

103 The prompt that was used to generate the video.

104 

105 - `Optional<String> remixedFromVideoId`

106 

107 Identifier of the source video if this video is a remix.

108 

109 - `VideoSeconds seconds`

110 

111 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

112 

113 - `_4("4")`

114 

115 - `_8("8")`

116 

117 - `_12("12")`

118 

119 - `VideoSize size`

120 

121 The resolution of the generated video.

122 

123 - `_720X1280("720x1280")`

124 

125 - `_1280X720("1280x720")`

126 

127 - `_1024X1792("1024x1792")`

128 

129 - `_1792X1024("1792x1024")`

130 

131 - `Status status`

132 

133 Current lifecycle status of the video job.

134 

135 - `QUEUED("queued")`

136 

137 - `IN_PROGRESS("in_progress")`

138 

139 - `COMPLETED("completed")`

140 

141 - `FAILED("failed")`

142 

143### Example

144 

145```java

146package com.openai.example;

147 

148import com.openai.client.OpenAIClient;

149import com.openai.client.okhttp.OpenAIOkHttpClient;

150import com.openai.models.videos.Video;

151import com.openai.models.videos.VideoCreateParams;

152 

153public final class Main {

154 private Main() {}

155 

156 public static void main(String[] args) {

157 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

158 

159 VideoCreateParams params = VideoCreateParams.builder()

160 .prompt("x")

161 .build();

162 Video video = client.videos().create(params);

163 }

164}

165```

166 

167#### Response

168 

169```json

170{

171 "id": "id",

172 "completed_at": 0,

173 "created_at": 0,

174 "error": {

175 "code": "code",

176 "message": "message"

177 },

178 "expires_at": 0,

179 "model": "sora-2",

180 "object": "video",

181 "progress": 0,

182 "prompt": "prompt",

183 "remixed_from_video_id": "remixed_from_video_id",

184 "seconds": "4",

185 "size": "720x1280",

186 "status": "queued"

187}

188```

189 

190### Example

191 

192```java

193package com.openai.example;

194 

195import com.openai.client.OpenAIClient;

196import com.openai.client.okhttp.OpenAIOkHttpClient;

197import com.openai.models.videos.Video;

198import com.openai.models.videos.VideoCreateParams;

199 

200public final class Main {

201 private Main() {}

202 

203 public static void main(String[] args) {

204 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

205 

206 VideoCreateParams params = VideoCreateParams.builder()

207 .prompt("A calico cat playing a piano on stage")

208 .build();

209 Video video = client.videos().create(params);

210 }

211}

212```

213 

214#### Response

215 

216```json

217{

218 "id": "video_123",

219 "object": "video",

220 "model": "sora-2",

221 "status": "queued",

222 "progress": 0,

223 "created_at": 1712697600,

224 "size": "1024x1792",

225 "seconds": "8",

226 "quality": "standard"

227}

228```

Details

1## Create a new video generation job by editing a source video or existing generated video.

2 

3`Video videos().edit(VideoEditParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/videos/edits`

6 

7Create a new video generation job by editing a source video or existing generated video.

8 

9### Parameters

10 

11- `VideoEditParams params`

12 

13 - `String prompt`

14 

15 Text prompt that describes how to edit the source video.

16 

17 - `Video video`

18 

19 Reference to the completed video to edit.

20 

21 - `String`

22 

23 - `class VideoReferenceInputParam:`

24 

25 Reference to the completed video.

26 

27 - `String id`

28 

29 The identifier of the completed video.

30 

31### Returns

32 

33- `class Video:`

34 

35 Structured information describing a generated video job.

36 

37 - `String id`

38 

39 Unique identifier for the video job.

40 

41 - `Optional<Long> completedAt`

42 

43 Unix timestamp (seconds) for when the job completed, if finished.

44 

45 - `long createdAt`

46 

47 Unix timestamp (seconds) for when the job was created.

48 

49 - `Optional<VideoCreateError> error`

50 

51 Error payload that explains why generation failed, if applicable.

52 

53 - `String code`

54 

55 A machine-readable error code that was returned.

56 

57 - `String message`

58 

59 A human-readable description of the error that was returned.

60 

61 - `Optional<Long> expiresAt`

62 

63 Unix timestamp (seconds) for when the downloadable assets expire, if set.

64 

65 - `VideoModel model`

66 

67 The video generation model that produced the job.

68 

69 - `SORA_2("sora-2")`

70 

71 - `SORA_2_PRO("sora-2-pro")`

72 

73 - `SORA_2_2025_10_06("sora-2-2025-10-06")`

74 

75 - `SORA_2_PRO_2025_10_06("sora-2-pro-2025-10-06")`

76 

77 - `SORA_2_2025_12_08("sora-2-2025-12-08")`

78 

79 - `JsonValue; object_ "video"constant`

80 

81 The object type, which is always `video`.

82 

83 - `VIDEO("video")`

84 

85 - `long progress`

86 

87 Approximate completion percentage for the generation task.

88 

89 - `Optional<String> prompt`

90 

91 The prompt that was used to generate the video.

92 

93 - `Optional<String> remixedFromVideoId`

94 

95 Identifier of the source video if this video is a remix.

96 

97 - `VideoSeconds seconds`

98 

99 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

100 

101 - `_4("4")`

102 

103 - `_8("8")`

104 

105 - `_12("12")`

106 

107 - `VideoSize size`

108 

109 The resolution of the generated video.

110 

111 - `_720X1280("720x1280")`

112 

113 - `_1280X720("1280x720")`

114 

115 - `_1024X1792("1024x1792")`

116 

117 - `_1792X1024("1792x1024")`

118 

119 - `Status status`

120 

121 Current lifecycle status of the video job.

122 

123 - `QUEUED("queued")`

124 

125 - `IN_PROGRESS("in_progress")`

126 

127 - `COMPLETED("completed")`

128 

129 - `FAILED("failed")`

130 

131### Example

132 

133```java

134package com.openai.example;

135 

136import com.openai.client.OpenAIClient;

137import com.openai.client.okhttp.OpenAIOkHttpClient;

138import com.openai.models.videos.Video;

139import com.openai.models.videos.VideoEditParams;

140import java.io.ByteArrayInputStream;

141import java.io.InputStream;

142 

143public final class Main {

144 private Main() {}

145 

146 public static void main(String[] args) {

147 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

148 

149 VideoEditParams params = VideoEditParams.builder()

150 .prompt("x")

151 .video(new ByteArrayInputStream("Example data".getBytes()))

152 .build();

153 Video video = client.videos().edit(params);

154 }

155}

156```

157 

158#### Response

159 

160```json

161{

162 "id": "id",

163 "completed_at": 0,

164 "created_at": 0,

165 "error": {

166 "code": "code",

167 "message": "message"

168 },

169 "expires_at": 0,

170 "model": "sora-2",

171 "object": "video",

172 "progress": 0,

173 "prompt": "prompt",

174 "remixed_from_video_id": "remixed_from_video_id",

175 "seconds": "4",

176 "size": "720x1280",

177 "status": "queued"

178}

179```

Details

1## Create an extension of a completed video.

2 

3`Video videos().extend(VideoExtendParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/videos/extensions`

6 

7Create an extension of a completed video.

8 

9### Parameters

10 

11- `VideoExtendParams params`

12 

13 - `String prompt`

14 

15 Updated text prompt that directs the extension generation.

16 

17 - `VideoSeconds seconds`

18 

19 Length of the newly generated extension segment in seconds (allowed values: 4, 8, 12, 16, 20).

20 

21 - `Video video`

22 

23 Reference to the completed video to extend.

24 

25 - `String`

26 

27 - `class VideoReferenceInputParam:`

28 

29 Reference to the completed video.

30 

31 - `String id`

32 

33 The identifier of the completed video.

34 

35### Returns

36 

37- `class Video:`

38 

39 Structured information describing a generated video job.

40 

41 - `String id`

42 

43 Unique identifier for the video job.

44 

45 - `Optional<Long> completedAt`

46 

47 Unix timestamp (seconds) for when the job completed, if finished.

48 

49 - `long createdAt`

50 

51 Unix timestamp (seconds) for when the job was created.

52 

53 - `Optional<VideoCreateError> error`

54 

55 Error payload that explains why generation failed, if applicable.

56 

57 - `String code`

58 

59 A machine-readable error code that was returned.

60 

61 - `String message`

62 

63 A human-readable description of the error that was returned.

64 

65 - `Optional<Long> expiresAt`

66 

67 Unix timestamp (seconds) for when the downloadable assets expire, if set.

68 

69 - `VideoModel model`

70 

71 The video generation model that produced the job.

72 

73 - `SORA_2("sora-2")`

74 

75 - `SORA_2_PRO("sora-2-pro")`

76 

77 - `SORA_2_2025_10_06("sora-2-2025-10-06")`

78 

79 - `SORA_2_PRO_2025_10_06("sora-2-pro-2025-10-06")`

80 

81 - `SORA_2_2025_12_08("sora-2-2025-12-08")`

82 

83 - `JsonValue; object_ "video"constant`

84 

85 The object type, which is always `video`.

86 

87 - `VIDEO("video")`

88 

89 - `long progress`

90 

91 Approximate completion percentage for the generation task.

92 

93 - `Optional<String> prompt`

94 

95 The prompt that was used to generate the video.

96 

97 - `Optional<String> remixedFromVideoId`

98 

99 Identifier of the source video if this video is a remix.

100 

101 - `VideoSeconds seconds`

102 

103 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

104 

105 - `_4("4")`

106 

107 - `_8("8")`

108 

109 - `_12("12")`

110 

111 - `VideoSize size`

112 

113 The resolution of the generated video.

114 

115 - `_720X1280("720x1280")`

116 

117 - `_1280X720("1280x720")`

118 

119 - `_1024X1792("1024x1792")`

120 

121 - `_1792X1024("1792x1024")`

122 

123 - `Status status`

124 

125 Current lifecycle status of the video job.

126 

127 - `QUEUED("queued")`

128 

129 - `IN_PROGRESS("in_progress")`

130 

131 - `COMPLETED("completed")`

132 

133 - `FAILED("failed")`

134 

135### Example

136 

137```java

138package com.openai.example;

139 

140import com.openai.client.OpenAIClient;

141import com.openai.client.okhttp.OpenAIOkHttpClient;

142import com.openai.models.videos.Video;

143import com.openai.models.videos.VideoExtendParams;

144import com.openai.models.videos.VideoSeconds;

145import java.io.ByteArrayInputStream;

146import java.io.InputStream;

147 

148public final class Main {

149 private Main() {}

150 

151 public static void main(String[] args) {

152 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

153 

154 VideoExtendParams params = VideoExtendParams.builder()

155 .prompt("x")

156 .seconds(VideoSeconds._4)

157 .video(new ByteArrayInputStream("Example data".getBytes()))

158 .build();

159 Video video = client.videos().extend(params);

160 }

161}

162```

163 

164#### Response

165 

166```json

167{

168 "id": "id",

169 "completed_at": 0,

170 "created_at": 0,

171 "error": {

172 "code": "code",

173 "message": "message"

174 },

175 "expires_at": 0,

176 "model": "sora-2",

177 "object": "video",

178 "progress": 0,

179 "prompt": "prompt",

180 "remixed_from_video_id": "remixed_from_video_id",

181 "seconds": "4",

182 "size": "720x1280",

183 "status": "queued"

184}

185```

Details

1## List videos

2 

3`VideoListPage videos().list(VideoListParamsparams = VideoListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**get** `/videos`

6 

7List recently generated videos for the current project.

8 

9### Parameters

10 

11- `VideoListParams params`

12 

13 - `Optional<String> after`

14 

15 Identifier for the last item from the previous pagination request

16 

17 - `Optional<Long> limit`

18 

19 Number of items to retrieve

20 

21 - `Optional<Order> order`

22 

23 Sort order of results by timestamp. Use `asc` for ascending order or `desc` for descending order.

24 

25 - `ASC("asc")`

26 

27 - `DESC("desc")`

28 

29### Returns

30 

31- `class Video:`

32 

33 Structured information describing a generated video job.

34 

35 - `String id`

36 

37 Unique identifier for the video job.

38 

39 - `Optional<Long> completedAt`

40 

41 Unix timestamp (seconds) for when the job completed, if finished.

42 

43 - `long createdAt`

44 

45 Unix timestamp (seconds) for when the job was created.

46 

47 - `Optional<VideoCreateError> error`

48 

49 Error payload that explains why generation failed, if applicable.

50 

51 - `String code`

52 

53 A machine-readable error code that was returned.

54 

55 - `String message`

56 

57 A human-readable description of the error that was returned.

58 

59 - `Optional<Long> expiresAt`

60 

61 Unix timestamp (seconds) for when the downloadable assets expire, if set.

62 

63 - `VideoModel model`

64 

65 The video generation model that produced the job.

66 

67 - `SORA_2("sora-2")`

68 

69 - `SORA_2_PRO("sora-2-pro")`

70 

71 - `SORA_2_2025_10_06("sora-2-2025-10-06")`

72 

73 - `SORA_2_PRO_2025_10_06("sora-2-pro-2025-10-06")`

74 

75 - `SORA_2_2025_12_08("sora-2-2025-12-08")`

76 

77 - `JsonValue; object_ "video"constant`

78 

79 The object type, which is always `video`.

80 

81 - `VIDEO("video")`

82 

83 - `long progress`

84 

85 Approximate completion percentage for the generation task.

86 

87 - `Optional<String> prompt`

88 

89 The prompt that was used to generate the video.

90 

91 - `Optional<String> remixedFromVideoId`

92 

93 Identifier of the source video if this video is a remix.

94 

95 - `VideoSeconds seconds`

96 

97 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

98 

99 - `_4("4")`

100 

101 - `_8("8")`

102 

103 - `_12("12")`

104 

105 - `VideoSize size`

106 

107 The resolution of the generated video.

108 

109 - `_720X1280("720x1280")`

110 

111 - `_1280X720("1280x720")`

112 

113 - `_1024X1792("1024x1792")`

114 

115 - `_1792X1024("1792x1024")`

116 

117 - `Status status`

118 

119 Current lifecycle status of the video job.

120 

121 - `QUEUED("queued")`

122 

123 - `IN_PROGRESS("in_progress")`

124 

125 - `COMPLETED("completed")`

126 

127 - `FAILED("failed")`

128 

129### Example

130 

131```java

132package com.openai.example;

133 

134import com.openai.client.OpenAIClient;

135import com.openai.client.okhttp.OpenAIOkHttpClient;

136import com.openai.models.videos.VideoListPage;

137import com.openai.models.videos.VideoListParams;

138 

139public final class Main {

140 private Main() {}

141 

142 public static void main(String[] args) {

143 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

144 

145 VideoListPage page = client.videos().list();

146 }

147}

148```

149 

150#### Response

151 

152```json

153{

154 "data": [

155 {

156 "id": "id",

157 "completed_at": 0,

158 "created_at": 0,

159 "error": {

160 "code": "code",

161 "message": "message"

162 },

163 "expires_at": 0,

164 "model": "sora-2",

165 "object": "video",

166 "progress": 0,

167 "prompt": "prompt",

168 "remixed_from_video_id": "remixed_from_video_id",

169 "seconds": "4",

170 "size": "720x1280",

171 "status": "queued"

172 }

173 ],

174 "first_id": "first_id",

175 "has_more": true,

176 "last_id": "last_id",

177 "object": "list"

178}

179```

180 

181### Example

182 

183```java

184package com.openai.example;

185 

186import com.openai.client.OpenAIClient;

187import com.openai.client.okhttp.OpenAIOkHttpClient;

188import com.openai.models.videos.VideoListPage;

189import com.openai.models.videos.VideoListParams;

190 

191public final class Main {

192 private Main() {}

193 

194 public static void main(String[] args) {

195 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

196 

197 VideoListPage page = client.videos().list();

198 }

199}

200```

201 

202#### Response

203 

204```json

205{

206 "data": [

207 {

208 "id": "video_123",

209 "object": "video",

210 "model": "sora-2",

211 "status": "completed"

212 }

213 ],

214 "object": "list"

215}

216```

Details

1## Remix video

2 

3`Video videos().remix(VideoRemixParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**post** `/videos/{video_id}/remix`

6 

7Create a remix of a completed video using a refreshed prompt.

8 

9### Parameters

10 

11- `VideoRemixParams params`

12 

13 - `Optional<String> videoId`

14 

15 - `String prompt`

16 

17 Updated text prompt that directs the remix generation.

18 

19### Returns

20 

21- `class Video:`

22 

23 Structured information describing a generated video job.

24 

25 - `String id`

26 

27 Unique identifier for the video job.

28 

29 - `Optional<Long> completedAt`

30 

31 Unix timestamp (seconds) for when the job completed, if finished.

32 

33 - `long createdAt`

34 

35 Unix timestamp (seconds) for when the job was created.

36 

37 - `Optional<VideoCreateError> error`

38 

39 Error payload that explains why generation failed, if applicable.

40 

41 - `String code`

42 

43 A machine-readable error code that was returned.

44 

45 - `String message`

46 

47 A human-readable description of the error that was returned.

48 

49 - `Optional<Long> expiresAt`

50 

51 Unix timestamp (seconds) for when the downloadable assets expire, if set.

52 

53 - `VideoModel model`

54 

55 The video generation model that produced the job.

56 

57 - `SORA_2("sora-2")`

58 

59 - `SORA_2_PRO("sora-2-pro")`

60 

61 - `SORA_2_2025_10_06("sora-2-2025-10-06")`

62 

63 - `SORA_2_PRO_2025_10_06("sora-2-pro-2025-10-06")`

64 

65 - `SORA_2_2025_12_08("sora-2-2025-12-08")`

66 

67 - `JsonValue; object_ "video"constant`

68 

69 The object type, which is always `video`.

70 

71 - `VIDEO("video")`

72 

73 - `long progress`

74 

75 Approximate completion percentage for the generation task.

76 

77 - `Optional<String> prompt`

78 

79 The prompt that was used to generate the video.

80 

81 - `Optional<String> remixedFromVideoId`

82 

83 Identifier of the source video if this video is a remix.

84 

85 - `VideoSeconds seconds`

86 

87 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

88 

89 - `_4("4")`

90 

91 - `_8("8")`

92 

93 - `_12("12")`

94 

95 - `VideoSize size`

96 

97 The resolution of the generated video.

98 

99 - `_720X1280("720x1280")`

100 

101 - `_1280X720("1280x720")`

102 

103 - `_1024X1792("1024x1792")`

104 

105 - `_1792X1024("1792x1024")`

106 

107 - `Status status`

108 

109 Current lifecycle status of the video job.

110 

111 - `QUEUED("queued")`

112 

113 - `IN_PROGRESS("in_progress")`

114 

115 - `COMPLETED("completed")`

116 

117 - `FAILED("failed")`

118 

119### Example

120 

121```java

122package com.openai.example;

123 

124import com.openai.client.OpenAIClient;

125import com.openai.client.okhttp.OpenAIOkHttpClient;

126import com.openai.models.videos.Video;

127import com.openai.models.videos.VideoRemixParams;

128 

129public final class Main {

130 private Main() {}

131 

132 public static void main(String[] args) {

133 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

134 

135 VideoRemixParams params = VideoRemixParams.builder()

136 .videoId("video_123")

137 .prompt("x")

138 .build();

139 Video video = client.videos().remix(params);

140 }

141}

142```

143 

144#### Response

145 

146```json

147{

148 "id": "id",

149 "completed_at": 0,

150 "created_at": 0,

151 "error": {

152 "code": "code",

153 "message": "message"

154 },

155 "expires_at": 0,

156 "model": "sora-2",

157 "object": "video",

158 "progress": 0,

159 "prompt": "prompt",

160 "remixed_from_video_id": "remixed_from_video_id",

161 "seconds": "4",

162 "size": "720x1280",

163 "status": "queued"

164}

165```

166 

167### Example

168 

169```java

170package com.openai.example;

171 

172import com.openai.client.OpenAIClient;

173import com.openai.client.okhttp.OpenAIOkHttpClient;

174import com.openai.models.videos.Video;

175import com.openai.models.videos.VideoRemixParams;

176 

177public final class Main {

178 private Main() {}

179 

180 public static void main(String[] args) {

181 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

182 

183 VideoRemixParams params = VideoRemixParams.builder()

184 .videoId("video_123")

185 .prompt("Extend the scene with the cat taking a bow to the cheering audience")

186 .build();

187 Video video = client.videos().remix(params);

188 }

189}

190```

191 

192#### Response

193 

194```json

195{

196 "id": "video_456",

197 "object": "video",

198 "model": "sora-2",

199 "status": "queued",

200 "progress": 0,

201 "created_at": 1712698600,

202 "size": "720x1280",

203 "seconds": "8",

204 "remixed_from_video_id": "video_123"

205}

206```

Details

1## Retrieve video

2 

3`Video videos().retrieve(VideoRetrieveParamsparams = VideoRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

4 

5**get** `/videos/{video_id}`

6 

7Fetch the latest metadata for a generated video.

8 

9### Parameters

10 

11- `VideoRetrieveParams params`

12 

13 - `Optional<String> videoId`

14 

15### Returns

16 

17- `class Video:`

18 

19 Structured information describing a generated video job.

20 

21 - `String id`

22 

23 Unique identifier for the video job.

24 

25 - `Optional<Long> completedAt`

26 

27 Unix timestamp (seconds) for when the job completed, if finished.

28 

29 - `long createdAt`

30 

31 Unix timestamp (seconds) for when the job was created.

32 

33 - `Optional<VideoCreateError> error`

34 

35 Error payload that explains why generation failed, if applicable.

36 

37 - `String code`

38 

39 A machine-readable error code that was returned.

40 

41 - `String message`

42 

43 A human-readable description of the error that was returned.

44 

45 - `Optional<Long> expiresAt`

46 

47 Unix timestamp (seconds) for when the downloadable assets expire, if set.

48 

49 - `VideoModel model`

50 

51 The video generation model that produced the job.

52 

53 - `SORA_2("sora-2")`

54 

55 - `SORA_2_PRO("sora-2-pro")`

56 

57 - `SORA_2_2025_10_06("sora-2-2025-10-06")`

58 

59 - `SORA_2_PRO_2025_10_06("sora-2-pro-2025-10-06")`

60 

61 - `SORA_2_2025_12_08("sora-2-2025-12-08")`

62 

63 - `JsonValue; object_ "video"constant`

64 

65 The object type, which is always `video`.

66 

67 - `VIDEO("video")`

68 

69 - `long progress`

70 

71 Approximate completion percentage for the generation task.

72 

73 - `Optional<String> prompt`

74 

75 The prompt that was used to generate the video.

76 

77 - `Optional<String> remixedFromVideoId`

78 

79 Identifier of the source video if this video is a remix.

80 

81 - `VideoSeconds seconds`

82 

83 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

84 

85 - `_4("4")`

86 

87 - `_8("8")`

88 

89 - `_12("12")`

90 

91 - `VideoSize size`

92 

93 The resolution of the generated video.

94 

95 - `_720X1280("720x1280")`

96 

97 - `_1280X720("1280x720")`

98 

99 - `_1024X1792("1024x1792")`

100 

101 - `_1792X1024("1792x1024")`

102 

103 - `Status status`

104 

105 Current lifecycle status of the video job.

106 

107 - `QUEUED("queued")`

108 

109 - `IN_PROGRESS("in_progress")`

110 

111 - `COMPLETED("completed")`

112 

113 - `FAILED("failed")`

114 

115### Example

116 

117```java

118package com.openai.example;

119 

120import com.openai.client.OpenAIClient;

121import com.openai.client.okhttp.OpenAIOkHttpClient;

122import com.openai.models.videos.Video;

123import com.openai.models.videos.VideoRetrieveParams;

124 

125public final class Main {

126 private Main() {}

127 

128 public static void main(String[] args) {

129 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

130 

131 Video video = client.videos().retrieve("video_123");

132 }

133}

134```

135 

136#### Response

137 

138```json

139{

140 "id": "id",

141 "completed_at": 0,

142 "created_at": 0,

143 "error": {

144 "code": "code",

145 "message": "message"

146 },

147 "expires_at": 0,

148 "model": "sora-2",

149 "object": "video",

150 "progress": 0,

151 "prompt": "prompt",

152 "remixed_from_video_id": "remixed_from_video_id",

153 "seconds": "4",

154 "size": "720x1280",

155 "status": "queued"

156}

157```

158 

159### Example

160 

161```java

162package com.openai.example;

163 

164import com.openai.client.OpenAIClient;

165import com.openai.client.okhttp.OpenAIOkHttpClient;

166import com.openai.models.videos.Video;

167import com.openai.models.videos.VideoRetrieveParams;

168 

169public final class Main {

170 private Main() {}

171 

172 public static void main(String[] args) {

173 OpenAIClient client = OpenAIOkHttpClient.fromEnv();

174 

175 Video video = client.videos().retrieve("video_123");

176 }

177}

178```

Details

1## Create speech

2 

3`audio.speech.create(SpeechCreateParams**kwargs) -> BinaryResponseContent`

4 

5**post** `/audio/speech`

6 

7Generates audio from the input text.

8 

9Returns the audio file content, or a stream of audio events.

10 

11### Parameters

12 

13- `input: str`

14 

15 The text to generate audio for. The maximum length is 4096 characters.

16 

17- `model: Union[str, SpeechModel]`

18 

19 One of the available [TTS models](https://platform.openai.com/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.

20 

21 - `str`

22 

23 - `Literal["tts-1", "tts-1-hd", "gpt-4o-mini-tts", "gpt-4o-mini-tts-2025-12-15"]`

24 

25 - `"tts-1"`

26 

27 - `"tts-1-hd"`

28 

29 - `"gpt-4o-mini-tts"`

30 

31 - `"gpt-4o-mini-tts-2025-12-15"`

32 

33- `voice: Voice`

34 

35 The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ "id": "voice_1234" }`. Previews of the voices are available in the [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).

36 

37 - `str`

38 

39 - `Literal["alloy", "ash", "ballad", 7 more]`

40 

41 - `"alloy"`

42 

43 - `"ash"`

44 

45 - `"ballad"`

46 

47 - `"coral"`

48 

49 - `"echo"`

50 

51 - `"sage"`

52 

53 - `"shimmer"`

54 

55 - `"verse"`

56 

57 - `"marin"`

58 

59 - `"cedar"`

60 

61 - `class VoiceID: …`

62 

63 Custom voice reference.

64 

65 - `id: str`

66 

67 The custom voice ID, e.g. `voice_1234`.

68 

69- `instructions: Optional[str]`

70 

71 Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.

72 

73- `response_format: Optional[Literal["mp3", "opus", "aac", 3 more]]`

74 

75 The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.

76 

77 - `"mp3"`

78 

79 - `"opus"`

80 

81 - `"aac"`

82 

83 - `"flac"`

84 

85 - `"wav"`

86 

87 - `"pcm"`

88 

89- `speed: Optional[float]`

90 

91 The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.

92 

93- `stream_format: Optional[Literal["sse", "audio"]]`

94 

95 The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.

96 

97 - `"sse"`

98 

99 - `"audio"`

100 

101### Returns

102 

103- `BinaryResponseContent`

104 

105### Example

106 

107```python

108import os

109from openai import OpenAI

110 

111client = OpenAI(

112 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted

113)

114speech = client.audio.speech.create(

115 input="input",

116 model="tts-1",

117 voice="alloy",

118)

119print(speech)

120content = speech.read()

121print(content)

122```

123 

124### Example

125 

126```python

127from pathlib import Path

128import openai

129 

130speech_file_path = Path(__file__).parent / "speech.mp3"

131with openai.audio.speech.with_streaming_response.create(

132 model="gpt-4o-mini-tts",

133 voice="alloy",

134 input="The quick brown fox jumped over the lazy dog."

135) as response:

136 response.stream_to_file(speech_file_path)

137```

Details

1## Create completion

2 

3`completions.create(CompletionCreateParams**kwargs) -> Completion`

4 

5**post** `/completions`

6 

7Creates a completion for the provided prompt and parameters.

8 

9Returns a completion object, or a sequence of completion objects if the request is streamed.

10 

11### Parameters

12 

13- `model: Union[str, Literal["gpt-3.5-turbo-instruct", "davinci-002", "babbage-002"]]`

14 

15 ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them.

16 

17 - `str`

18 

19 - `Literal["gpt-3.5-turbo-instruct", "davinci-002", "babbage-002"]`

20 

21 ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them.

22 

23 - `"gpt-3.5-turbo-instruct"`

24 

25 - `"davinci-002"`

26 

27 - `"babbage-002"`

28 

29- `prompt: Union[str, Sequence[str], Iterable[int], 2 more]`

30 

31 The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.

32 

33 Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.

34 

35 - `str`

36 

37 - `Sequence[str]`

38 

39 - `Iterable[int]`

40 

41 - `Iterable[Iterable[int]]`

42 

43- `best_of: Optional[int]`

44 

45 Generates `best_of` completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed.

46 

47 When used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`.

48 

49 **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.

50 

51- `echo: Optional[bool]`

52 

53 Echo back the prompt in addition to the completion

54 

55- `frequency_penalty: Optional[float]`

56 

57 Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

58 

59 [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)

60 

61- `logit_bias: Optional[Dict[str, int]]`

62 

63 Modify the likelihood of specified tokens appearing in the completion.

64 

65 Accepts a JSON object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.

66 

67 As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token from being generated.

68 

69- `logprobs: Optional[int]`

70 

71 Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.

72 

73 The maximum value for `logprobs` is 5.

74 

75- `max_tokens: Optional[int]`

76 

77 The maximum number of [tokens](/tokenizer) that can be generated in the completion.

78 

79 The token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.

80 

81- `n: Optional[int]`

82 

83 How many completions to generate for each prompt.

84 

85 **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.

86 

87- `presence_penalty: Optional[float]`

88 

89 Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

90 

91 [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)

92 

93- `seed: Optional[int]`

94 

95 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.

96 

97 Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.

98 

99- `stop: Optional[Union[Optional[str], Sequence[str], null]]`

100 

101 Not supported with latest reasoning models `o3` and `o4-mini`.

102 

103 Up to 4 sequences where the API will stop generating further tokens. The

104 returned text will not contain the stop sequence.

105 

106 - `Optional[str]`

107 

108 - `Sequence[str]`

109 

110- `stream: Optional[Literal[false]]`

111 

112 Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).

113 

114 - `false`

115 

116- `stream_options: Optional[ChatCompletionStreamOptionsParam]`

117 

118 Options for streaming response. Only set this when you set `stream: true`.

119 

120 - `include_obfuscation: Optional[bool]`

121 

122 When true, stream obfuscation will be enabled. Stream obfuscation adds

123 random characters to an `obfuscation` field on streaming delta events to

124 normalize payload sizes as a mitigation to certain side-channel attacks.

125 These obfuscation fields are included by default, but add a small amount

126 of overhead to the data stream. You can set `include_obfuscation` to

127 false to optimize for bandwidth if you trust the network links between

128 your application and the OpenAI API.

129 

130 - `include_usage: Optional[bool]`

131 

132 If set, an additional chunk will be streamed before the `data: [DONE]`

133 message. The `usage` field on this chunk shows the token usage statistics

134 for the entire request, and the `choices` field will always be an empty

135 array.

136 

137 All other chunks will also include a `usage` field, but with a null

138 value. **NOTE:** If the stream is interrupted, you may not receive the

139 final usage chunk which contains the total token usage for the request.

140 

141- `suffix: Optional[str]`

142 

143 The suffix that comes after a completion of inserted text.

144 

145 This parameter is only supported for `gpt-3.5-turbo-instruct`.

146 

147- `temperature: Optional[float]`

148 

149 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.

150 

151 We generally recommend altering this or `top_p` but not both.

152 

153- `top_p: Optional[float]`

154 

155 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

156 

157 We generally recommend altering this or `temperature` but not both.

158 

159- `user: Optional[str]`

160 

161 A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

162 

163### Returns

164 

165- `class Completion: …`

166 

167 Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint).

168 

169 - `id: str`

170 

171 A unique identifier for the completion.

172 

173 - `choices: List[CompletionChoice]`

174 

175 The list of completion choices the model generated for the input prompt.

176 

177 - `finish_reason: Literal["stop", "length", "content_filter"]`

178 

179 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,

180 `length` if the maximum number of tokens specified in the request was reached,

181 or `content_filter` if content was omitted due to a flag from our content filters.

182 

183 - `"stop"`

184 

185 - `"length"`

186 

187 - `"content_filter"`

188 

189 - `index: int`

190 

191 - `logprobs: Optional[Logprobs]`

192 

193 - `text_offset: Optional[List[int]]`

194 

195 - `token_logprobs: Optional[List[float]]`

196 

197 - `tokens: Optional[List[str]]`

198 

199 - `top_logprobs: Optional[List[Dict[str, float]]]`

200 

201 - `text: str`

202 

203 - `created: int`

204 

205 The Unix timestamp (in seconds) of when the completion was created.

206 

207 - `model: str`

208 

209 The model used for completion.

210 

211 - `object: Literal["text_completion"]`

212 

213 The object type, which is always "text_completion"

214 

215 - `"text_completion"`

216 

217 - `system_fingerprint: Optional[str]`

218 

219 This fingerprint represents the backend configuration that the model runs with.

220 

221 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.

222 

223 - `usage: Optional[CompletionUsage]`

224 

225 Usage statistics for the completion request.

226 

227 - `completion_tokens: int`

228 

229 Number of tokens in the generated completion.

230 

231 - `prompt_tokens: int`

232 

233 Number of tokens in the prompt.

234 

235 - `total_tokens: int`

236 

237 Total number of tokens used in the request (prompt + completion).

238 

239 - `completion_tokens_details: Optional[CompletionTokensDetails]`

240 

241 Breakdown of tokens used in a completion.

242 

243 - `accepted_prediction_tokens: Optional[int]`

244 

245 When using Predicted Outputs, the number of tokens in the

246 prediction that appeared in the completion.

247 

248 - `audio_tokens: Optional[int]`

249 

250 Audio input tokens generated by the model.

251 

252 - `reasoning_tokens: Optional[int]`

253 

254 Tokens generated by the model for reasoning.

255 

256 - `rejected_prediction_tokens: Optional[int]`

257 

258 When using Predicted Outputs, the number of tokens in the

259 prediction that did not appear in the completion. However, like

260 reasoning tokens, these tokens are still counted in the total

261 completion tokens for purposes of billing, output, and context window

262 limits.

263 

264 - `prompt_tokens_details: Optional[PromptTokensDetails]`

265 

266 Breakdown of tokens used in the prompt.

267 

268 - `audio_tokens: Optional[int]`

269 

270 Audio input tokens present in the prompt.

271 

272 - `cached_tokens: Optional[int]`

273 

274 Cached tokens present in the prompt.

275 

276### Example

277 

278```python

279import os

280from openai import OpenAI

281 

282client = OpenAI(

283 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted

284)

285for completion in client.completions.create(

286 model="gpt-3.5-turbo-instruct",

287 prompt="This is a test.",

288):

289 print(completion)

290```

291 

292#### Response

293 

294```json

295{

296 "id": "id",

297 "choices": [

298 {

299 "finish_reason": "stop",

300 "index": 0,

301 "logprobs": {

302 "text_offset": [

303 0

304 ],

305 "token_logprobs": [

306 0

307 ],

308 "tokens": [

309 "string"

310 ],

311 "top_logprobs": [

312 {

313 "foo": 0

314 }

315 ]

316 },

317 "text": "text"

318 }

319 ],

320 "created": 0,

321 "model": "model",

322 "object": "text_completion",

323 "system_fingerprint": "system_fingerprint",

324 "usage": {

325 "completion_tokens": 0,

326 "prompt_tokens": 0,

327 "total_tokens": 0,

328 "completion_tokens_details": {

329 "accepted_prediction_tokens": 0,

330 "audio_tokens": 0,

331 "reasoning_tokens": 0,

332 "rejected_prediction_tokens": 0

333 },

334 "prompt_tokens_details": {

335 "audio_tokens": 0,

336 "cached_tokens": 0

337 }

338 }

339}

340```

341 

342### No streaming

343 

344```python

345from openai import OpenAI

346client = OpenAI()

347 

348client.completions.create(

349 model="VAR_completion_model_id",

350 prompt="Say this is a test",

351 max_tokens=7,

352 temperature=0

353)

354```

355 

356#### Response

357 

358```json

359{

360 "id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",

361 "object": "text_completion",

362 "created": 1589478378,

363 "model": "VAR_completion_model_id",

364 "system_fingerprint": "fp_44709d6fcb",

365 "choices": [

366 {

367 "text": "\n\nThis is indeed a test",

368 "index": 0,

369 "logprobs": null,

370 "finish_reason": "length"

371 }

372 ],

373 "usage": {

374 "prompt_tokens": 5,

375 "completion_tokens": 7,

376 "total_tokens": 12

377 }

378}

379```

380 

381### Streaming

382 

383```python

384from openai import OpenAI

385client = OpenAI()

386 

387for chunk in client.completions.create(

388 model="VAR_completion_model_id",

389 prompt="Say this is a test",

390 max_tokens=7,

391 temperature=0,

392 stream=True

393):

394 print(chunk.choices[0].text)

395```

396 

397#### Response

398 

399```json

400{

401 "id": "cmpl-7iA7iJjj8V2zOkCGvWF2hAkDWBQZe",

402 "object": "text_completion",

403 "created": 1690759702,

404 "choices": [

405 {

406 "text": "This",

407 "index": 0,

408 "logprobs": null,

409 "finish_reason": null

410 }

411 ],

412 "model": "gpt-3.5-turbo-instruct"

413 "system_fingerprint": "fp_44709d6fcb",

414}

415```

Details

1## Create client secret

2 

3`realtime.client_secrets.create(ClientSecretCreateParams**kwargs) -> ClientSecretCreateResponse`

4 

5**post** `/realtime/client_secrets`

6 

7Create a Realtime client secret with an associated session configuration.

8 

9Client secrets are short-lived tokens that can be passed to a client app,

10such as a web frontend or mobile client, which grants access to the Realtime API without

11leaking your main API key. You can configure a custom TTL for each client secret.

12 

13You can also attach session configuration options to the client secret, which will be

14applied to any sessions created using that client secret, but these can also be overridden

15by the client connection.

16 

17[Learn more about authentication with client secrets over WebRTC](https://platform.openai.com/docs/guides/realtime-webrtc).

18 

19Returns the created client secret and the effective session object. The client secret is a string that looks like `ek_1234`.

20 

21### Parameters

22 

23- `expires_after: Optional[ExpiresAfter]`

24 

25 Configuration for the client secret expiration. Expiration refers to the time after which

26 a client secret will no longer be valid for creating sessions. The session itself may

27 continue after that time once started. A secret can be used to create multiple sessions

28 until it expires.

29 

30 - `anchor: Optional[Literal["created_at"]]`

31 

32 The anchor point for the client secret expiration, meaning that `seconds` will be added to the `created_at` time of the client secret to produce an expiration timestamp. Only `created_at` is currently supported.

33 

34 - `"created_at"`

35 

36 - `seconds: Optional[int]`

37 

38 The number of seconds from the anchor point to the expiration. Select a value between `10` and `7200` (2 hours). This default to 600 seconds (10 minutes) if not specified.

39 

40- `session: Optional[Session]`

41 

42 Session configuration to use for the client secret. Choose either a realtime

43 session or a transcription session.

44 

45 - `class RealtimeSessionCreateRequest: …`

46 

47 Realtime session object configuration.

48 

49 - `type: Literal["realtime"]`

50 

51 The type of session to create. Always `realtime` for the Realtime API.

52 

53 - `"realtime"`

54 

55 - `audio: Optional[RealtimeAudioConfig]`

56 

57 Configuration for input and output audio.

58 

59 - `input: Optional[RealtimeAudioConfigInput]`

60 

61 - `format: Optional[RealtimeAudioFormats]`

62 

63 The format of the input audio.

64 

65 - `class AudioPCM: …`

66 

67 The PCM audio format. Only a 24kHz sample rate is supported.

68 

69 - `rate: Optional[Literal[24000]]`

70 

71 The sample rate of the audio. Always `24000`.

72 

73 - `24000`

74 

75 - `type: Optional[Literal["audio/pcm"]]`

76 

77 The audio format. Always `audio/pcm`.

78 

79 - `"audio/pcm"`

80 

81 - `class AudioPCMU: …`

82 

83 The G.711 μ-law format.

84 

85 - `type: Optional[Literal["audio/pcmu"]]`

86 

87 The audio format. Always `audio/pcmu`.

88 

89 - `"audio/pcmu"`

90 

91 - `class AudioPCMA: …`

92 

93 The G.711 A-law format.

94 

95 - `type: Optional[Literal["audio/pcma"]]`

96 

97 The audio format. Always `audio/pcma`.

98 

99 - `"audio/pcma"`

100 

101 - `noise_reduction: Optional[NoiseReduction]`

102 

103 Configuration for input audio noise reduction. This can be set to `null` to turn off.

104 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

105 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

106 

107 - `type: Optional[NoiseReductionType]`

108 

109 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

110 

111 - `"near_field"`

112 

113 - `"far_field"`

114 

115 - `transcription: Optional[AudioTranscription]`

116 

117 Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.

118 

119 - `delay: Optional[Literal["minimal", "low", "medium", 2 more]]`

120 

121 Controls how long the model waits before emitting transcription text.

122 Higher values can improve transcription accuracy at the cost of latency.

123 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

124 

125 - `"minimal"`

126 

127 - `"low"`

128 

129 - `"medium"`

130 

131 - `"high"`

132 

133 - `"xhigh"`

134 

135 - `language: Optional[str]`

136 

137 The language of the input audio. Supplying the input language in

138 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

139 will improve accuracy and latency.

140 

141 - `model: Optional[Union[str, Literal["whisper-1", "gpt-4o-mini-transcribe", "gpt-4o-mini-transcribe-2025-12-15", 3 more], null]]`

142 

143 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

144 

145 - `str`

146 

147 - `Literal["whisper-1", "gpt-4o-mini-transcribe", "gpt-4o-mini-transcribe-2025-12-15", 3 more]`

148 

149 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

150 

151 - `"whisper-1"`

152 

153 - `"gpt-4o-mini-transcribe"`

154 

155 - `"gpt-4o-mini-transcribe-2025-12-15"`

156 

157 - `"gpt-4o-transcribe"`

158 

159 - `"gpt-4o-transcribe-diarize"`

160 

161 - `"gpt-realtime-whisper"`

162 

163 - `prompt: Optional[str]`

164 

165 An optional text to guide the model's style or continue a previous audio

166 segment.

167 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).

168 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

169 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

170 

171 - `turn_detection: Optional[RealtimeAudioInputTurnDetection]`

172 

173 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

174 

175 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

176 

177 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

178 

179 For `gpt-realtime-whisper` transcription sessions, turn detection must be

180 set to `null`; VAD is not supported.

181 

182 - `class ServerVad: …`

183 

184 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.

185 

186 - `type: Literal["server_vad"]`

187 

188 Type of turn detection, `server_vad` to turn on simple Server VAD.

189 

190 - `"server_vad"`

191 

192 - `create_response: Optional[bool]`

193 

194 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

195 

196 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

197 

198 - `idle_timeout_ms: Optional[int]`

199 

200 Optional timeout after which a model response will be triggered automatically. This is

201 useful for situations in which a long pause from the user is unexpected, such as a phone

202 call. The model will effectively prompt the user to continue the conversation based

203 on the current context.

204 

205 The timeout value will be applied after the last model response's audio has finished playing,

206 i.e. it's set to the `response.done` time plus audio playback duration.

207 

208 An `input_audio_buffer.timeout_triggered` event (plus events

209 associated with the Response) will be emitted when the timeout is reached.

210 Idle timeout is currently only supported for `server_vad` mode.

211 

212 - `interrupt_response: Optional[bool]`

213 

214 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

215 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

216 

217 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

218 

219 - `prefix_padding_ms: Optional[int]`

220 

221 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

222 milliseconds). Defaults to 300ms.

223 

224 - `silence_duration_ms: Optional[int]`

225 

226 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

227 to 500ms. With shorter values the model will respond more quickly,

228 but may jump in on short pauses from the user.

229 

230 - `threshold: Optional[float]`

231 

232 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

233 higher threshold will require louder audio to activate the model, and

234 thus might perform better in noisy environments.

235 

236 - `class SemanticVad: …`

237 

238 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.

239 

240 - `type: Literal["semantic_vad"]`

241 

242 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

243 

244 - `"semantic_vad"`

245 

246 - `create_response: Optional[bool]`

247 

248 Whether or not to automatically generate a response when a VAD stop event occurs.

249 

250 - `eagerness: Optional[Literal["low", "medium", "high", "auto"]]`

251 

252 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

253 

254 - `"low"`

255 

256 - `"medium"`

257 

258 - `"high"`

259 

260 - `"auto"`

261 

262 - `interrupt_response: Optional[bool]`

263 

264 Whether or not to automatically interrupt any ongoing response with output to the default

265 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

266 

267 - `output: Optional[RealtimeAudioConfigOutput]`

268 

269 - `format: Optional[RealtimeAudioFormats]`

270 

271 The format of the output audio.

272 

273 - `speed: Optional[float]`

274 

275 The speed of the model's spoken response as a multiple of the original speed.

276 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.

277 

278 This parameter is a post-processing adjustment to the audio after it is generated, it's

279 also possible to prompt the model to speak faster or slower.

280 

281 - `voice: Optional[Voice]`

282 

283 The voice the model uses to respond. Supported built-in voices are

284 `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,

285 `marin`, and `cedar`. You may also provide a custom voice object with

286 an `id`, for example `{ "id": "voice_1234" }`. Voice cannot be changed

287 during the session once the model has responded with audio at least once.

288 We recommend `marin` and `cedar` for best quality.

289 

290 - `str`

291 

292 - `Literal["alloy", "ash", "ballad", 7 more]`

293 

294 - `"alloy"`

295 

296 - `"ash"`

297 

298 - `"ballad"`

299 

300 - `"coral"`

301 

302 - `"echo"`

303 

304 - `"sage"`

305 

306 - `"shimmer"`

307 

308 - `"verse"`

309 

310 - `"marin"`

311 

312 - `"cedar"`

313 

314 - `class VoiceID: …`

315 

316 Custom voice reference.

317 

318 - `id: str`

319 

320 The custom voice ID, e.g. `voice_1234`.

321 

322 - `include: Optional[List[Literal["item.input_audio_transcription.logprobs"]]]`

323 

324 Additional fields to include in server outputs.

325 

326 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

327 

328 - `"item.input_audio_transcription.logprobs"`

329 

330 - `instructions: Optional[str]`

331 

332 The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.

333 

334 Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.

335 

336 - `max_output_tokens: Optional[Union[int, Literal["inf"], null]]`

337 

338 Maximum number of output tokens for a single assistant response,

339 inclusive of tool calls. Provide an integer between 1 and 4096 to

340 limit output tokens, or `inf` for the maximum available tokens for a

341 given model. Defaults to `inf`.

342 

343 - `int`

344 

345 - `Literal["inf"]`

346 

347 - `"inf"`

348 

349 - `model: Optional[Union[str, Literal["gpt-realtime", "gpt-realtime-1.5", "gpt-realtime-2", 14 more], null]]`

350 

351 The Realtime model used for this session.

352 

353 - `str`

354 

355 - `Literal["gpt-realtime", "gpt-realtime-1.5", "gpt-realtime-2", 14 more]`

356 

357 The Realtime model used for this session.

358 

359 - `"gpt-realtime"`

360 

361 - `"gpt-realtime-1.5"`

362 

363 - `"gpt-realtime-2"`

364 

365 - `"gpt-realtime-2025-08-28"`

366 

367 - `"gpt-4o-realtime-preview"`

368 

369 - `"gpt-4o-realtime-preview-2024-10-01"`

370 

371 - `"gpt-4o-realtime-preview-2024-12-17"`

372 

373 - `"gpt-4o-realtime-preview-2025-06-03"`

374 

375 - `"gpt-4o-mini-realtime-preview"`

376 

377 - `"gpt-4o-mini-realtime-preview-2024-12-17"`

378 

379 - `"gpt-realtime-mini"`

380 

381 - `"gpt-realtime-mini-2025-10-06"`

382 

383 - `"gpt-realtime-mini-2025-12-15"`

384 

385 - `"gpt-audio-1.5"`

386 

387 - `"gpt-audio-mini"`

388 

389 - `"gpt-audio-mini-2025-10-06"`

390 

391 - `"gpt-audio-mini-2025-12-15"`

392 

393 - `output_modalities: Optional[List[Literal["text", "audio"]]]`

394 

395 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating

396 that the model will respond with audio plus a transcript. `["text"]` can be used to make

397 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.

398 

399 - `"text"`

400 

401 - `"audio"`

402 

403 - `parallel_tool_calls: Optional[bool]`

404 

405 Whether the model may call multiple tools in parallel. Only supported by

406 reasoning Realtime models such as `gpt-realtime-2`.

407 

408 - `prompt: Optional[ResponsePrompt]`

409 

410 Reference to a prompt template and its variables.

411 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).

412 

413 - `id: str`

414 

415 The unique identifier of the prompt template to use.

416 

417 - `variables: Optional[Dict[str, Variables]]`

418 

419 Optional map of values to substitute in for variables in your

420 prompt. The substitution values can either be strings, or other

421 Response input types like images or files.

422 

423 - `str`

424 

425 - `class ResponseInputText: …`

426 

427 A text input to the model.

428 

429 - `text: str`

430 

431 The text input to the model.

432 

433 - `type: Literal["input_text"]`

434 

435 The type of the input item. Always `input_text`.

436 

437 - `"input_text"`

438 

439 - `class ResponseInputImage: …`

440 

441 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).

442 

443 - `detail: Literal["low", "high", "auto", "original"]`

444 

445 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.

446 

447 - `"low"`

448 

449 - `"high"`

450 

451 - `"auto"`

452 

453 - `"original"`

454 

455 - `type: Literal["input_image"]`

456 

457 The type of the input item. Always `input_image`.

458 

459 - `"input_image"`

460 

461 - `file_id: Optional[str]`

462 

463 The ID of the file to be sent to the model.

464 

465 - `image_url: Optional[str]`

466 

467 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.

468 

469 - `class ResponseInputFile: …`

470 

471 A file input to the model.

472 

473 - `type: Literal["input_file"]`

474 

475 The type of the input item. Always `input_file`.

476 

477 - `"input_file"`

478 

479 - `detail: Optional[Literal["low", "high"]]`

480 

481 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.

482 

483 - `"low"`

484 

485 - `"high"`

486 

487 - `file_data: Optional[str]`

488 

489 The content of the file to be sent to the model.

490 

491 - `file_id: Optional[str]`

492 

493 The ID of the file to be sent to the model.

494 

495 - `file_url: Optional[str]`

496 

497 The URL of the file to be sent to the model.

498 

499 - `filename: Optional[str]`

500 

501 The name of the file to be sent to the model.

502 

503 - `version: Optional[str]`

504 

505 Optional version of the prompt template.

506 

507 - `reasoning: Optional[RealtimeReasoning]`

508 

509 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.

510 

511 - `effort: Optional[RealtimeReasoningEffort]`

512 

513 Constrains effort on reasoning for reasoning-capable Realtime models such as

514 `gpt-realtime-2`.

515 

516 - `"minimal"`

517 

518 - `"low"`

519 

520 - `"medium"`

521 

522 - `"high"`

523 

524 - `"xhigh"`

525 

526 - `tool_choice: Optional[RealtimeToolChoiceConfig]`

527 

528 How the model chooses tools. Provide one of the string modes or force a specific

529 function/MCP tool.

530 

531 - `Literal["none", "auto", "required"]`

532 

533 - `"none"`

534 

535 - `"auto"`

536 

537 - `"required"`

538 

539 - `class ToolChoiceFunction: …`

540 

541 Use this option to force the model to call a specific function.

542 

543 - `name: str`

544 

545 The name of the function to call.

546 

547 - `type: Literal["function"]`

548 

549 For function calling, the type is always `function`.

550 

551 - `"function"`

552 

553 - `class ToolChoiceMcp: …`

554 

555 Use this option to force the model to call a specific tool on a remote MCP server.

556 

557 - `server_label: str`

558 

559 The label of the MCP server to use.

560 

561 - `type: Literal["mcp"]`

562 

563 For MCP tools, the type is always `mcp`.

564 

565 - `"mcp"`

566 

567 - `name: Optional[str]`

568 

569 The name of the tool to call on the server.

570 

571 - `tools: Optional[RealtimeToolsConfig]`

572 

573 Tools available to the model.

574 

575 - `class RealtimeFunctionTool: …`

576 

577 - `description: Optional[str]`

578 

579 The description of the function, including guidance on when and how

580 to call it, and guidance about what to tell the user when calling

581 (if anything).

582 

583 - `name: Optional[str]`

584 

585 The name of the function.

586 

587 - `parameters: Optional[object]`

588 

589 Parameters of the function in JSON Schema.

590 

591 - `type: Optional[Literal["function"]]`

592 

593 The type of the tool, i.e. `function`.

594 

595 - `"function"`

596 

597 - `class Mcp: …`

598 

599 Give the model access to additional tools via remote Model Context Protocol

600 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).

601 

602 - `server_label: str`

603 

604 A label for this MCP server, used to identify it in tool calls.

605 

606 - `type: Literal["mcp"]`

607 

608 The type of the MCP tool. Always `mcp`.

609 

610 - `"mcp"`

611 

612 - `allowed_tools: Optional[McpAllowedTools]`

613 

614 List of allowed tool names or a filter object.

615 

616 - `List[str]`

617 

618 A string array of allowed tool names

619 

620 - `class McpAllowedToolsMcpToolFilter: …`

621 

622 A filter object to specify which tools are allowed.

623 

624 - `read_only: Optional[bool]`

625 

626 Indicates whether or not a tool modifies data or is read-only. If an

627 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

628 it will match this filter.

629 

630 - `tool_names: Optional[List[str]]`

631 

632 List of allowed tool names.

633 

634 - `authorization: Optional[str]`

635 

636 An OAuth access token that can be used with a remote MCP server, either

637 with a custom MCP server URL or a service connector. Your application

638 must handle the OAuth authorization flow and provide the token here.

639 

640 - `connector_id: Optional[Literal["connector_dropbox", "connector_gmail", "connector_googlecalendar", 5 more]]`

641 

642 Identifier for service connectors, like those available in ChatGPT. One of

643 `server_url` or `connector_id` must be provided. Learn more about service

644 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).

645 

646 Currently supported `connector_id` values are:

647 

648 - Dropbox: `connector_dropbox`

649 - Gmail: `connector_gmail`

650 - Google Calendar: `connector_googlecalendar`

651 - Google Drive: `connector_googledrive`

652 - Microsoft Teams: `connector_microsoftteams`

653 - Outlook Calendar: `connector_outlookcalendar`

654 - Outlook Email: `connector_outlookemail`

655 - SharePoint: `connector_sharepoint`

656 

657 - `"connector_dropbox"`

658 

659 - `"connector_gmail"`

660 

661 - `"connector_googlecalendar"`

662 

663 - `"connector_googledrive"`

664 

665 - `"connector_microsoftteams"`

666 

667 - `"connector_outlookcalendar"`

668 

669 - `"connector_outlookemail"`

670 

671 - `"connector_sharepoint"`

672 

673 - `defer_loading: Optional[bool]`

674 

675 Whether this MCP tool is deferred and discovered via tool search.

676 

677 - `headers: Optional[Dict[str, str]]`

678 

679 Optional HTTP headers to send to the MCP server. Use for authentication

680 or other purposes.

681 

682 - `require_approval: Optional[McpRequireApproval]`

683 

684 Specify which of the MCP server's tools require approval.

685 

686 - `class McpRequireApprovalMcpToolApprovalFilter: …`

687 

688 Specify which of the MCP server's tools require approval. Can be

689 `always`, `never`, or a filter object associated with tools

690 that require approval.

691 

692 - `always: Optional[McpRequireApprovalMcpToolApprovalFilterAlways]`

693 

694 A filter object to specify which tools are allowed.

695 

696 - `read_only: Optional[bool]`

697 

698 Indicates whether or not a tool modifies data or is read-only. If an

699 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

700 it will match this filter.

701 

702 - `tool_names: Optional[List[str]]`

703 

704 List of allowed tool names.

705 

706 - `never: Optional[McpRequireApprovalMcpToolApprovalFilterNever]`

707 

708 A filter object to specify which tools are allowed.

709 

710 - `read_only: Optional[bool]`

711 

712 Indicates whether or not a tool modifies data or is read-only. If an

713 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

714 it will match this filter.

715 

716 - `tool_names: Optional[List[str]]`

717 

718 List of allowed tool names.

719 

720 - `Literal["always", "never"]`

721 

722 Specify a single approval policy for all tools. One of `always` or

723 `never`. When set to `always`, all tools will require approval. When

724 set to `never`, all tools will not require approval.

725 

726 - `"always"`

727 

728 - `"never"`

729 

730 - `server_description: Optional[str]`

731 

732 Optional description of the MCP server, used to provide more context.

733 

734 - `server_url: Optional[str]`

735 

736 The URL for the MCP server. One of `server_url` or `connector_id` must be

737 provided.

738 

739 - `tracing: Optional[RealtimeTracingConfig]`

740 

741 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once

742 tracing is enabled for a session, the configuration cannot be modified.

743 

744 `auto` will create a trace for the session with default values for the

745 workflow name, group id, and metadata.

746 

747 - `Literal["auto"]`

748 

749 Enables tracing and sets default values for tracing configuration options. Always `auto`.

750 

751 - `"auto"`

752 

753 - `class TracingConfiguration: …`

754 

755 Granular configuration for tracing.

756 

757 - `group_id: Optional[str]`

758 

759 The group id to attach to this trace to enable filtering and

760 grouping in the Traces Dashboard.

761 

762 - `metadata: Optional[object]`

763 

764 The arbitrary metadata to attach to this trace to enable

765 filtering in the Traces Dashboard.

766 

767 - `workflow_name: Optional[str]`

768 

769 The name of the workflow to attach to this trace. This is used to

770 name the trace in the Traces Dashboard.

771 

772 - `truncation: Optional[RealtimeTruncation]`

773 

774 When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

775 

776 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

777 

778 Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

779 

780 Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.

781 

782 - `Literal["auto", "disabled"]`

783 

784 The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit.

785 

786 - `"auto"`

787 

788 - `"disabled"`

789 

790 - `class RealtimeTruncationRetentionRatio: …`

791 

792 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

793 

794 - `retention_ratio: float`

795 

796 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.

797 

798 - `type: Literal["retention_ratio"]`

799 

800 Use retention ratio truncation.

801 

802 - `"retention_ratio"`

803 

804 - `token_limits: Optional[TokenLimits]`

805 

806 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.

807 

808 - `post_instructions: Optional[int]`

809 

810 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.

811 

812 - `class RealtimeTranscriptionSessionCreateRequest: …`

813 

814 Realtime transcription session object configuration.

815 

816 - `type: Literal["transcription"]`

817 

818 The type of session to create. Always `transcription` for transcription sessions.

819 

820 - `"transcription"`

821 

822 - `audio: Optional[RealtimeTranscriptionSessionAudio]`

823 

824 Configuration for input and output audio.

825 

826 - `input: Optional[RealtimeTranscriptionSessionAudioInput]`

827 

828 - `format: Optional[RealtimeAudioFormats]`

829 

830 The PCM audio format. Only a 24kHz sample rate is supported.

831 

832 - `noise_reduction: Optional[NoiseReduction]`

833 

834 Configuration for input audio noise reduction. This can be set to `null` to turn off.

835 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

836 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

837 

838 - `type: Optional[NoiseReductionType]`

839 

840 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

841 

842 - `transcription: Optional[AudioTranscription]`

843 

844 Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.

845 

846 - `turn_detection: Optional[RealtimeTranscriptionSessionAudioInputTurnDetection]`

847 

848 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

849 

850 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

851 

852 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

853 

854 For `gpt-realtime-whisper` transcription sessions, turn detection must be

855 set to `null`; VAD is not supported.

856 

857 - `class ServerVad: …`

858 

859 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.

860 

861 - `type: Literal["server_vad"]`

862 

863 Type of turn detection, `server_vad` to turn on simple Server VAD.

864 

865 - `"server_vad"`

866 

867 - `create_response: Optional[bool]`

868 

869 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

870 

871 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

872 

873 - `idle_timeout_ms: Optional[int]`

874 

875 Optional timeout after which a model response will be triggered automatically. This is

876 useful for situations in which a long pause from the user is unexpected, such as a phone

877 call. The model will effectively prompt the user to continue the conversation based

878 on the current context.

879 

880 The timeout value will be applied after the last model response's audio has finished playing,

881 i.e. it's set to the `response.done` time plus audio playback duration.

882 

883 An `input_audio_buffer.timeout_triggered` event (plus events

884 associated with the Response) will be emitted when the timeout is reached.

885 Idle timeout is currently only supported for `server_vad` mode.

886 

887 - `interrupt_response: Optional[bool]`

888 

889 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

890 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

891 

892 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

893 

894 - `prefix_padding_ms: Optional[int]`

895 

896 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

897 milliseconds). Defaults to 300ms.

898 

899 - `silence_duration_ms: Optional[int]`

900 

901 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

902 to 500ms. With shorter values the model will respond more quickly,

903 but may jump in on short pauses from the user.

904 

905 - `threshold: Optional[float]`

906 

907 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

908 higher threshold will require louder audio to activate the model, and

909 thus might perform better in noisy environments.

910 

911 - `class SemanticVad: …`

912 

913 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.

914 

915 - `type: Literal["semantic_vad"]`

916 

917 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

918 

919 - `"semantic_vad"`

920 

921 - `create_response: Optional[bool]`

922 

923 Whether or not to automatically generate a response when a VAD stop event occurs.

924 

925 - `eagerness: Optional[Literal["low", "medium", "high", "auto"]]`

926 

927 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

928 

929 - `"low"`

930 

931 - `"medium"`

932 

933 - `"high"`

934 

935 - `"auto"`

936 

937 - `interrupt_response: Optional[bool]`

938 

939 Whether or not to automatically interrupt any ongoing response with output to the default

940 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

941 

942 - `include: Optional[List[Literal["item.input_audio_transcription.logprobs"]]]`

943 

944 Additional fields to include in server outputs.

945 

946 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

947 

948 - `"item.input_audio_transcription.logprobs"`

949 

950### Returns

951 

952- `class ClientSecretCreateResponse: …`

953 

954 Response from creating a session and client secret for the Realtime API.

955 

956 - `expires_at: int`

957 

958 Expiration timestamp for the client secret, in seconds since epoch.

959 

960 - `session: Session`

961 

962 The session configuration for either a realtime or transcription session.

963 

964 - `class RealtimeSessionCreateResponse: …`

965 

966 A Realtime session configuration object.

967 

968 - `id: str`

969 

970 Unique identifier for the session that looks like `sess_1234567890abcdef`.

971 

972 - `object: Literal["realtime.session"]`

973 

974 The object type. Always `realtime.session`.

975 

976 - `"realtime.session"`

977 

978 - `type: Literal["realtime"]`

979 

980 The type of session to create. Always `realtime` for the Realtime API.

981 

982 - `"realtime"`

983 

984 - `audio: Optional[Audio]`

985 

986 Configuration for input and output audio.

987 

988 - `input: Optional[AudioInput]`

989 

990 - `format: Optional[RealtimeAudioFormats]`

991 

992 The format of the input audio.

993 

994 - `class AudioPCM: …`

995 

996 The PCM audio format. Only a 24kHz sample rate is supported.

997 

998 - `rate: Optional[Literal[24000]]`

999 

1000 The sample rate of the audio. Always `24000`.

1001 

1002 - `24000`

1003 

1004 - `type: Optional[Literal["audio/pcm"]]`

1005 

1006 The audio format. Always `audio/pcm`.

1007 

1008 - `"audio/pcm"`

1009 

1010 - `class AudioPCMU: …`

1011 

1012 The G.711 μ-law format.

1013 

1014 - `type: Optional[Literal["audio/pcmu"]]`

1015 

1016 The audio format. Always `audio/pcmu`.

1017 

1018 - `"audio/pcmu"`

1019 

1020 - `class AudioPCMA: …`

1021 

1022 The G.711 A-law format.

1023 

1024 - `type: Optional[Literal["audio/pcma"]]`

1025 

1026 The audio format. Always `audio/pcma`.

1027 

1028 - `"audio/pcma"`

1029 

1030 - `noise_reduction: Optional[AudioInputNoiseReduction]`

1031 

1032 Configuration for input audio noise reduction. This can be set to `null` to turn off.

1033 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

1034 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

1035 

1036 - `type: Optional[NoiseReductionType]`

1037 

1038 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

1039 

1040 - `"near_field"`

1041 

1042 - `"far_field"`

1043 

1044 - `transcription: Optional[AudioTranscription]`

1045 

1046 - `delay: Optional[Literal["minimal", "low", "medium", 2 more]]`

1047 

1048 Controls how long the model waits before emitting transcription text.

1049 Higher values can improve transcription accuracy at the cost of latency.

1050 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

1051 

1052 - `"minimal"`

1053 

1054 - `"low"`

1055 

1056 - `"medium"`

1057 

1058 - `"high"`

1059 

1060 - `"xhigh"`

1061 

1062 - `language: Optional[str]`

1063 

1064 The language of the input audio. Supplying the input language in

1065 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

1066 will improve accuracy and latency.

1067 

1068 - `model: Optional[Union[str, Literal["whisper-1", "gpt-4o-mini-transcribe", "gpt-4o-mini-transcribe-2025-12-15", 3 more], null]]`

1069 

1070 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

1071 

1072 - `str`

1073 

1074 - `Literal["whisper-1", "gpt-4o-mini-transcribe", "gpt-4o-mini-transcribe-2025-12-15", 3 more]`

1075 

1076 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

1077 

1078 - `"whisper-1"`

1079 

1080 - `"gpt-4o-mini-transcribe"`

1081 

1082 - `"gpt-4o-mini-transcribe-2025-12-15"`

1083 

1084 - `"gpt-4o-transcribe"`

1085 

1086 - `"gpt-4o-transcribe-diarize"`

1087 

1088 - `"gpt-realtime-whisper"`

1089 

1090 - `prompt: Optional[str]`

1091 

1092 An optional text to guide the model's style or continue a previous audio

1093 segment.

1094 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).

1095 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

1096 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

1097 

1098 - `turn_detection: Optional[AudioInputTurnDetection]`

1099 

1100 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

1101 

1102 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

1103 

1104 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

1105 

1106 For `gpt-realtime-whisper` transcription sessions, turn detection must be

1107 set to `null`; VAD is not supported.

1108 

1109 - `class AudioInputTurnDetectionServerVad: …`

1110 

1111 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.

1112 

1113 - `type: Literal["server_vad"]`

1114 

1115 Type of turn detection, `server_vad` to turn on simple Server VAD.

1116 

1117 - `"server_vad"`

1118 

1119 - `create_response: Optional[bool]`

1120 

1121 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

1122 

1123 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

1124 

1125 - `idle_timeout_ms: Optional[int]`

1126 

1127 Optional timeout after which a model response will be triggered automatically. This is

1128 useful for situations in which a long pause from the user is unexpected, such as a phone

1129 call. The model will effectively prompt the user to continue the conversation based

1130 on the current context.

1131 

1132 The timeout value will be applied after the last model response's audio has finished playing,

1133 i.e. it's set to the `response.done` time plus audio playback duration.

1134 

1135 An `input_audio_buffer.timeout_triggered` event (plus events

1136 associated with the Response) will be emitted when the timeout is reached.

1137 Idle timeout is currently only supported for `server_vad` mode.

1138 

1139 - `interrupt_response: Optional[bool]`

1140 

1141 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

1142 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

1143 

1144 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

1145 

1146 - `prefix_padding_ms: Optional[int]`

1147 

1148 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

1149 milliseconds). Defaults to 300ms.

1150 

1151 - `silence_duration_ms: Optional[int]`

1152 

1153 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

1154 to 500ms. With shorter values the model will respond more quickly,

1155 but may jump in on short pauses from the user.

1156 

1157 - `threshold: Optional[float]`

1158 

1159 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

1160 higher threshold will require louder audio to activate the model, and

1161 thus might perform better in noisy environments.

1162 

1163 - `class AudioInputTurnDetectionSemanticVad: …`

1164 

1165 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.

1166 

1167 - `type: Literal["semantic_vad"]`

1168 

1169 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

1170 

1171 - `"semantic_vad"`

1172 

1173 - `create_response: Optional[bool]`

1174 

1175 Whether or not to automatically generate a response when a VAD stop event occurs.

1176 

1177 - `eagerness: Optional[Literal["low", "medium", "high", "auto"]]`

1178 

1179 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

1180 

1181 - `"low"`

1182 

1183 - `"medium"`

1184 

1185 - `"high"`

1186 

1187 - `"auto"`

1188 

1189 - `interrupt_response: Optional[bool]`

1190 

1191 Whether or not to automatically interrupt any ongoing response with output to the default

1192 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

1193 

1194 - `output: Optional[AudioOutput]`

1195 

1196 - `format: Optional[RealtimeAudioFormats]`

1197 

1198 The format of the output audio.

1199 

1200 - `speed: Optional[float]`

1201 

1202 The speed of the model's spoken response as a multiple of the original speed.

1203 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.

1204 

1205 This parameter is a post-processing adjustment to the audio after it is generated, it's

1206 also possible to prompt the model to speak faster or slower.

1207 

1208 - `voice: Optional[Union[str, Literal["alloy", "ash", "ballad", 7 more], null]]`

1209 

1210 The voice the model uses to respond. Voice cannot be changed during the

1211 session once the model has responded with audio at least once. Current

1212 voice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,

1213 `shimmer`, `verse`, `marin`, and `cedar`. We recommend `marin` and `cedar` for

1214 best quality.

1215 

1216 - `str`

1217 

1218 - `Literal["alloy", "ash", "ballad", 7 more]`

1219 

1220 The voice the model uses to respond. Voice cannot be changed during the

1221 session once the model has responded with audio at least once. Current

1222 voice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,

1223 `shimmer`, `verse`, `marin`, and `cedar`. We recommend `marin` and `cedar` for

1224 best quality.

1225 

1226 - `"alloy"`

1227 

1228 - `"ash"`

1229 

1230 - `"ballad"`

1231 

1232 - `"coral"`

1233 

1234 - `"echo"`

1235 

1236 - `"sage"`

1237 

1238 - `"shimmer"`

1239 

1240 - `"verse"`

1241 

1242 - `"marin"`

1243 

1244 - `"cedar"`

1245 

1246 - `expires_at: Optional[int]`

1247 

1248 Expiration timestamp for the session, in seconds since epoch.

1249 

1250 - `include: Optional[List[Literal["item.input_audio_transcription.logprobs"]]]`

1251 

1252 Additional fields to include in server outputs.

1253 

1254 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

1255 

1256 - `"item.input_audio_transcription.logprobs"`

1257 

1258 - `instructions: Optional[str]`

1259 

1260 The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.

1261 

1262 Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.

1263 

1264 - `max_output_tokens: Optional[Union[int, Literal["inf"], null]]`

1265 

1266 Maximum number of output tokens for a single assistant response,

1267 inclusive of tool calls. Provide an integer between 1 and 4096 to

1268 limit output tokens, or `inf` for the maximum available tokens for a

1269 given model. Defaults to `inf`.

1270 

1271 - `int`

1272 

1273 - `Literal["inf"]`

1274 

1275 - `"inf"`

1276 

1277 - `model: Optional[Union[str, Literal["gpt-realtime", "gpt-realtime-1.5", "gpt-realtime-2", 14 more], null]]`

1278 

1279 The Realtime model used for this session.

1280 

1281 - `str`

1282 

1283 - `Literal["gpt-realtime", "gpt-realtime-1.5", "gpt-realtime-2", 14 more]`

1284 

1285 The Realtime model used for this session.

1286 

1287 - `"gpt-realtime"`

1288 

1289 - `"gpt-realtime-1.5"`

1290 

1291 - `"gpt-realtime-2"`

1292 

1293 - `"gpt-realtime-2025-08-28"`

1294 

1295 - `"gpt-4o-realtime-preview"`

1296 

1297 - `"gpt-4o-realtime-preview-2024-10-01"`

1298 

1299 - `"gpt-4o-realtime-preview-2024-12-17"`

1300 

1301 - `"gpt-4o-realtime-preview-2025-06-03"`

1302 

1303 - `"gpt-4o-mini-realtime-preview"`

1304 

1305 - `"gpt-4o-mini-realtime-preview-2024-12-17"`

1306 

1307 - `"gpt-realtime-mini"`

1308 

1309 - `"gpt-realtime-mini-2025-10-06"`

1310 

1311 - `"gpt-realtime-mini-2025-12-15"`

1312 

1313 - `"gpt-audio-1.5"`

1314 

1315 - `"gpt-audio-mini"`

1316 

1317 - `"gpt-audio-mini-2025-10-06"`

1318 

1319 - `"gpt-audio-mini-2025-12-15"`

1320 

1321 - `output_modalities: Optional[List[Literal["text", "audio"]]]`

1322 

1323 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating

1324 that the model will respond with audio plus a transcript. `["text"]` can be used to make

1325 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.

1326 

1327 - `"text"`

1328 

1329 - `"audio"`

1330 

1331 - `prompt: Optional[ResponsePrompt]`

1332 

1333 Reference to a prompt template and its variables.

1334 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).

1335 

1336 - `id: str`

1337 

1338 The unique identifier of the prompt template to use.

1339 

1340 - `variables: Optional[Dict[str, Variables]]`

1341 

1342 Optional map of values to substitute in for variables in your

1343 prompt. The substitution values can either be strings, or other

1344 Response input types like images or files.

1345 

1346 - `str`

1347 

1348 - `class ResponseInputText: …`

1349 

1350 A text input to the model.

1351 

1352 - `text: str`

1353 

1354 The text input to the model.

1355 

1356 - `type: Literal["input_text"]`

1357 

1358 The type of the input item. Always `input_text`.

1359 

1360 - `"input_text"`

1361 

1362 - `class ResponseInputImage: …`

1363 

1364 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).

1365 

1366 - `detail: Literal["low", "high", "auto", "original"]`

1367 

1368 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.

1369 

1370 - `"low"`

1371 

1372 - `"high"`

1373 

1374 - `"auto"`

1375 

1376 - `"original"`

1377 

1378 - `type: Literal["input_image"]`

1379 

1380 The type of the input item. Always `input_image`.

1381 

1382 - `"input_image"`

1383 

1384 - `file_id: Optional[str]`

1385 

1386 The ID of the file to be sent to the model.

1387 

1388 - `image_url: Optional[str]`

1389 

1390 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.

1391 

1392 - `class ResponseInputFile: …`

1393 

1394 A file input to the model.

1395 

1396 - `type: Literal["input_file"]`

1397 

1398 The type of the input item. Always `input_file`.

1399 

1400 - `"input_file"`

1401 

1402 - `detail: Optional[Literal["low", "high"]]`

1403 

1404 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.

1405 

1406 - `"low"`

1407 

1408 - `"high"`

1409 

1410 - `file_data: Optional[str]`

1411 

1412 The content of the file to be sent to the model.

1413 

1414 - `file_id: Optional[str]`

1415 

1416 The ID of the file to be sent to the model.

1417 

1418 - `file_url: Optional[str]`

1419 

1420 The URL of the file to be sent to the model.

1421 

1422 - `filename: Optional[str]`

1423 

1424 The name of the file to be sent to the model.

1425 

1426 - `version: Optional[str]`

1427 

1428 Optional version of the prompt template.

1429 

1430 - `reasoning: Optional[RealtimeReasoning]`

1431 

1432 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.

1433 

1434 - `effort: Optional[RealtimeReasoningEffort]`

1435 

1436 Constrains effort on reasoning for reasoning-capable Realtime models such as

1437 `gpt-realtime-2`.

1438 

1439 - `"minimal"`

1440 

1441 - `"low"`

1442 

1443 - `"medium"`

1444 

1445 - `"high"`

1446 

1447 - `"xhigh"`

1448 

1449 - `tool_choice: Optional[ToolChoice]`

1450 

1451 How the model chooses tools. Provide one of the string modes or force a specific

1452 function/MCP tool.

1453 

1454 - `Literal["none", "auto", "required"]`

1455 

1456 - `"none"`

1457 

1458 - `"auto"`

1459 

1460 - `"required"`

1461 

1462 - `class ToolChoiceFunction: …`

1463 

1464 Use this option to force the model to call a specific function.

1465 

1466 - `name: str`

1467 

1468 The name of the function to call.

1469 

1470 - `type: Literal["function"]`

1471 

1472 For function calling, the type is always `function`.

1473 

1474 - `"function"`

1475 

1476 - `class ToolChoiceMcp: …`

1477 

1478 Use this option to force the model to call a specific tool on a remote MCP server.

1479 

1480 - `server_label: str`

1481 

1482 The label of the MCP server to use.

1483 

1484 - `type: Literal["mcp"]`

1485 

1486 For MCP tools, the type is always `mcp`.

1487 

1488 - `"mcp"`

1489 

1490 - `name: Optional[str]`

1491 

1492 The name of the tool to call on the server.

1493 

1494 - `tools: Optional[List[Tool]]`

1495 

1496 Tools available to the model.

1497 

1498 - `class RealtimeFunctionTool: …`

1499 

1500 - `description: Optional[str]`

1501 

1502 The description of the function, including guidance on when and how

1503 to call it, and guidance about what to tell the user when calling

1504 (if anything).

1505 

1506 - `name: Optional[str]`

1507 

1508 The name of the function.

1509 

1510 - `parameters: Optional[object]`

1511 

1512 Parameters of the function in JSON Schema.

1513 

1514 - `type: Optional[Literal["function"]]`

1515 

1516 The type of the tool, i.e. `function`.

1517 

1518 - `"function"`

1519 

1520 - `class ToolMcpTool: …`

1521 

1522 Give the model access to additional tools via remote Model Context Protocol

1523 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).

1524 

1525 - `server_label: str`

1526 

1527 A label for this MCP server, used to identify it in tool calls.

1528 

1529 - `type: Literal["mcp"]`

1530 

1531 The type of the MCP tool. Always `mcp`.

1532 

1533 - `"mcp"`

1534 

1535 - `allowed_tools: Optional[ToolMcpToolAllowedTools]`

1536 

1537 List of allowed tool names or a filter object.

1538 

1539 - `List[str]`

1540 

1541 A string array of allowed tool names

1542 

1543 - `class ToolMcpToolAllowedToolsMcpToolFilter: …`

1544 

1545 A filter object to specify which tools are allowed.

1546 

1547 - `read_only: Optional[bool]`

1548 

1549 Indicates whether or not a tool modifies data or is read-only. If an

1550 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1551 it will match this filter.

1552 

1553 - `tool_names: Optional[List[str]]`

1554 

1555 List of allowed tool names.

1556 

1557 - `authorization: Optional[str]`

1558 

1559 An OAuth access token that can be used with a remote MCP server, either

1560 with a custom MCP server URL or a service connector. Your application

1561 must handle the OAuth authorization flow and provide the token here.

1562 

1563 - `connector_id: Optional[Literal["connector_dropbox", "connector_gmail", "connector_googlecalendar", 5 more]]`

1564 

1565 Identifier for service connectors, like those available in ChatGPT. One of

1566 `server_url` or `connector_id` must be provided. Learn more about service

1567 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).

1568 

1569 Currently supported `connector_id` values are:

1570 

1571 - Dropbox: `connector_dropbox`

1572 - Gmail: `connector_gmail`

1573 - Google Calendar: `connector_googlecalendar`

1574 - Google Drive: `connector_googledrive`

1575 - Microsoft Teams: `connector_microsoftteams`

1576 - Outlook Calendar: `connector_outlookcalendar`

1577 - Outlook Email: `connector_outlookemail`

1578 - SharePoint: `connector_sharepoint`

1579 

1580 - `"connector_dropbox"`

1581 

1582 - `"connector_gmail"`

1583 

1584 - `"connector_googlecalendar"`

1585 

1586 - `"connector_googledrive"`

1587 

1588 - `"connector_microsoftteams"`

1589 

1590 - `"connector_outlookcalendar"`

1591 

1592 - `"connector_outlookemail"`

1593 

1594 - `"connector_sharepoint"`

1595 

1596 - `defer_loading: Optional[bool]`

1597 

1598 Whether this MCP tool is deferred and discovered via tool search.

1599 

1600 - `headers: Optional[Dict[str, str]]`

1601 

1602 Optional HTTP headers to send to the MCP server. Use for authentication

1603 or other purposes.

1604 

1605 - `require_approval: Optional[ToolMcpToolRequireApproval]`

1606 

1607 Specify which of the MCP server's tools require approval.

1608 

1609 - `class ToolMcpToolRequireApprovalMcpToolApprovalFilter: …`

1610 

1611 Specify which of the MCP server's tools require approval. Can be

1612 `always`, `never`, or a filter object associated with tools

1613 that require approval.

1614 

1615 - `always: Optional[ToolMcpToolRequireApprovalMcpToolApprovalFilterAlways]`

1616 

1617 A filter object to specify which tools are allowed.

1618 

1619 - `read_only: Optional[bool]`

1620 

1621 Indicates whether or not a tool modifies data or is read-only. If an

1622 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1623 it will match this filter.

1624 

1625 - `tool_names: Optional[List[str]]`

1626 

1627 List of allowed tool names.

1628 

1629 - `never: Optional[ToolMcpToolRequireApprovalMcpToolApprovalFilterNever]`

1630 

1631 A filter object to specify which tools are allowed.

1632 

1633 - `read_only: Optional[bool]`

1634 

1635 Indicates whether or not a tool modifies data or is read-only. If an

1636 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1637 it will match this filter.

1638 

1639 - `tool_names: Optional[List[str]]`

1640 

1641 List of allowed tool names.

1642 

1643 - `Literal["always", "never"]`

1644 

1645 Specify a single approval policy for all tools. One of `always` or

1646 `never`. When set to `always`, all tools will require approval. When

1647 set to `never`, all tools will not require approval.

1648 

1649 - `"always"`

1650 

1651 - `"never"`

1652 

1653 - `server_description: Optional[str]`

1654 

1655 Optional description of the MCP server, used to provide more context.

1656 

1657 - `server_url: Optional[str]`

1658 

1659 The URL for the MCP server. One of `server_url` or `connector_id` must be

1660 provided.

1661 

1662 - `tracing: Optional[Tracing]`

1663 

1664 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once

1665 tracing is enabled for a session, the configuration cannot be modified.

1666 

1667 `auto` will create a trace for the session with default values for the

1668 workflow name, group id, and metadata.

1669 

1670 - `Literal["auto"]`

1671 

1672 Enables tracing and sets default values for tracing configuration options. Always `auto`.

1673 

1674 - `"auto"`

1675 

1676 - `class TracingTracingConfiguration: …`

1677 

1678 Granular configuration for tracing.

1679 

1680 - `group_id: Optional[str]`

1681 

1682 The group id to attach to this trace to enable filtering and

1683 grouping in the Traces Dashboard.

1684 

1685 - `metadata: Optional[object]`

1686 

1687 The arbitrary metadata to attach to this trace to enable

1688 filtering in the Traces Dashboard.

1689 

1690 - `workflow_name: Optional[str]`

1691 

1692 The name of the workflow to attach to this trace. This is used to

1693 name the trace in the Traces Dashboard.

1694 

1695 - `truncation: Optional[RealtimeTruncation]`

1696 

1697 When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

1698 

1699 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

1700 

1701 Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

1702 

1703 Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.

1704 

1705 - `Literal["auto", "disabled"]`

1706 

1707 The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit.

1708 

1709 - `"auto"`

1710 

1711 - `"disabled"`

1712 

1713 - `class RealtimeTruncationRetentionRatio: …`

1714 

1715 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

1716 

1717 - `retention_ratio: float`

1718 

1719 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.

1720 

1721 - `type: Literal["retention_ratio"]`

1722 

1723 Use retention ratio truncation.

1724 

1725 - `"retention_ratio"`

1726 

1727 - `token_limits: Optional[TokenLimits]`

1728 

1729 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.

1730 

1731 - `post_instructions: Optional[int]`

1732 

1733 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.

1734 

1735 - `class RealtimeTranscriptionSessionCreateResponse: …`

1736 

1737 A Realtime transcription session configuration object.

1738 

1739 - `id: str`

1740 

1741 Unique identifier for the session that looks like `sess_1234567890abcdef`.

1742 

1743 - `object: str`

1744 

1745 The object type. Always `realtime.transcription_session`.

1746 

1747 - `type: Literal["transcription"]`

1748 

1749 The type of session. Always `transcription` for transcription sessions.

1750 

1751 - `"transcription"`

1752 

1753 - `audio: Optional[Audio]`

1754 

1755 Configuration for input audio for the session.

1756 

1757 - `input: Optional[AudioInput]`

1758 

1759 - `format: Optional[RealtimeAudioFormats]`

1760 

1761 The PCM audio format. Only a 24kHz sample rate is supported.

1762 

1763 - `noise_reduction: Optional[AudioInputNoiseReduction]`

1764 

1765 Configuration for input audio noise reduction.

1766 

1767 - `type: Optional[NoiseReductionType]`

1768 

1769 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

1770 

1771 - `transcription: Optional[AudioTranscription]`

1772 

1773 - `turn_detection: Optional[RealtimeTranscriptionSessionTurnDetection]`

1774 

1775 Configuration for turn detection. Can be set to `null` to turn off. Server

1776 VAD means that the model will detect the start and end of speech based on

1777 audio volume and respond at the end of user speech. For `gpt-realtime-whisper`, this must be `null`; VAD is not supported.

1778 

1779 - `prefix_padding_ms: Optional[int]`

1780 

1781 Amount of audio to include before the VAD detected speech (in

1782 milliseconds). Defaults to 300ms.

1783 

1784 - `silence_duration_ms: Optional[int]`

1785 

1786 Duration of silence to detect speech stop (in milliseconds). Defaults

1787 to 500ms. With shorter values the model will respond more quickly,

1788 but may jump in on short pauses from the user.

1789 

1790 - `threshold: Optional[float]`

1791 

1792 Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

1793 higher threshold will require louder audio to activate the model, and

1794 thus might perform better in noisy environments.

1795 

1796 - `type: Optional[str]`

1797 

1798 Type of turn detection, only `server_vad` is currently supported.

1799 

1800 - `expires_at: Optional[int]`

1801 

1802 Expiration timestamp for the session, in seconds since epoch.

1803 

1804 - `include: Optional[List[Literal["item.input_audio_transcription.logprobs"]]]`

1805 

1806 Additional fields to include in server outputs.

1807 

1808 - `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

1809 

1810 - `"item.input_audio_transcription.logprobs"`

1811 

1812 - `value: str`

1813 

1814 The generated client secret value.

1815 

1816### Example

1817 

1818```python

1819import os

1820from openai import OpenAI

1821 

1822client = OpenAI(

1823 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted

1824)

1825client_secret = client.realtime.client_secrets.create()

1826print(client_secret.expires_at)

1827```

1828 

1829#### Response

1830 

1831```json

1832{

1833 "expires_at": 0,

1834 "session": {

1835 "id": "id",

1836 "object": "realtime.session",

1837 "type": "realtime",

1838 "audio": {

1839 "input": {

1840 "format": {

1841 "rate": 24000,

1842 "type": "audio/pcm"

1843 },

1844 "noise_reduction": {

1845 "type": "near_field"

1846 },

1847 "transcription": {

1848 "delay": "minimal",

1849 "language": "language",

1850 "model": "whisper-1",

1851 "prompt": "prompt"

1852 },

1853 "turn_detection": {

1854 "type": "server_vad",

1855 "create_response": true,

1856 "idle_timeout_ms": 5000,

1857 "interrupt_response": true,

1858 "prefix_padding_ms": 0,

1859 "silence_duration_ms": 0,

1860 "threshold": 0

1861 }

1862 },

1863 "output": {

1864 "format": {

1865 "rate": 24000,

1866 "type": "audio/pcm"

1867 },

1868 "speed": 0.25,

1869 "voice": "ash"

1870 }

1871 },

1872 "expires_at": 0,

1873 "include": [

1874 "item.input_audio_transcription.logprobs"

1875 ],

1876 "instructions": "instructions",

1877 "max_output_tokens": "inf",

1878 "model": "gpt-realtime",

1879 "output_modalities": [

1880 "text"

1881 ],

1882 "prompt": {

1883 "id": "id",

1884 "variables": {

1885 "foo": "string"

1886 },

1887 "version": "version"

1888 },

1889 "reasoning": {

1890 "effort": "minimal"

1891 },

1892 "tool_choice": "none",

1893 "tools": [

1894 {

1895 "description": "description",

1896 "name": "name",

1897 "parameters": {},

1898 "type": "function"

1899 }

1900 ],

1901 "tracing": "auto",

1902 "truncation": "auto"

1903 },

1904 "value": "value"

1905}

1906```

Details

1## Create video

2 

3`videos.create(VideoCreateParams**kwargs) -> Video`

4 

5**post** `/videos`

6 

7Create a new video generation job from a prompt and optional reference assets.

8 

9### Parameters

10 

11- `prompt: str`

12 

13 Text prompt that describes the video to generate.

14 

15- `input_reference: Optional[InputReference]`

16 

17 Optional reference asset upload or reference object that guides generation.

18 

19 - `FileTypes`

20 

21 Optional reference asset upload or reference object that guides generation.

22 

23 - `class ImageInputReferenceParam: …`

24 

25 - `file_id: Optional[str]`

26 

27 - `image_url: Optional[str]`

28 

29 A fully qualified URL or base64-encoded data URL.

30 

31- `model: Optional[VideoModelParam]`

32 

33 The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to `sora-2`.

34 

35 - `str`

36 

37 - `Literal["sora-2", "sora-2-pro", "sora-2-2025-10-06", 2 more]`

38 

39 - `"sora-2"`

40 

41 - `"sora-2-pro"`

42 

43 - `"sora-2-2025-10-06"`

44 

45 - `"sora-2-pro-2025-10-06"`

46 

47 - `"sora-2-2025-12-08"`

48 

49- `seconds: Optional[VideoSeconds]`

50 

51 Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds.

52 

53 - `"4"`

54 

55 - `"8"`

56 

57 - `"12"`

58 

59- `size: Optional[VideoSize]`

60 

61 Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280.

62 

63 - `"720x1280"`

64 

65 - `"1280x720"`

66 

67 - `"1024x1792"`

68 

69 - `"1792x1024"`

70 

71### Returns

72 

73- `class Video: …`

74 

75 Structured information describing a generated video job.

76 

77 - `id: str`

78 

79 Unique identifier for the video job.

80 

81 - `completed_at: Optional[int]`

82 

83 Unix timestamp (seconds) for when the job completed, if finished.

84 

85 - `created_at: int`

86 

87 Unix timestamp (seconds) for when the job was created.

88 

89 - `error: Optional[VideoCreateError]`

90 

91 Error payload that explains why generation failed, if applicable.

92 

93 - `code: str`

94 

95 A machine-readable error code that was returned.

96 

97 - `message: str`

98 

99 A human-readable description of the error that was returned.

100 

101 - `expires_at: Optional[int]`

102 

103 Unix timestamp (seconds) for when the downloadable assets expire, if set.

104 

105 - `model: VideoModel`

106 

107 The video generation model that produced the job.

108 

109 - `str`

110 

111 - `Literal["sora-2", "sora-2-pro", "sora-2-2025-10-06", 2 more]`

112 

113 - `"sora-2"`

114 

115 - `"sora-2-pro"`

116 

117 - `"sora-2-2025-10-06"`

118 

119 - `"sora-2-pro-2025-10-06"`

120 

121 - `"sora-2-2025-12-08"`

122 

123 - `object: Literal["video"]`

124 

125 The object type, which is always `video`.

126 

127 - `"video"`

128 

129 - `progress: int`

130 

131 Approximate completion percentage for the generation task.

132 

133 - `prompt: Optional[str]`

134 

135 The prompt that was used to generate the video.

136 

137 - `remixed_from_video_id: Optional[str]`

138 

139 Identifier of the source video if this video is a remix.

140 

141 - `seconds: Union[str, VideoSeconds]`

142 

143 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

144 

145 - `str`

146 

147 - `Literal["4", "8", "12"]`

148 

149 - `"4"`

150 

151 - `"8"`

152 

153 - `"12"`

154 

155 - `size: VideoSize`

156 

157 The resolution of the generated video.

158 

159 - `"720x1280"`

160 

161 - `"1280x720"`

162 

163 - `"1024x1792"`

164 

165 - `"1792x1024"`

166 

167 - `status: Literal["queued", "in_progress", "completed", "failed"]`

168 

169 Current lifecycle status of the video job.

170 

171 - `"queued"`

172 

173 - `"in_progress"`

174 

175 - `"completed"`

176 

177 - `"failed"`

178 

179### Example

180 

181```python

182import os

183from openai import OpenAI

184 

185client = OpenAI(

186 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted

187)

188video = client.videos.create(

189 prompt="x",

190)

191print(video.id)

192```

193 

194#### Response

195 

196```json

197{

198 "id": "id",

199 "completed_at": 0,

200 "created_at": 0,

201 "error": {

202 "code": "code",

203 "message": "message"

204 },

205 "expires_at": 0,

206 "model": "sora-2",

207 "object": "video",

208 "progress": 0,

209 "prompt": "prompt",

210 "remixed_from_video_id": "remixed_from_video_id",

211 "seconds": "4",

212 "size": "720x1280",

213 "status": "queued"

214}

215```

216 

217### Example

218 

219```python

220from openai import OpenAI

221 

222client = OpenAI()

223video = client.videos.create(

224 prompt="A calico cat playing a piano on stage",

225)

226print(video.id)

227```

228 

229#### Response

230 

231```json

232{

233 "id": "video_123",

234 "object": "video",

235 "model": "sora-2",

236 "status": "queued",

237 "progress": 0,

238 "created_at": 1712697600,

239 "size": "1024x1792",

240 "seconds": "8",

241 "quality": "standard"

242}

243```

Details

1## Create a new video generation job by editing a source video or existing generated video.

2 

3`videos.edit(VideoEditParams**kwargs) -> Video`

4 

5**post** `/videos/edits`

6 

7Create a new video generation job by editing a source video or existing generated video.

8 

9### Parameters

10 

11- `prompt: str`

12 

13 Text prompt that describes how to edit the source video.

14 

15- `video: Video`

16 

17 Reference to the completed video to edit.

18 

19 - `FileTypes`

20 

21 Reference to the completed video to edit.

22 

23 - `class VideoVideoReferenceInputParam: …`

24 

25 Reference to the completed video.

26 

27 - `id: str`

28 

29 The identifier of the completed video.

30 

31### Returns

32 

33- `class Video: …`

34 

35 Structured information describing a generated video job.

36 

37 - `id: str`

38 

39 Unique identifier for the video job.

40 

41 - `completed_at: Optional[int]`

42 

43 Unix timestamp (seconds) for when the job completed, if finished.

44 

45 - `created_at: int`

46 

47 Unix timestamp (seconds) for when the job was created.

48 

49 - `error: Optional[VideoCreateError]`

50 

51 Error payload that explains why generation failed, if applicable.

52 

53 - `code: str`

54 

55 A machine-readable error code that was returned.

56 

57 - `message: str`

58 

59 A human-readable description of the error that was returned.

60 

61 - `expires_at: Optional[int]`

62 

63 Unix timestamp (seconds) for when the downloadable assets expire, if set.

64 

65 - `model: VideoModel`

66 

67 The video generation model that produced the job.

68 

69 - `str`

70 

71 - `Literal["sora-2", "sora-2-pro", "sora-2-2025-10-06", 2 more]`

72 

73 - `"sora-2"`

74 

75 - `"sora-2-pro"`

76 

77 - `"sora-2-2025-10-06"`

78 

79 - `"sora-2-pro-2025-10-06"`

80 

81 - `"sora-2-2025-12-08"`

82 

83 - `object: Literal["video"]`

84 

85 The object type, which is always `video`.

86 

87 - `"video"`

88 

89 - `progress: int`

90 

91 Approximate completion percentage for the generation task.

92 

93 - `prompt: Optional[str]`

94 

95 The prompt that was used to generate the video.

96 

97 - `remixed_from_video_id: Optional[str]`

98 

99 Identifier of the source video if this video is a remix.

100 

101 - `seconds: Union[str, VideoSeconds]`

102 

103 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

104 

105 - `str`

106 

107 - `Literal["4", "8", "12"]`

108 

109 - `"4"`

110 

111 - `"8"`

112 

113 - `"12"`

114 

115 - `size: VideoSize`

116 

117 The resolution of the generated video.

118 

119 - `"720x1280"`

120 

121 - `"1280x720"`

122 

123 - `"1024x1792"`

124 

125 - `"1792x1024"`

126 

127 - `status: Literal["queued", "in_progress", "completed", "failed"]`

128 

129 Current lifecycle status of the video job.

130 

131 - `"queued"`

132 

133 - `"in_progress"`

134 

135 - `"completed"`

136 

137 - `"failed"`

138 

139### Example

140 

141```python

142import os

143from openai import OpenAI

144 

145client = OpenAI(

146 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted

147)

148video = client.videos.edit(

149 prompt="x",

150 video=b"Example data",

151)

152print(video.id)

153```

154 

155#### Response

156 

157```json

158{

159 "id": "id",

160 "completed_at": 0,

161 "created_at": 0,

162 "error": {

163 "code": "code",

164 "message": "message"

165 },

166 "expires_at": 0,

167 "model": "sora-2",

168 "object": "video",

169 "progress": 0,

170 "prompt": "prompt",

171 "remixed_from_video_id": "remixed_from_video_id",

172 "seconds": "4",

173 "size": "720x1280",

174 "status": "queued"

175}

176```

Details

1## Create an extension of a completed video.

2 

3`videos.extend(VideoExtendParams**kwargs) -> Video`

4 

5**post** `/videos/extensions`

6 

7Create an extension of a completed video.

8 

9### Parameters

10 

11- `prompt: str`

12 

13 Updated text prompt that directs the extension generation.

14 

15- `seconds: VideoSeconds`

16 

17 Length of the newly generated extension segment in seconds (allowed values: 4, 8, 12, 16, 20).

18 

19 - `"4"`

20 

21 - `"8"`

22 

23 - `"12"`

24 

25- `video: Video`

26 

27 Reference to the completed video to extend.

28 

29 - `FileTypes`

30 

31 Reference to the completed video to extend.

32 

33 - `class VideoVideoReferenceInputParam: …`

34 

35 Reference to the completed video.

36 

37 - `id: str`

38 

39 The identifier of the completed video.

40 

41### Returns

42 

43- `class Video: …`

44 

45 Structured information describing a generated video job.

46 

47 - `id: str`

48 

49 Unique identifier for the video job.

50 

51 - `completed_at: Optional[int]`

52 

53 Unix timestamp (seconds) for when the job completed, if finished.

54 

55 - `created_at: int`

56 

57 Unix timestamp (seconds) for when the job was created.

58 

59 - `error: Optional[VideoCreateError]`

60 

61 Error payload that explains why generation failed, if applicable.

62 

63 - `code: str`

64 

65 A machine-readable error code that was returned.

66 

67 - `message: str`

68 

69 A human-readable description of the error that was returned.

70 

71 - `expires_at: Optional[int]`

72 

73 Unix timestamp (seconds) for when the downloadable assets expire, if set.

74 

75 - `model: VideoModel`

76 

77 The video generation model that produced the job.

78 

79 - `str`

80 

81 - `Literal["sora-2", "sora-2-pro", "sora-2-2025-10-06", 2 more]`

82 

83 - `"sora-2"`

84 

85 - `"sora-2-pro"`

86 

87 - `"sora-2-2025-10-06"`

88 

89 - `"sora-2-pro-2025-10-06"`

90 

91 - `"sora-2-2025-12-08"`

92 

93 - `object: Literal["video"]`

94 

95 The object type, which is always `video`.

96 

97 - `"video"`

98 

99 - `progress: int`

100 

101 Approximate completion percentage for the generation task.

102 

103 - `prompt: Optional[str]`

104 

105 The prompt that was used to generate the video.

106 

107 - `remixed_from_video_id: Optional[str]`

108 

109 Identifier of the source video if this video is a remix.

110 

111 - `seconds: Union[str, VideoSeconds]`

112 

113 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

114 

115 - `str`

116 

117 - `Literal["4", "8", "12"]`

118 

119 - `"4"`

120 

121 - `"8"`

122 

123 - `"12"`

124 

125 - `size: VideoSize`

126 

127 The resolution of the generated video.

128 

129 - `"720x1280"`

130 

131 - `"1280x720"`

132 

133 - `"1024x1792"`

134 

135 - `"1792x1024"`

136 

137 - `status: Literal["queued", "in_progress", "completed", "failed"]`

138 

139 Current lifecycle status of the video job.

140 

141 - `"queued"`

142 

143 - `"in_progress"`

144 

145 - `"completed"`

146 

147 - `"failed"`

148 

149### Example

150 

151```python

152import os

153from openai import OpenAI

154 

155client = OpenAI(

156 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted

157)

158video = client.videos.extend(

159 prompt="x",

160 seconds="4",

161 video=b"Example data",

162)

163print(video.id)

164```

165 

166#### Response

167 

168```json

169{

170 "id": "id",

171 "completed_at": 0,

172 "created_at": 0,

173 "error": {

174 "code": "code",

175 "message": "message"

176 },

177 "expires_at": 0,

178 "model": "sora-2",

179 "object": "video",

180 "progress": 0,

181 "prompt": "prompt",

182 "remixed_from_video_id": "remixed_from_video_id",

183 "seconds": "4",

184 "size": "720x1280",

185 "status": "queued"

186}

187```

Details

1## List videos

2 

3`videos.list(VideoListParams**kwargs) -> SyncConversationCursorPage[Video]`

4 

5**get** `/videos`

6 

7List recently generated videos for the current project.

8 

9### Parameters

10 

11- `after: Optional[str]`

12 

13 Identifier for the last item from the previous pagination request

14 

15- `limit: Optional[int]`

16 

17 Number of items to retrieve

18 

19- `order: Optional[Literal["asc", "desc"]]`

20 

21 Sort order of results by timestamp. Use `asc` for ascending order or `desc` for descending order.

22 

23 - `"asc"`

24 

25 - `"desc"`

26 

27### Returns

28 

29- `class Video: …`

30 

31 Structured information describing a generated video job.

32 

33 - `id: str`

34 

35 Unique identifier for the video job.

36 

37 - `completed_at: Optional[int]`

38 

39 Unix timestamp (seconds) for when the job completed, if finished.

40 

41 - `created_at: int`

42 

43 Unix timestamp (seconds) for when the job was created.

44 

45 - `error: Optional[VideoCreateError]`

46 

47 Error payload that explains why generation failed, if applicable.

48 

49 - `code: str`

50 

51 A machine-readable error code that was returned.

52 

53 - `message: str`

54 

55 A human-readable description of the error that was returned.

56 

57 - `expires_at: Optional[int]`

58 

59 Unix timestamp (seconds) for when the downloadable assets expire, if set.

60 

61 - `model: VideoModel`

62 

63 The video generation model that produced the job.

64 

65 - `str`

66 

67 - `Literal["sora-2", "sora-2-pro", "sora-2-2025-10-06", 2 more]`

68 

69 - `"sora-2"`

70 

71 - `"sora-2-pro"`

72 

73 - `"sora-2-2025-10-06"`

74 

75 - `"sora-2-pro-2025-10-06"`

76 

77 - `"sora-2-2025-12-08"`

78 

79 - `object: Literal["video"]`

80 

81 The object type, which is always `video`.

82 

83 - `"video"`

84 

85 - `progress: int`

86 

87 Approximate completion percentage for the generation task.

88 

89 - `prompt: Optional[str]`

90 

91 The prompt that was used to generate the video.

92 

93 - `remixed_from_video_id: Optional[str]`

94 

95 Identifier of the source video if this video is a remix.

96 

97 - `seconds: Union[str, VideoSeconds]`

98 

99 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

100 

101 - `str`

102 

103 - `Literal["4", "8", "12"]`

104 

105 - `"4"`

106 

107 - `"8"`

108 

109 - `"12"`

110 

111 - `size: VideoSize`

112 

113 The resolution of the generated video.

114 

115 - `"720x1280"`

116 

117 - `"1280x720"`

118 

119 - `"1024x1792"`

120 

121 - `"1792x1024"`

122 

123 - `status: Literal["queued", "in_progress", "completed", "failed"]`

124 

125 Current lifecycle status of the video job.

126 

127 - `"queued"`

128 

129 - `"in_progress"`

130 

131 - `"completed"`

132 

133 - `"failed"`

134 

135### Example

136 

137```python

138import os

139from openai import OpenAI

140 

141client = OpenAI(

142 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted

143)

144page = client.videos.list()

145page = page.data[0]

146print(page.id)

147```

148 

149#### Response

150 

151```json

152{

153 "data": [

154 {

155 "id": "id",

156 "completed_at": 0,

157 "created_at": 0,

158 "error": {

159 "code": "code",

160 "message": "message"

161 },

162 "expires_at": 0,

163 "model": "sora-2",

164 "object": "video",

165 "progress": 0,

166 "prompt": "prompt",

167 "remixed_from_video_id": "remixed_from_video_id",

168 "seconds": "4",

169 "size": "720x1280",

170 "status": "queued"

171 }

172 ],

173 "first_id": "first_id",

174 "has_more": true,

175 "last_id": "last_id",

176 "object": "list"

177}

178```

179 

180### Example

181 

182```python

183from openai import OpenAI

184 

185client = OpenAI()

186page = client.videos.list()

187page = page.data[0]

188print(page.id)

189```

190 

191#### Response

192 

193```json

194{

195 "data": [

196 {

197 "id": "video_123",

198 "object": "video",

199 "model": "sora-2",

200 "status": "completed"

201 }

202 ],

203 "object": "list"

204}

205```

Details

1## Remix video

2 

3`videos.remix(strvideo_id, VideoRemixParams**kwargs) -> Video`

4 

5**post** `/videos/{video_id}/remix`

6 

7Create a remix of a completed video using a refreshed prompt.

8 

9### Parameters

10 

11- `video_id: str`

12 

13- `prompt: str`

14 

15 Updated text prompt that directs the remix generation.

16 

17### Returns

18 

19- `class Video: …`

20 

21 Structured information describing a generated video job.

22 

23 - `id: str`

24 

25 Unique identifier for the video job.

26 

27 - `completed_at: Optional[int]`

28 

29 Unix timestamp (seconds) for when the job completed, if finished.

30 

31 - `created_at: int`

32 

33 Unix timestamp (seconds) for when the job was created.

34 

35 - `error: Optional[VideoCreateError]`

36 

37 Error payload that explains why generation failed, if applicable.

38 

39 - `code: str`

40 

41 A machine-readable error code that was returned.

42 

43 - `message: str`

44 

45 A human-readable description of the error that was returned.

46 

47 - `expires_at: Optional[int]`

48 

49 Unix timestamp (seconds) for when the downloadable assets expire, if set.

50 

51 - `model: VideoModel`

52 

53 The video generation model that produced the job.

54 

55 - `str`

56 

57 - `Literal["sora-2", "sora-2-pro", "sora-2-2025-10-06", 2 more]`

58 

59 - `"sora-2"`

60 

61 - `"sora-2-pro"`

62 

63 - `"sora-2-2025-10-06"`

64 

65 - `"sora-2-pro-2025-10-06"`

66 

67 - `"sora-2-2025-12-08"`

68 

69 - `object: Literal["video"]`

70 

71 The object type, which is always `video`.

72 

73 - `"video"`

74 

75 - `progress: int`

76 

77 Approximate completion percentage for the generation task.

78 

79 - `prompt: Optional[str]`

80 

81 The prompt that was used to generate the video.

82 

83 - `remixed_from_video_id: Optional[str]`

84 

85 Identifier of the source video if this video is a remix.

86 

87 - `seconds: Union[str, VideoSeconds]`

88 

89 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

90 

91 - `str`

92 

93 - `Literal["4", "8", "12"]`

94 

95 - `"4"`

96 

97 - `"8"`

98 

99 - `"12"`

100 

101 - `size: VideoSize`

102 

103 The resolution of the generated video.

104 

105 - `"720x1280"`

106 

107 - `"1280x720"`

108 

109 - `"1024x1792"`

110 

111 - `"1792x1024"`

112 

113 - `status: Literal["queued", "in_progress", "completed", "failed"]`

114 

115 Current lifecycle status of the video job.

116 

117 - `"queued"`

118 

119 - `"in_progress"`

120 

121 - `"completed"`

122 

123 - `"failed"`

124 

125### Example

126 

127```python

128import os

129from openai import OpenAI

130 

131client = OpenAI(

132 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted

133)

134video = client.videos.remix(

135 video_id="video_123",

136 prompt="x",

137)

138print(video.id)

139```

140 

141#### Response

142 

143```json

144{

145 "id": "id",

146 "completed_at": 0,

147 "created_at": 0,

148 "error": {

149 "code": "code",

150 "message": "message"

151 },

152 "expires_at": 0,

153 "model": "sora-2",

154 "object": "video",

155 "progress": 0,

156 "prompt": "prompt",

157 "remixed_from_video_id": "remixed_from_video_id",

158 "seconds": "4",

159 "size": "720x1280",

160 "status": "queued"

161}

162```

163 

164### Example

165 

166```python

167from openai import OpenAI

168 

169client = OpenAI()

170video = client.videos.remix(

171 video_id="video_123",

172 prompt="Extend the scene with the cat taking a bow to the cheering audience",

173)

174print(video.id)

175```

176 

177#### Response

178 

179```json

180{

181 "id": "video_456",

182 "object": "video",

183 "model": "sora-2",

184 "status": "queued",

185 "progress": 0,

186 "created_at": 1712698600,

187 "size": "720x1280",

188 "seconds": "8",

189 "remixed_from_video_id": "video_123"

190}

191```

Details

1## Retrieve video

2 

3`videos.retrieve(strvideo_id) -> Video`

4 

5**get** `/videos/{video_id}`

6 

7Fetch the latest metadata for a generated video.

8 

9### Parameters

10 

11- `video_id: str`

12 

13### Returns

14 

15- `class Video: …`

16 

17 Structured information describing a generated video job.

18 

19 - `id: str`

20 

21 Unique identifier for the video job.

22 

23 - `completed_at: Optional[int]`

24 

25 Unix timestamp (seconds) for when the job completed, if finished.

26 

27 - `created_at: int`

28 

29 Unix timestamp (seconds) for when the job was created.

30 

31 - `error: Optional[VideoCreateError]`

32 

33 Error payload that explains why generation failed, if applicable.

34 

35 - `code: str`

36 

37 A machine-readable error code that was returned.

38 

39 - `message: str`

40 

41 A human-readable description of the error that was returned.

42 

43 - `expires_at: Optional[int]`

44 

45 Unix timestamp (seconds) for when the downloadable assets expire, if set.

46 

47 - `model: VideoModel`

48 

49 The video generation model that produced the job.

50 

51 - `str`

52 

53 - `Literal["sora-2", "sora-2-pro", "sora-2-2025-10-06", 2 more]`

54 

55 - `"sora-2"`

56 

57 - `"sora-2-pro"`

58 

59 - `"sora-2-2025-10-06"`

60 

61 - `"sora-2-pro-2025-10-06"`

62 

63 - `"sora-2-2025-12-08"`

64 

65 - `object: Literal["video"]`

66 

67 The object type, which is always `video`.

68 

69 - `"video"`

70 

71 - `progress: int`

72 

73 Approximate completion percentage for the generation task.

74 

75 - `prompt: Optional[str]`

76 

77 The prompt that was used to generate the video.

78 

79 - `remixed_from_video_id: Optional[str]`

80 

81 Identifier of the source video if this video is a remix.

82 

83 - `seconds: Union[str, VideoSeconds]`

84 

85 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

86 

87 - `str`

88 

89 - `Literal["4", "8", "12"]`

90 

91 - `"4"`

92 

93 - `"8"`

94 

95 - `"12"`

96 

97 - `size: VideoSize`

98 

99 The resolution of the generated video.

100 

101 - `"720x1280"`

102 

103 - `"1280x720"`

104 

105 - `"1024x1792"`

106 

107 - `"1792x1024"`

108 

109 - `status: Literal["queued", "in_progress", "completed", "failed"]`

110 

111 Current lifecycle status of the video job.

112 

113 - `"queued"`

114 

115 - `"in_progress"`

116 

117 - `"completed"`

118 

119 - `"failed"`

120 

121### Example

122 

123```python

124import os

125from openai import OpenAI

126 

127client = OpenAI(

128 api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted

129)

130video = client.videos.retrieve(

131 "video_123",

132)

133print(video.id)

134```

135 

136#### Response

137 

138```json

139{

140 "id": "id",

141 "completed_at": 0,

142 "created_at": 0,

143 "error": {

144 "code": "code",

145 "message": "message"

146 },

147 "expires_at": 0,

148 "model": "sora-2",

149 "object": "video",

150 "progress": 0,

151 "prompt": "prompt",

152 "remixed_from_video_id": "remixed_from_video_id",

153 "seconds": "4",

154 "size": "720x1280",

155 "status": "queued"

156}

157```

158 

159### Example

160 

161```python

162from openai import OpenAI

163 

164client = OpenAI()

165video = client.videos.retrieve(

166 "video_123",

167)

168print(video.id)

169```

Details

104 -H "Authorization: Bearer $OPENAI_API_KEY" \104 -H "Authorization: Bearer $OPENAI_API_KEY" \

105 -d '{105 -d '{

106 "input": "input",106 "input": "input",

107 "model": "string",107 "model": "tts-1",

108 "voice": "string"108 "voice": "alloy"

109 }'109 }'

110```110```

111 111 

Details

276 -H 'Content-Type: application/json' \276 -H 'Content-Type: application/json' \

277 -H "Authorization: Bearer $OPENAI_API_KEY" \277 -H "Authorization: Bearer $OPENAI_API_KEY" \

278 -d '{278 -d '{

279 "model": "string",279 "model": "gpt-3.5-turbo-instruct",

280 "prompt": "This is a test.",280 "prompt": "This is a test.",

281 "max_tokens": 16,281 "max_tokens": 16,

282 "n": 1,282 "n": 1,

Details

1866 },1866 },

1867 "transcription": {1867 "transcription": {

1868 "language": "language",1868 "language": "language",

1869 "model": "string",1869 "model": "whisper-1",

1870 "prompt": "prompt"1870 "prompt": "prompt"

1871 },1871 },

1872 "turn_detection": {1872 "turn_detection": {


1893 "item.input_audio_transcription.logprobs"1893 "item.input_audio_transcription.logprobs"

1894 ],1894 ],

1895 "instructions": "instructions",1895 "instructions": "instructions",

1896 "max_output_tokens": 0,1896 "max_output_tokens": "inf",

1897 "model": "string",1897 "model": "gpt-realtime",

1898 "output_modalities": [1898 "output_modalities": [

1899 "text"1899 "text"

1900 ],1900 ],

Details

1## Create session

2 

3**post** `/realtime/sessions`

4 

5Create an ephemeral API token for use in client-side applications with the

6Realtime API. Can be configured with the same session parameters as the

7`session.update` client event.

8 

9It responds with a session object, plus a `client_secret` key which contains

10a usable ephemeral API token that can be used to authenticate browser clients

11for the Realtime API.

12 

13Returns the created Realtime session object, plus an ephemeral key.

14 

15### Body Parameters

16 

17- `client_secret: object { expires_at, value }`

18 

19 Ephemeral key returned by the API.

20 

21 - `expires_at: number`

22 

23 Timestamp for when the token expires. Currently, all tokens expire

24 after one minute.

25 

26 - `value: string`

27 

28 Ephemeral key usable in client environments to authenticate connections

29 to the Realtime API. Use this in client-side environments rather than

30 a standard API token, which should only be used server-side.

31 

32- `input_audio_format: optional string`

33 

34 The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.

35 

36- `input_audio_transcription: optional object { model }`

37 

38 Configuration for input audio transcription, defaults to off and can be

39 set to `null` to turn off once on. Input audio transcription is not native

40 to the model, since the model consumes audio directly. Transcription runs

41 asynchronously and should be treated as rough guidance

42 rather than the representation understood by the model.

43 

44 - `model: optional string`

45 

46 The model to use for transcription.

47 

48- `instructions: optional string`

49 

50 The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.

51 Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.

52 

53- `max_response_output_tokens: optional number or "inf"`

54 

55 Maximum number of output tokens for a single assistant response,

56 inclusive of tool calls. Provide an integer between 1 and 4096 to

57 limit output tokens, or `inf` for the maximum available tokens for a

58 given model. Defaults to `inf`.

59 

60 - `number`

61 

62 - `"inf"`

63 

64 - `"inf"`

65 

66- `modalities: optional array of "text" or "audio"`

67 

68 The set of modalities the model can respond with. To disable audio,

69 set this to ["text"].

70 

71 - `"text"`

72 

73 - `"audio"`

74 

75- `output_audio_format: optional string`

76 

77 The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.

78 

79- `prompt: optional ResponsePrompt`

80 

81 Reference to a prompt template and its variables.

82 [Learn more](/docs/guides/text?api-mode=responses#reusable-prompts).

83 

84 - `id: string`

85 

86 The unique identifier of the prompt template to use.

87 

88 - `variables: optional map[string or ResponseInputText or ResponseInputImage or ResponseInputFile]`

89 

90 Optional map of values to substitute in for variables in your

91 prompt. The substitution values can either be strings, or other

92 Response input types like images or files.

93 

94 - `string`

95 

96 - `ResponseInputText object { text, type }`

97 

98 A text input to the model.

99 

100 - `text: string`

101 

102 The text input to the model.

103 

104 - `type: "input_text"`

105 

106 The type of the input item. Always `input_text`.

107 

108 - `"input_text"`

109 

110 - `ResponseInputImage object { detail, type, file_id, image_url }`

111 

112 An image input to the model. Learn about [image inputs](/docs/guides/vision).

113 

114 - `detail: "low" or "high" or "auto" or "original"`

115 

116 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.

117 

118 - `"low"`

119 

120 - `"high"`

121 

122 - `"auto"`

123 

124 - `"original"`

125 

126 - `type: "input_image"`

127 

128 The type of the input item. Always `input_image`.

129 

130 - `"input_image"`

131 

132 - `file_id: optional string`

133 

134 The ID of the file to be sent to the model.

135 

136 - `image_url: optional string`

137 

138 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.

139 

140 - `ResponseInputFile object { type, detail, file_data, 3 more }`

141 

142 A file input to the model.

143 

144 - `type: "input_file"`

145 

146 The type of the input item. Always `input_file`.

147 

148 - `"input_file"`

149 

150 - `detail: optional "low" or "high"`

151 

152 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.

153 

154 - `"low"`

155 

156 - `"high"`

157 

158 - `file_data: optional string`

159 

160 The content of the file to be sent to the model.

161 

162 - `file_id: optional string`

163 

164 The ID of the file to be sent to the model.

165 

166 - `file_url: optional string`

167 

168 The URL of the file to be sent to the model.

169 

170 - `filename: optional string`

171 

172 The name of the file to be sent to the model.

173 

174 - `version: optional string`

175 

176 Optional version of the prompt template.

177 

178- `speed: optional number`

179 

180 The speed of the model's spoken response. 1.0 is the default speed. 0.25 is

181 the minimum speed. 1.5 is the maximum speed. This value can only be changed

182 in between model turns, not while a response is in progress.

183 

184- `temperature: optional number`

185 

186 Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.

187 

188- `tool_choice: optional string`

189 

190 How the model chooses tools. Options are `auto`, `none`, `required`, or

191 specify a function.

192 

193- `tools: optional array of object { description, name, parameters, type }`

194 

195 Tools (functions) available to the model.

196 

197 - `description: optional string`

198 

199 The description of the function, including guidance on when and how

200 to call it, and guidance about what to tell the user when calling

201 (if anything).

202 

203 - `name: optional string`

204 

205 The name of the function.

206 

207 - `parameters: optional unknown`

208 

209 Parameters of the function in JSON Schema.

210 

211 - `type: optional "function"`

212 

213 The type of the tool, i.e. `function`.

214 

215 - `"function"`

216 

217- `tracing: optional "auto" or object { group_id, metadata, workflow_name }`

218 

219 Configuration options for tracing. Set to null to disable tracing. Once

220 tracing is enabled for a session, the configuration cannot be modified.

221 

222 `auto` will create a trace for the session with default values for the

223 workflow name, group id, and metadata.

224 

225 - `"auto"`

226 

227 Default tracing mode for the session.

228 

229 - `"auto"`

230 

231 - `TracingConfiguration object { group_id, metadata, workflow_name }`

232 

233 Granular configuration for tracing.

234 

235 - `group_id: optional string`

236 

237 The group id to attach to this trace to enable filtering and

238 grouping in the traces dashboard.

239 

240 - `metadata: optional unknown`

241 

242 The arbitrary metadata to attach to this trace to enable

243 filtering in the traces dashboard.

244 

245 - `workflow_name: optional string`

246 

247 The name of the workflow to attach to this trace. This is used to

248 name the trace in the traces dashboard.

249 

250- `truncation: optional RealtimeTruncation`

251 

252 When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

253 

254 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

255 

256 Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

257 

258 Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.

259 

260 - `"auto" or "disabled"`

261 

262 The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit.

263 

264 - `"auto"`

265 

266 - `"disabled"`

267 

268 - `RetentionRatioTruncation object { retention_ratio, type, token_limits }`

269 

270 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

271 

272 - `retention_ratio: number`

273 

274 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.

275 

276 - `type: "retention_ratio"`

277 

278 Use retention ratio truncation.

279 

280 - `"retention_ratio"`

281 

282 - `token_limits: optional object { post_instructions }`

283 

284 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.

285 

286 - `post_instructions: optional number`

287 

288 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.

289 

290- `turn_detection: optional object { prefix_padding_ms, silence_duration_ms, threshold, type }`

291 

292 Configuration for turn detection. Can be set to `null` to turn off. Server

293 VAD means that the model will detect the start and end of speech based on

294 audio volume and respond at the end of user speech.

295 

296 - `prefix_padding_ms: optional number`

297 

298 Amount of audio to include before the VAD detected speech (in

299 milliseconds). Defaults to 300ms.

300 

301 - `silence_duration_ms: optional number`

302 

303 Duration of silence to detect speech stop (in milliseconds). Defaults

304 to 500ms. With shorter values the model will respond more quickly,

305 but may jump in on short pauses from the user.

306 

307 - `threshold: optional number`

308 

309 Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

310 higher threshold will require louder audio to activate the model, and

311 thus might perform better in noisy environments.

312 

313 - `type: optional string`

314 

315 Type of turn detection, only `server_vad` is currently supported.

316 

317- `voice: optional string or "alloy" or "ash" or "ballad" or 7 more or object { id }`

318 

319 The voice the model uses to respond. Supported built-in voices are

320 `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,

321 `marin`, and `cedar`. You may also provide a custom voice object with an

322 `id`, for example `{ "id": "voice_1234" }`. Voice cannot be changed during

323 the session once the model has responded with audio at least once.

324 

325 - `string`

326 

327 - `"alloy" or "ash" or "ballad" or 7 more`

328 

329 - `"alloy"`

330 

331 - `"ash"`

332 

333 - `"ballad"`

334 

335 - `"coral"`

336 

337 - `"echo"`

338 

339 - `"sage"`

340 

341 - `"shimmer"`

342 

343 - `"verse"`

344 

345 - `"marin"`

346 

347 - `"cedar"`

348 

349 - `ID object { id }`

350 

351 Custom voice reference.

352 

353 - `id: string`

354 

355 The custom voice ID, e.g. `voice_1234`.

356 

357### Returns

358 

359- `id: optional string`

360 

361 Unique identifier for the session that looks like `sess_1234567890abcdef`.

362 

363- `audio: optional object { input, output }`

364 

365 Configuration for input and output audio for the session.

366 

367 - `input: optional object { format, noise_reduction, transcription, turn_detection }`

368 

369 - `format: optional RealtimeAudioFormats`

370 

371 The PCM audio format. Only a 24kHz sample rate is supported.

372 

373 - `PCMAudioFormat object { rate, type }`

374 

375 The PCM audio format. Only a 24kHz sample rate is supported.

376 

377 - `rate: optional 24000`

378 

379 The sample rate of the audio. Always `24000`.

380 

381 - `24000`

382 

383 - `type: optional "audio/pcm"`

384 

385 The audio format. Always `audio/pcm`.

386 

387 - `"audio/pcm"`

388 

389 - `PCMUAudioFormat object { type }`

390 

391 The G.711 μ-law format.

392 

393 - `type: optional "audio/pcmu"`

394 

395 The audio format. Always `audio/pcmu`.

396 

397 - `"audio/pcmu"`

398 

399 - `PCMAAudioFormat object { type }`

400 

401 The G.711 A-law format.

402 

403 - `type: optional "audio/pcma"`

404 

405 The audio format. Always `audio/pcma`.

406 

407 - `"audio/pcma"`

408 

409 - `noise_reduction: optional object { type }`

410 

411 Configuration for input audio noise reduction.

412 

413 - `type: optional NoiseReductionType`

414 

415 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

416 

417 - `"near_field"`

418 

419 - `"far_field"`

420 

421 - `transcription: optional object { language, model, prompt }`

422 

423 Configuration for input audio transcription.

424 

425 - `language: optional string`

426 

427 The language of the input audio.

428 

429 - `model: optional string or "whisper-1" or "gpt-4o-mini-transcribe" or "gpt-4o-mini-transcribe-2025-12-15" or 3 more`

430 

431 The model used for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.

432 

433 - `string`

434 

435 - `"whisper-1" or "gpt-4o-mini-transcribe" or "gpt-4o-mini-transcribe-2025-12-15" or 3 more`

436 

437 The model used for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.

438 

439 - `"whisper-1"`

440 

441 - `"gpt-4o-mini-transcribe"`

442 

443 - `"gpt-4o-mini-transcribe-2025-12-15"`

444 

445 - `"gpt-4o-transcribe"`

446 

447 - `"gpt-4o-transcribe-diarize"`

448 

449 - `"gpt-realtime-whisper"`

450 

451 - `prompt: optional string`

452 

453 The prompt configured for input audio transcription, when present.

454 

455 - `turn_detection: optional object { prefix_padding_ms, silence_duration_ms, threshold, type }`

456 

457 Configuration for turn detection.

458 

459 - `prefix_padding_ms: optional number`

460 

461 - `silence_duration_ms: optional number`

462 

463 - `threshold: optional number`

464 

465 - `type: optional string`

466 

467 Type of turn detection, only `server_vad` is currently supported.

468 

469 - `output: optional object { format, speed, voice }`

470 

471 - `format: optional RealtimeAudioFormats`

472 

473 The PCM audio format. Only a 24kHz sample rate is supported.

474 

475 - `speed: optional number`

476 

477 - `voice: optional string or "alloy" or "ash" or "ballad" or 7 more`

478 

479 - `string`

480 

481 - `"alloy" or "ash" or "ballad" or 7 more`

482 

483 - `"alloy"`

484 

485 - `"ash"`

486 

487 - `"ballad"`

488 

489 - `"coral"`

490 

491 - `"echo"`

492 

493 - `"sage"`

494 

495 - `"shimmer"`

496 

497 - `"verse"`

498 

499 - `"marin"`

500 

501 - `"cedar"`

502 

503- `expires_at: optional number`

504 

505 Expiration timestamp for the session, in seconds since epoch.

506 

507- `include: optional array of "item.input_audio_transcription.logprobs"`

508 

509 Additional fields to include in server outputs.

510 

511 - `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

512 

513 - `"item.input_audio_transcription.logprobs"`

514 

515- `instructions: optional string`

516 

517 The default system instructions (i.e. system message) prepended to model

518 calls. This field allows the client to guide the model on desired

519 responses. The model can be instructed on response content and format,

520 (e.g. "be extremely succinct", "act friendly", "here are examples of good

521 responses") and on audio behavior (e.g. "talk quickly", "inject emotion

522 into your voice", "laugh frequently"). The instructions are not guaranteed

523 to be followed by the model, but they provide guidance to the model on the

524 desired behavior.

525 

526 Note that the server sets default instructions which will be used if this

527 field is not set and are visible in the `session.created` event at the

528 start of the session.

529 

530- `max_output_tokens: optional number or "inf"`

531 

532 Maximum number of output tokens for a single assistant response,

533 inclusive of tool calls. Provide an integer between 1 and 4096 to

534 limit output tokens, or `inf` for the maximum available tokens for a

535 given model. Defaults to `inf`.

536 

537 - `number`

538 

539 - `"inf"`

540 

541 - `"inf"`

542 

543- `model: optional string`

544 

545 The Realtime model used for this session.

546 

547- `object: optional string`

548 

549 The object type. Always `realtime.session`.

550 

551- `output_modalities: optional array of "text" or "audio"`

552 

553 The set of modalities the model can respond with. To disable audio,

554 set this to ["text"].

555 

556 - `"text"`

557 

558 - `"audio"`

559 

560- `tool_choice: optional string`

561 

562 How the model chooses tools. Options are `auto`, `none`, `required`, or

563 specify a function.

564 

565- `tools: optional array of RealtimeFunctionTool`

566 

567 Tools (functions) available to the model.

568 

569 - `description: optional string`

570 

571 The description of the function, including guidance on when and how

572 to call it, and guidance about what to tell the user when calling

573 (if anything).

574 

575 - `name: optional string`

576 

577 The name of the function.

578 

579 - `parameters: optional unknown`

580 

581 Parameters of the function in JSON Schema.

582 

583 - `type: optional "function"`

584 

585 The type of the tool, i.e. `function`.

586 

587 - `"function"`

588 

589- `tracing: optional "auto" or object { group_id, metadata, workflow_name }`

590 

591 Configuration options for tracing. Set to null to disable tracing. Once

592 tracing is enabled for a session, the configuration cannot be modified.

593 

594 `auto` will create a trace for the session with default values for the

595 workflow name, group id, and metadata.

596 

597 - `"auto"`

598 

599 Default tracing mode for the session.

600 

601 - `"auto"`

602 

603 - `TracingConfiguration object { group_id, metadata, workflow_name }`

604 

605 Granular configuration for tracing.

606 

607 - `group_id: optional string`

608 

609 The group id to attach to this trace to enable filtering and

610 grouping in the traces dashboard.

611 

612 - `metadata: optional unknown`

613 

614 The arbitrary metadata to attach to this trace to enable

615 filtering in the traces dashboard.

616 

617 - `workflow_name: optional string`

618 

619 The name of the workflow to attach to this trace. This is used to

620 name the trace in the traces dashboard.

621 

622- `turn_detection: optional object { prefix_padding_ms, silence_duration_ms, threshold, type }`

623 

624 Configuration for turn detection. Can be set to `null` to turn off. Server

625 VAD means that the model will detect the start and end of speech based on

626 audio volume and respond at the end of user speech.

627 

628 - `prefix_padding_ms: optional number`

629 

630 Amount of audio to include before the VAD detected speech (in

631 milliseconds). Defaults to 300ms.

632 

633 - `silence_duration_ms: optional number`

634 

635 Duration of silence to detect speech stop (in milliseconds). Defaults

636 to 500ms. With shorter values the model will respond more quickly,

637 but may jump in on short pauses from the user.

638 

639 - `threshold: optional number`

640 

641 Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

642 higher threshold will require louder audio to activate the model, and

643 thus might perform better in noisy environments.

644 

645 - `type: optional string`

646 

647 Type of turn detection, only `server_vad` is currently supported.

648 

649### Example

650 

651```http

652curl https://api.openai.com/v1/realtime/sessions \

653 -H 'Content-Type: application/json' \

654 -H "Authorization: Bearer $OPENAI_API_KEY" \

655 -d '{

656 "client_secret": {

657 "expires_at": 0,

658 "value": "value"

659 }

660 }'

661```

662 

663#### Response

664 

665```json

666{

667 "id": "id",

668 "audio": {

669 "input": {

670 "format": {

671 "rate": 24000,

672 "type": "audio/pcm"

673 },

674 "noise_reduction": {

675 "type": "near_field"

676 },

677 "transcription": {

678 "language": "language",

679 "model": "whisper-1",

680 "prompt": "prompt"

681 },

682 "turn_detection": {

683 "prefix_padding_ms": 0,

684 "silence_duration_ms": 0,

685 "threshold": 0,

686 "type": "type"

687 }

688 },

689 "output": {

690 "format": {

691 "rate": 24000,

692 "type": "audio/pcm"

693 },

694 "speed": 0,

695 "voice": "ash"

696 }

697 },

698 "expires_at": 0,

699 "include": [

700 "item.input_audio_transcription.logprobs"

701 ],

702 "instructions": "instructions",

703 "max_output_tokens": "inf",

704 "model": "model",

705 "object": "object",

706 "output_modalities": [

707 "text"

708 ],

709 "tool_choice": "tool_choice",

710 "tools": [

711 {

712 "description": "description",

713 "name": "name",

714 "parameters": {},

715 "type": "function"

716 }

717 ],

718 "tracing": "auto",

719 "turn_detection": {

720 "prefix_padding_ms": 0,

721 "silence_duration_ms": 0,

722 "threshold": 0,

723 "type": "type"

724 }

725}

726```

727 

728### Example

729 

730```http

731curl -X POST https://api.openai.com/v1/realtime/sessions \

732 -H "Authorization: Bearer $OPENAI_API_KEY" \

733 -H "Content-Type: application/json" \

734 -d '{

735 "model": "gpt-realtime",

736 "modalities": ["audio", "text"],

737 "instructions": "You are a friendly assistant."

738 }'

739```

740 

741#### Response

742 

743```json

744{

745 "id": "sess_001",

746 "object": "realtime.session",

747 "model": "gpt-realtime-2025-08-25",

748 "modalities": ["audio", "text"],

749 "instructions": "You are a friendly assistant.",

750 "voice": "alloy",

751 "input_audio_format": "pcm16",

752 "output_audio_format": "pcm16",

753 "input_audio_transcription": {

754 "model": "whisper-1"

755 },

756 "turn_detection": null,

757 "tools": [],

758 "tool_choice": "none",

759 "temperature": 0.7,

760 "max_response_output_tokens": 200,

761 "speed": 1.1,

762 "tracing": "auto",

763 "client_secret": {

764 "value": "ek_abc123",

765 "expires_at": 1234567890

766 }

767}

768```

Details

1## Create transcription session

2 

3**post** `/realtime/transcription_sessions`

4 

5Create an ephemeral API token for use in client-side applications with the

6Realtime API specifically for realtime transcriptions.

7Can be configured with the same session parameters as the `transcription_session.update` client event.

8 

9It responds with a session object, plus a `client_secret` key which contains

10a usable ephemeral API token that can be used to authenticate browser clients

11for the Realtime API.

12 

13Returns the created Realtime transcription session object, plus an ephemeral key.

14 

15### Body Parameters

16 

17- `include: optional array of "item.input_audio_transcription.logprobs"`

18 

19 The set of items to include in the transcription. Current available items are:

20 `item.input_audio_transcription.logprobs`

21 

22 - `"item.input_audio_transcription.logprobs"`

23 

24- `input_audio_format: optional "pcm16" or "g711_ulaw" or "g711_alaw"`

25 

26 The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.

27 For `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate,

28 single channel (mono), and little-endian byte order.

29 

30 - `"pcm16"`

31 

32 - `"g711_ulaw"`

33 

34 - `"g711_alaw"`

35 

36- `input_audio_noise_reduction: optional object { type }`

37 

38 Configuration for input audio noise reduction. This can be set to `null` to turn off.

39 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

40 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

41 

42 - `type: optional NoiseReductionType`

43 

44 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

45 

46 - `"near_field"`

47 

48 - `"far_field"`

49 

50- `input_audio_transcription: optional AudioTranscription`

51 

52 Configuration for input audio transcription. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.

53 

54 - `delay: optional "minimal" or "low" or "medium" or 2 more`

55 

56 Controls how long the model waits before emitting transcription text.

57 Higher values can improve transcription accuracy at the cost of latency.

58 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

59 

60 - `"minimal"`

61 

62 - `"low"`

63 

64 - `"medium"`

65 

66 - `"high"`

67 

68 - `"xhigh"`

69 

70 - `language: optional string`

71 

72 The language of the input audio. Supplying the input language in

73 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

74 will improve accuracy and latency.

75 

76 - `model: optional string or "whisper-1" or "gpt-4o-mini-transcribe" or "gpt-4o-mini-transcribe-2025-12-15" or 3 more`

77 

78 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

79 

80 - `string`

81 

82 - `"whisper-1" or "gpt-4o-mini-transcribe" or "gpt-4o-mini-transcribe-2025-12-15" or 3 more`

83 

84 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

85 

86 - `"whisper-1"`

87 

88 - `"gpt-4o-mini-transcribe"`

89 

90 - `"gpt-4o-mini-transcribe-2025-12-15"`

91 

92 - `"gpt-4o-transcribe"`

93 

94 - `"gpt-4o-transcribe-diarize"`

95 

96 - `"gpt-realtime-whisper"`

97 

98 - `prompt: optional string`

99 

100 An optional text to guide the model's style or continue a previous audio

101 segment.

102 For `whisper-1`, the [prompt is a list of keywords](/docs/guides/speech-to-text#prompting).

103 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

104 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

105 

106- `turn_detection: optional object { prefix_padding_ms, silence_duration_ms, threshold, type }`

107 

108 Configuration for turn detection. Can be set to `null` to turn off. Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

109 

110 - `prefix_padding_ms: optional number`

111 

112 Amount of audio to include before the VAD detected speech (in

113 milliseconds). Defaults to 300ms.

114 

115 - `silence_duration_ms: optional number`

116 

117 Duration of silence to detect speech stop (in milliseconds). Defaults

118 to 500ms. With shorter values the model will respond more quickly,

119 but may jump in on short pauses from the user.

120 

121 - `threshold: optional number`

122 

123 Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

124 higher threshold will require louder audio to activate the model, and

125 thus might perform better in noisy environments.

126 

127 - `type: optional "server_vad"`

128 

129 Type of turn detection. Only `server_vad` is currently supported for transcription sessions.

130 

131 - `"server_vad"`

132 

133### Returns

134 

135- `client_secret: object { expires_at, value }`

136 

137 Ephemeral key returned by the API. Only present when the session is

138 created on the server via REST API.

139 

140 - `expires_at: number`

141 

142 Timestamp for when the token expires. Currently, all tokens expire

143 after one minute.

144 

145 - `value: string`

146 

147 Ephemeral key usable in client environments to authenticate connections

148 to the Realtime API. Use this in client-side environments rather than

149 a standard API token, which should only be used server-side.

150 

151- `input_audio_format: optional string`

152 

153 The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.

154 

155- `input_audio_transcription: optional object { language, model, prompt }`

156 

157 Configuration of the transcription model.

158 

159 - `language: optional string`

160 

161 The language of the input audio.

162 

163 - `model: optional string or "whisper-1" or "gpt-4o-mini-transcribe" or "gpt-4o-mini-transcribe-2025-12-15" or 3 more`

164 

165 The model used for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.

166 

167 - `string`

168 

169 - `"whisper-1" or "gpt-4o-mini-transcribe" or "gpt-4o-mini-transcribe-2025-12-15" or 3 more`

170 

171 The model used for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.

172 

173 - `"whisper-1"`

174 

175 - `"gpt-4o-mini-transcribe"`

176 

177 - `"gpt-4o-mini-transcribe-2025-12-15"`

178 

179 - `"gpt-4o-transcribe"`

180 

181 - `"gpt-4o-transcribe-diarize"`

182 

183 - `"gpt-realtime-whisper"`

184 

185 - `prompt: optional string`

186 

187 The prompt configured for input audio transcription, when present.

188 

189- `modalities: optional array of "text" or "audio"`

190 

191 The set of modalities the model can respond with. To disable audio,

192 set this to ["text"].

193 

194 - `"text"`

195 

196 - `"audio"`

197 

198- `turn_detection: optional object { prefix_padding_ms, silence_duration_ms, threshold, type }`

199 

200 Configuration for turn detection. Can be set to `null` to turn off. Server

201 VAD means that the model will detect the start and end of speech based on

202 audio volume and respond at the end of user speech.

203 

204 - `prefix_padding_ms: optional number`

205 

206 Amount of audio to include before the VAD detected speech (in

207 milliseconds). Defaults to 300ms.

208 

209 - `silence_duration_ms: optional number`

210 

211 Duration of silence to detect speech stop (in milliseconds). Defaults

212 to 500ms. With shorter values the model will respond more quickly,

213 but may jump in on short pauses from the user.

214 

215 - `threshold: optional number`

216 

217 Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

218 higher threshold will require louder audio to activate the model, and

219 thus might perform better in noisy environments.

220 

221 - `type: optional string`

222 

223 Type of turn detection, only `server_vad` is currently supported.

224 

225### Example

226 

227```http

228curl https://api.openai.com/v1/realtime/transcription_sessions \

229 -H 'Content-Type: application/json' \

230 -H "Authorization: Bearer $OPENAI_API_KEY" \

231 -d '{}'

232```

233 

234#### Response

235 

236```json

237{

238 "client_secret": {

239 "expires_at": 0,

240 "value": "value"

241 },

242 "input_audio_format": "input_audio_format",

243 "input_audio_transcription": {

244 "language": "language",

245 "model": "whisper-1",

246 "prompt": "prompt"

247 },

248 "modalities": [

249 "text"

250 ],

251 "turn_detection": {

252 "prefix_padding_ms": 0,

253 "silence_duration_ms": 0,

254 "threshold": 0,

255 "type": "type"

256 }

257}

258```

259 

260### Example

261 

262```http

263curl -X POST https://api.openai.com/v1/realtime/transcription_sessions \

264 -H "Authorization: Bearer $OPENAI_API_KEY" \

265 -H "Content-Type: application/json" \

266 -d '{}'

267```

268 

269#### Response

270 

271```json

272{

273 "id": "sess_BBwZc7cFV3XizEyKGDCGL",

274 "object": "realtime.transcription_session",

275 "modalities": ["audio", "text"],

276 "turn_detection": {

277 "type": "server_vad",

278 "threshold": 0.5,

279 "prefix_padding_ms": 300,

280 "silence_duration_ms": 200

281 },

282 "input_audio_format": "pcm16",

283 "input_audio_transcription": {

284 "model": "gpt-4o-transcribe",

285 "language": null,

286 "prompt": ""

287 },

288 "client_secret": null

289}

290```

Details

181 "message": "message"181 "message": "message"

182 },182 },

183 "expires_at": 0,183 "expires_at": 0,

184 "model": "string",184 "model": "sora-2",

185 "object": "video",185 "object": "video",

186 "progress": 0,186 "progress": 0,

187 "prompt": "prompt",187 "prompt": "prompt",

Details

1## Create a new video generation job by editing a source video or existing generated video.

2 

3**post** `/videos/edits`

4 

5Create a new video generation job by editing a source video or existing generated video.

6 

7### Body Parameters

8 

9- `prompt: string`

10 

11 Text prompt that describes how to edit the source video.

12 

13- `video: object { id }`

14 

15 Reference to the completed video to edit.

16 

17 - `id: string`

18 

19 The identifier of the completed video.

20 

21### Returns

22 

23- `Video object { id, completed_at, created_at, 10 more }`

24 

25 Structured information describing a generated video job.

26 

27 - `id: string`

28 

29 Unique identifier for the video job.

30 

31 - `completed_at: number`

32 

33 Unix timestamp (seconds) for when the job completed, if finished.

34 

35 - `created_at: number`

36 

37 Unix timestamp (seconds) for when the job was created.

38 

39 - `error: VideoCreateError`

40 

41 Error payload that explains why generation failed, if applicable.

42 

43 - `code: string`

44 

45 A machine-readable error code that was returned.

46 

47 - `message: string`

48 

49 A human-readable description of the error that was returned.

50 

51 - `expires_at: number`

52 

53 Unix timestamp (seconds) for when the downloadable assets expire, if set.

54 

55 - `model: VideoModel`

56 

57 The video generation model that produced the job.

58 

59 - `string`

60 

61 - `"sora-2" or "sora-2-pro" or "sora-2-2025-10-06" or 2 more`

62 

63 - `"sora-2"`

64 

65 - `"sora-2-pro"`

66 

67 - `"sora-2-2025-10-06"`

68 

69 - `"sora-2-pro-2025-10-06"`

70 

71 - `"sora-2-2025-12-08"`

72 

73 - `object: "video"`

74 

75 The object type, which is always `video`.

76 

77 - `"video"`

78 

79 - `progress: number`

80 

81 Approximate completion percentage for the generation task.

82 

83 - `prompt: string`

84 

85 The prompt that was used to generate the video.

86 

87 - `remixed_from_video_id: string`

88 

89 Identifier of the source video if this video is a remix.

90 

91 - `seconds: string`

92 

93 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

94 

95 - `size: VideoSize`

96 

97 The resolution of the generated video.

98 

99 - `"720x1280"`

100 

101 - `"1280x720"`

102 

103 - `"1024x1792"`

104 

105 - `"1792x1024"`

106 

107 - `status: "queued" or "in_progress" or "completed" or "failed"`

108 

109 Current lifecycle status of the video job.

110 

111 - `"queued"`

112 

113 - `"in_progress"`

114 

115 - `"completed"`

116 

117 - `"failed"`

118 

119### Example

120 

121```http

122curl https://api.openai.com/v1/videos/edits \

123 -H 'Content-Type: application/json' \

124 -H "Authorization: Bearer $OPENAI_API_KEY" \

125 -d '{

126 "prompt": "x",

127 "video": {

128 "id": "video_123"

129 }

130 }'

131```

132 

133#### Response

134 

135```json

136{

137 "id": "id",

138 "completed_at": 0,

139 "created_at": 0,

140 "error": {

141 "code": "code",

142 "message": "message"

143 },

144 "expires_at": 0,

145 "model": "sora-2",

146 "object": "video",

147 "progress": 0,

148 "prompt": "prompt",

149 "remixed_from_video_id": "remixed_from_video_id",

150 "seconds": "seconds",

151 "size": "720x1280",

152 "status": "queued"

153}

154```

Details

1## Create an extension of a completed video.

2 

3**post** `/videos/extensions`

4 

5Create an extension of a completed video.

6 

7### Body Parameters

8 

9- `prompt: string`

10 

11 Updated text prompt that directs the extension generation.

12 

13- `seconds: VideoSeconds`

14 

15 Length of the newly generated extension segment in seconds (allowed values: 4, 8, 12, 16, 20).

16 

17 - `"4"`

18 

19 - `"8"`

20 

21 - `"12"`

22 

23- `video: object { id }`

24 

25 Reference to the completed video to extend.

26 

27 - `id: string`

28 

29 The identifier of the completed video.

30 

31### Returns

32 

33- `Video object { id, completed_at, created_at, 10 more }`

34 

35 Structured information describing a generated video job.

36 

37 - `id: string`

38 

39 Unique identifier for the video job.

40 

41 - `completed_at: number`

42 

43 Unix timestamp (seconds) for when the job completed, if finished.

44 

45 - `created_at: number`

46 

47 Unix timestamp (seconds) for when the job was created.

48 

49 - `error: VideoCreateError`

50 

51 Error payload that explains why generation failed, if applicable.

52 

53 - `code: string`

54 

55 A machine-readable error code that was returned.

56 

57 - `message: string`

58 

59 A human-readable description of the error that was returned.

60 

61 - `expires_at: number`

62 

63 Unix timestamp (seconds) for when the downloadable assets expire, if set.

64 

65 - `model: VideoModel`

66 

67 The video generation model that produced the job.

68 

69 - `string`

70 

71 - `"sora-2" or "sora-2-pro" or "sora-2-2025-10-06" or 2 more`

72 

73 - `"sora-2"`

74 

75 - `"sora-2-pro"`

76 

77 - `"sora-2-2025-10-06"`

78 

79 - `"sora-2-pro-2025-10-06"`

80 

81 - `"sora-2-2025-12-08"`

82 

83 - `object: "video"`

84 

85 The object type, which is always `video`.

86 

87 - `"video"`

88 

89 - `progress: number`

90 

91 Approximate completion percentage for the generation task.

92 

93 - `prompt: string`

94 

95 The prompt that was used to generate the video.

96 

97 - `remixed_from_video_id: string`

98 

99 Identifier of the source video if this video is a remix.

100 

101 - `seconds: string`

102 

103 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

104 

105 - `size: VideoSize`

106 

107 The resolution of the generated video.

108 

109 - `"720x1280"`

110 

111 - `"1280x720"`

112 

113 - `"1024x1792"`

114 

115 - `"1792x1024"`

116 

117 - `status: "queued" or "in_progress" or "completed" or "failed"`

118 

119 Current lifecycle status of the video job.

120 

121 - `"queued"`

122 

123 - `"in_progress"`

124 

125 - `"completed"`

126 

127 - `"failed"`

128 

129### Example

130 

131```http

132curl https://api.openai.com/v1/videos/extensions \

133 -H 'Content-Type: application/json' \

134 -H "Authorization: Bearer $OPENAI_API_KEY" \

135 -d '{

136 "prompt": "x",

137 "seconds": "4",

138 "video": {

139 "id": "video_123"

140 }

141 }'

142```

143 

144#### Response

145 

146```json

147{

148 "id": "id",

149 "completed_at": 0,

150 "created_at": 0,

151 "error": {

152 "code": "code",

153 "message": "message"

154 },

155 "expires_at": 0,

156 "model": "sora-2",

157 "object": "video",

158 "progress": 0,

159 "prompt": "prompt",

160 "remixed_from_video_id": "remixed_from_video_id",

161 "seconds": "seconds",

162 "size": "720x1280",

163 "status": "queued"

164}

165```

Details

159 "message": "message"159 "message": "message"

160 },160 },

161 "expires_at": 0,161 "expires_at": 0,

162 "model": "string",162 "model": "sora-2",

163 "object": "video",163 "object": "video",

164 "progress": 0,164 "progress": 0,

165 "prompt": "prompt",165 "prompt": "prompt",

Details

1## Remix video

2 

3**post** `/videos/{video_id}/remix`

4 

5Create a remix of a completed video using a refreshed prompt.

6 

7### Path Parameters

8 

9- `video_id: string`

10 

11### Body Parameters

12 

13- `prompt: string`

14 

15 Updated text prompt that directs the remix generation.

16 

17### Returns

18 

19- `Video object { id, completed_at, created_at, 10 more }`

20 

21 Structured information describing a generated video job.

22 

23 - `id: string`

24 

25 Unique identifier for the video job.

26 

27 - `completed_at: number`

28 

29 Unix timestamp (seconds) for when the job completed, if finished.

30 

31 - `created_at: number`

32 

33 Unix timestamp (seconds) for when the job was created.

34 

35 - `error: VideoCreateError`

36 

37 Error payload that explains why generation failed, if applicable.

38 

39 - `code: string`

40 

41 A machine-readable error code that was returned.

42 

43 - `message: string`

44 

45 A human-readable description of the error that was returned.

46 

47 - `expires_at: number`

48 

49 Unix timestamp (seconds) for when the downloadable assets expire, if set.

50 

51 - `model: VideoModel`

52 

53 The video generation model that produced the job.

54 

55 - `string`

56 

57 - `"sora-2" or "sora-2-pro" or "sora-2-2025-10-06" or 2 more`

58 

59 - `"sora-2"`

60 

61 - `"sora-2-pro"`

62 

63 - `"sora-2-2025-10-06"`

64 

65 - `"sora-2-pro-2025-10-06"`

66 

67 - `"sora-2-2025-12-08"`

68 

69 - `object: "video"`

70 

71 The object type, which is always `video`.

72 

73 - `"video"`

74 

75 - `progress: number`

76 

77 Approximate completion percentage for the generation task.

78 

79 - `prompt: string`

80 

81 The prompt that was used to generate the video.

82 

83 - `remixed_from_video_id: string`

84 

85 Identifier of the source video if this video is a remix.

86 

87 - `seconds: string`

88 

89 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

90 

91 - `size: VideoSize`

92 

93 The resolution of the generated video.

94 

95 - `"720x1280"`

96 

97 - `"1280x720"`

98 

99 - `"1024x1792"`

100 

101 - `"1792x1024"`

102 

103 - `status: "queued" or "in_progress" or "completed" or "failed"`

104 

105 Current lifecycle status of the video job.

106 

107 - `"queued"`

108 

109 - `"in_progress"`

110 

111 - `"completed"`

112 

113 - `"failed"`

114 

115### Example

116 

117```http

118curl https://api.openai.com/v1/videos/$VIDEO_ID/remix \

119 -H 'Content-Type: application/json' \

120 -H "Authorization: Bearer $OPENAI_API_KEY" \

121 -d '{

122 "prompt": "x"

123 }'

124```

125 

126#### Response

127 

128```json

129{

130 "id": "id",

131 "completed_at": 0,

132 "created_at": 0,

133 "error": {

134 "code": "code",

135 "message": "message"

136 },

137 "expires_at": 0,

138 "model": "sora-2",

139 "object": "video",

140 "progress": 0,

141 "prompt": "prompt",

142 "remixed_from_video_id": "remixed_from_video_id",

143 "seconds": "seconds",

144 "size": "720x1280",

145 "status": "queued"

146}

147```

148 

149### Example

150 

151```http

152curl -X POST https://api.openai.com/v1/videos/video_123/remix \

153 -H "Authorization: Bearer $OPENAI_API_KEY" \

154 -H "Content-Type: application/json" \

155 -d '{

156 "prompt": "Extend the scene with the cat taking a bow to the cheering audience"

157 }'

158```

159 

160#### Response

161 

162```json

163{

164 "id": "video_456",

165 "object": "video",

166 "model": "sora-2",

167 "status": "queued",

168 "progress": 0,

169 "created_at": 1712698600,

170 "size": "720x1280",

171 "seconds": "8",

172 "remixed_from_video_id": "video_123"

173}

174```

Details

125 "message": "message"125 "message": "message"

126 },126 },

127 "expires_at": 0,127 "expires_at": 0,

128 "model": "string",128 "model": "sora-2",

129 "object": "video",129 "object": "video",

130 "progress": 0,130 "progress": 0,

131 "prompt": "prompt",131 "prompt": "prompt",

Details

1## Create speech

2 

3`audio.speech.create(**kwargs) -> StringIO`

4 

5**post** `/audio/speech`

6 

7Generates audio from the input text.

8 

9Returns the audio file content, or a stream of audio events.

10 

11### Parameters

12 

13- `input: String`

14 

15 The text to generate audio for. The maximum length is 4096 characters.

16 

17- `model: String | SpeechModel`

18 

19 One of the available [TTS models](https://platform.openai.com/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.

20 

21 - `String = String`

22 

23 - `SpeechModel = :"tts-1" | :"tts-1-hd" | :"gpt-4o-mini-tts" | :"gpt-4o-mini-tts-2025-12-15"`

24 

25 - `:"tts-1"`

26 

27 - `:"tts-1-hd"`

28 

29 - `:"gpt-4o-mini-tts"`

30 

31 - `:"gpt-4o-mini-tts-2025-12-15"`

32 

33- `voice: String | :alloy | :ash | :ballad | 7 more | ID{ id}`

34 

35 The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ "id": "voice_1234" }`. Previews of the voices are available in the [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).

36 

37 - `String = String`

38 

39 - `Voice = :alloy | :ash | :ballad | 7 more`

40 

41 - `:alloy`

42 

43 - `:ash`

44 

45 - `:ballad`

46 

47 - `:coral`

48 

49 - `:echo`

50 

51 - `:sage`

52 

53 - `:shimmer`

54 

55 - `:verse`

56 

57 - `:marin`

58 

59 - `:cedar`

60 

61 - `class ID`

62 

63 Custom voice reference.

64 

65 - `id: String`

66 

67 The custom voice ID, e.g. `voice_1234`.

68 

69- `instructions: String`

70 

71 Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.

72 

73- `response_format: :mp3 | :opus | :aac | 3 more`

74 

75 The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.

76 

77 - `:mp3`

78 

79 - `:opus`

80 

81 - `:aac`

82 

83 - `:flac`

84 

85 - `:wav`

86 

87 - `:pcm`

88 

89- `speed: Float`

90 

91 The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.

92 

93- `stream_format: :sse | :audio`

94 

95 The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.

96 

97 - `:sse`

98 

99 - `:audio`

100 

101### Returns

102 

103- `StringIO`

104 

105### Example

106 

107```ruby

108require "openai"

109 

110openai = OpenAI::Client.new(api_key: "My API Key")

111 

112speech = openai.audio.speech.create(input: "input", model: :"tts-1", voice: :alloy)

113 

114puts(speech)

115```

Details

1## Create client secret

2 

3`realtime.client_secrets.create(**kwargs) -> ClientSecretCreateResponse`

4 

5**post** `/realtime/client_secrets`

6 

7Create a Realtime client secret with an associated session configuration.

8 

9Client secrets are short-lived tokens that can be passed to a client app,

10such as a web frontend or mobile client, which grants access to the Realtime API without

11leaking your main API key. You can configure a custom TTL for each client secret.

12 

13You can also attach session configuration options to the client secret, which will be

14applied to any sessions created using that client secret, but these can also be overridden

15by the client connection.

16 

17[Learn more about authentication with client secrets over WebRTC](https://platform.openai.com/docs/guides/realtime-webrtc).

18 

19Returns the created client secret and the effective session object. The client secret is a string that looks like `ek_1234`.

20 

21### Parameters

22 

23- `expires_after: ExpiresAfter{ anchor, seconds}`

24 

25 Configuration for the client secret expiration. Expiration refers to the time after which

26 a client secret will no longer be valid for creating sessions. The session itself may

27 continue after that time once started. A secret can be used to create multiple sessions

28 until it expires.

29 

30 - `anchor: :created_at`

31 

32 The anchor point for the client secret expiration, meaning that `seconds` will be added to the `created_at` time of the client secret to produce an expiration timestamp. Only `created_at` is currently supported.

33 

34 - `:created_at`

35 

36 - `seconds: Integer`

37 

38 The number of seconds from the anchor point to the expiration. Select a value between `10` and `7200` (2 hours). This default to 600 seconds (10 minutes) if not specified.

39 

40- `session: RealtimeSessionCreateRequest | RealtimeTranscriptionSessionCreateRequest`

41 

42 Session configuration to use for the client secret. Choose either a realtime

43 session or a transcription session.

44 

45 - `class RealtimeSessionCreateRequest`

46 

47 Realtime session object configuration.

48 

49 - `type: :realtime`

50 

51 The type of session to create. Always `realtime` for the Realtime API.

52 

53 - `:realtime`

54 

55 - `audio: RealtimeAudioConfig`

56 

57 Configuration for input and output audio.

58 

59 - `input: RealtimeAudioConfigInput`

60 

61 - `format_: RealtimeAudioFormats`

62 

63 The format of the input audio.

64 

65 - `class AudioPCM`

66 

67 The PCM audio format. Only a 24kHz sample rate is supported.

68 

69 - `rate: 24000`

70 

71 The sample rate of the audio. Always `24000`.

72 

73 - `24000`

74 

75 - `type: :"audio/pcm"`

76 

77 The audio format. Always `audio/pcm`.

78 

79 - `:"audio/pcm"`

80 

81 - `class AudioPCMU`

82 

83 The G.711 μ-law format.

84 

85 - `type: :"audio/pcmu"`

86 

87 The audio format. Always `audio/pcmu`.

88 

89 - `:"audio/pcmu"`

90 

91 - `class AudioPCMA`

92 

93 The G.711 A-law format.

94 

95 - `type: :"audio/pcma"`

96 

97 The audio format. Always `audio/pcma`.

98 

99 - `:"audio/pcma"`

100 

101 - `noise_reduction: NoiseReduction{ type}`

102 

103 Configuration for input audio noise reduction. This can be set to `null` to turn off.

104 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

105 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

106 

107 - `type: NoiseReductionType`

108 

109 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

110 

111 - `:near_field`

112 

113 - `:far_field`

114 

115 - `transcription: AudioTranscription`

116 

117 Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.

118 

119 - `delay: :minimal | :low | :medium | 2 more`

120 

121 Controls how long the model waits before emitting transcription text.

122 Higher values can improve transcription accuracy at the cost of latency.

123 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

124 

125 - `:minimal`

126 

127 - `:low`

128 

129 - `:medium`

130 

131 - `:high`

132 

133 - `:xhigh`

134 

135 - `language: String`

136 

137 The language of the input audio. Supplying the input language in

138 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

139 will improve accuracy and latency.

140 

141 - `model: String | :"whisper-1" | :"gpt-4o-mini-transcribe" | :"gpt-4o-mini-transcribe-2025-12-15" | 3 more`

142 

143 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

144 

145 - `String = String`

146 

147 - `Model = :"whisper-1" | :"gpt-4o-mini-transcribe" | :"gpt-4o-mini-transcribe-2025-12-15" | 3 more`

148 

149 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

150 

151 - `:"whisper-1"`

152 

153 - `:"gpt-4o-mini-transcribe"`

154 

155 - `:"gpt-4o-mini-transcribe-2025-12-15"`

156 

157 - `:"gpt-4o-transcribe"`

158 

159 - `:"gpt-4o-transcribe-diarize"`

160 

161 - `:"gpt-realtime-whisper"`

162 

163 - `prompt: String`

164 

165 An optional text to guide the model's style or continue a previous audio

166 segment.

167 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).

168 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

169 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

170 

171 - `turn_detection: RealtimeAudioInputTurnDetection`

172 

173 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

174 

175 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

176 

177 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

178 

179 For `gpt-realtime-whisper` transcription sessions, turn detection must be

180 set to `null`; VAD is not supported.

181 

182 - `class ServerVad`

183 

184 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.

185 

186 - `type: :server_vad`

187 

188 Type of turn detection, `server_vad` to turn on simple Server VAD.

189 

190 - `:server_vad`

191 

192 - `create_response: bool`

193 

194 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

195 

196 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

197 

198 - `idle_timeout_ms: Integer`

199 

200 Optional timeout after which a model response will be triggered automatically. This is

201 useful for situations in which a long pause from the user is unexpected, such as a phone

202 call. The model will effectively prompt the user to continue the conversation based

203 on the current context.

204 

205 The timeout value will be applied after the last model response's audio has finished playing,

206 i.e. it's set to the `response.done` time plus audio playback duration.

207 

208 An `input_audio_buffer.timeout_triggered` event (plus events

209 associated with the Response) will be emitted when the timeout is reached.

210 Idle timeout is currently only supported for `server_vad` mode.

211 

212 - `interrupt_response: bool`

213 

214 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

215 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

216 

217 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

218 

219 - `prefix_padding_ms: Integer`

220 

221 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

222 milliseconds). Defaults to 300ms.

223 

224 - `silence_duration_ms: Integer`

225 

226 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

227 to 500ms. With shorter values the model will respond more quickly,

228 but may jump in on short pauses from the user.

229 

230 - `threshold: Float`

231 

232 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

233 higher threshold will require louder audio to activate the model, and

234 thus might perform better in noisy environments.

235 

236 - `class SemanticVad`

237 

238 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.

239 

240 - `type: :semantic_vad`

241 

242 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

243 

244 - `:semantic_vad`

245 

246 - `create_response: bool`

247 

248 Whether or not to automatically generate a response when a VAD stop event occurs.

249 

250 - `eagerness: :low | :medium | :high | :auto`

251 

252 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

253 

254 - `:low`

255 

256 - `:medium`

257 

258 - `:high`

259 

260 - `:auto`

261 

262 - `interrupt_response: bool`

263 

264 Whether or not to automatically interrupt any ongoing response with output to the default

265 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

266 

267 - `output: RealtimeAudioConfigOutput`

268 

269 - `format_: RealtimeAudioFormats`

270 

271 The format of the output audio.

272 

273 - `speed: Float`

274 

275 The speed of the model's spoken response as a multiple of the original speed.

276 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.

277 

278 This parameter is a post-processing adjustment to the audio after it is generated, it's

279 also possible to prompt the model to speak faster or slower.

280 

281 - `voice: String | :alloy | :ash | :ballad | 7 more | ID{ id}`

282 

283 The voice the model uses to respond. Supported built-in voices are

284 `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,

285 `marin`, and `cedar`. You may also provide a custom voice object with

286 an `id`, for example `{ "id": "voice_1234" }`. Voice cannot be changed

287 during the session once the model has responded with audio at least once.

288 We recommend `marin` and `cedar` for best quality.

289 

290 - `String = String`

291 

292 - `Voice = :alloy | :ash | :ballad | 7 more`

293 

294 - `:alloy`

295 

296 - `:ash`

297 

298 - `:ballad`

299 

300 - `:coral`

301 

302 - `:echo`

303 

304 - `:sage`

305 

306 - `:shimmer`

307 

308 - `:verse`

309 

310 - `:marin`

311 

312 - `:cedar`

313 

314 - `class ID`

315 

316 Custom voice reference.

317 

318 - `id: String`

319 

320 The custom voice ID, e.g. `voice_1234`.

321 

322 - `include: Array[:"item.input_audio_transcription.logprobs"]`

323 

324 Additional fields to include in server outputs.

325 

326 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

327 

328 - `:"item.input_audio_transcription.logprobs"`

329 

330 - `instructions: String`

331 

332 The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.

333 

334 Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.

335 

336 - `max_output_tokens: Integer | :inf`

337 

338 Maximum number of output tokens for a single assistant response,

339 inclusive of tool calls. Provide an integer between 1 and 4096 to

340 limit output tokens, or `inf` for the maximum available tokens for a

341 given model. Defaults to `inf`.

342 

343 - `Integer = Integer`

344 

345 - `MaxOutputTokens = :inf`

346 

347 - `:inf`

348 

349 - `model: String | :"gpt-realtime" | :"gpt-realtime-1.5" | :"gpt-realtime-2" | 14 more`

350 

351 The Realtime model used for this session.

352 

353 - `String = String`

354 

355 - `Model = :"gpt-realtime" | :"gpt-realtime-1.5" | :"gpt-realtime-2" | 14 more`

356 

357 The Realtime model used for this session.

358 

359 - `:"gpt-realtime"`

360 

361 - `:"gpt-realtime-1.5"`

362 

363 - `:"gpt-realtime-2"`

364 

365 - `:"gpt-realtime-2025-08-28"`

366 

367 - `:"gpt-4o-realtime-preview"`

368 

369 - `:"gpt-4o-realtime-preview-2024-10-01"`

370 

371 - `:"gpt-4o-realtime-preview-2024-12-17"`

372 

373 - `:"gpt-4o-realtime-preview-2025-06-03"`

374 

375 - `:"gpt-4o-mini-realtime-preview"`

376 

377 - `:"gpt-4o-mini-realtime-preview-2024-12-17"`

378 

379 - `:"gpt-realtime-mini"`

380 

381 - `:"gpt-realtime-mini-2025-10-06"`

382 

383 - `:"gpt-realtime-mini-2025-12-15"`

384 

385 - `:"gpt-audio-1.5"`

386 

387 - `:"gpt-audio-mini"`

388 

389 - `:"gpt-audio-mini-2025-10-06"`

390 

391 - `:"gpt-audio-mini-2025-12-15"`

392 

393 - `output_modalities: Array[:text | :audio]`

394 

395 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating

396 that the model will respond with audio plus a transcript. `["text"]` can be used to make

397 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.

398 

399 - `:text`

400 

401 - `:audio`

402 

403 - `parallel_tool_calls: bool`

404 

405 Whether the model may call multiple tools in parallel. Only supported by

406 reasoning Realtime models such as `gpt-realtime-2`.

407 

408 - `prompt: ResponsePrompt`

409 

410 Reference to a prompt template and its variables.

411 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).

412 

413 - `id: String`

414 

415 The unique identifier of the prompt template to use.

416 

417 - `variables: Hash[Symbol, String | ResponseInputText | ResponseInputImage | ResponseInputFile]`

418 

419 Optional map of values to substitute in for variables in your

420 prompt. The substitution values can either be strings, or other

421 Response input types like images or files.

422 

423 - `String = String`

424 

425 - `class ResponseInputText`

426 

427 A text input to the model.

428 

429 - `text: String`

430 

431 The text input to the model.

432 

433 - `type: :input_text`

434 

435 The type of the input item. Always `input_text`.

436 

437 - `:input_text`

438 

439 - `class ResponseInputImage`

440 

441 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).

442 

443 - `detail: :low | :high | :auto | :original`

444 

445 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.

446 

447 - `:low`

448 

449 - `:high`

450 

451 - `:auto`

452 

453 - `:original`

454 

455 - `type: :input_image`

456 

457 The type of the input item. Always `input_image`.

458 

459 - `:input_image`

460 

461 - `file_id: String`

462 

463 The ID of the file to be sent to the model.

464 

465 - `image_url: String`

466 

467 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.

468 

469 - `class ResponseInputFile`

470 

471 A file input to the model.

472 

473 - `type: :input_file`

474 

475 The type of the input item. Always `input_file`.

476 

477 - `:input_file`

478 

479 - `detail: :low | :high`

480 

481 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.

482 

483 - `:low`

484 

485 - `:high`

486 

487 - `file_data: String`

488 

489 The content of the file to be sent to the model.

490 

491 - `file_id: String`

492 

493 The ID of the file to be sent to the model.

494 

495 - `file_url: String`

496 

497 The URL of the file to be sent to the model.

498 

499 - `filename: String`

500 

501 The name of the file to be sent to the model.

502 

503 - `version: String`

504 

505 Optional version of the prompt template.

506 

507 - `reasoning: RealtimeReasoning`

508 

509 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.

510 

511 - `effort: RealtimeReasoningEffort`

512 

513 Constrains effort on reasoning for reasoning-capable Realtime models such as

514 `gpt-realtime-2`.

515 

516 - `:minimal`

517 

518 - `:low`

519 

520 - `:medium`

521 

522 - `:high`

523 

524 - `:xhigh`

525 

526 - `tool_choice: RealtimeToolChoiceConfig`

527 

528 How the model chooses tools. Provide one of the string modes or force a specific

529 function/MCP tool.

530 

531 - `ToolChoiceOptions = :none | :auto | :required`

532 

533 Controls which (if any) tool is called by the model.

534 

535 `none` means the model will not call any tool and instead generates a message.

536 

537 `auto` means the model can pick between generating a message or calling one or

538 more tools.

539 

540 `required` means the model must call one or more tools.

541 

542 - `:none`

543 

544 - `:auto`

545 

546 - `:required`

547 

548 - `class ToolChoiceFunction`

549 

550 Use this option to force the model to call a specific function.

551 

552 - `name: String`

553 

554 The name of the function to call.

555 

556 - `type: :function`

557 

558 For function calling, the type is always `function`.

559 

560 - `:function`

561 

562 - `class ToolChoiceMcp`

563 

564 Use this option to force the model to call a specific tool on a remote MCP server.

565 

566 - `server_label: String`

567 

568 The label of the MCP server to use.

569 

570 - `type: :mcp`

571 

572 For MCP tools, the type is always `mcp`.

573 

574 - `:mcp`

575 

576 - `name: String`

577 

578 The name of the tool to call on the server.

579 

580 - `tools: RealtimeToolsConfig`

581 

582 Tools available to the model.

583 

584 - `class RealtimeFunctionTool`

585 

586 - `description: String`

587 

588 The description of the function, including guidance on when and how

589 to call it, and guidance about what to tell the user when calling

590 (if anything).

591 

592 - `name: String`

593 

594 The name of the function.

595 

596 - `parameters: untyped`

597 

598 Parameters of the function in JSON Schema.

599 

600 - `type: :function`

601 

602 The type of the tool, i.e. `function`.

603 

604 - `:function`

605 

606 - `class Mcp`

607 

608 Give the model access to additional tools via remote Model Context Protocol

609 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).

610 

611 - `server_label: String`

612 

613 A label for this MCP server, used to identify it in tool calls.

614 

615 - `type: :mcp`

616 

617 The type of the MCP tool. Always `mcp`.

618 

619 - `:mcp`

620 

621 - `allowed_tools: Array[String] | McpToolFilter{ read_only, tool_names}`

622 

623 List of allowed tool names or a filter object.

624 

625 - `McpAllowedTools = Array[String]`

626 

627 A string array of allowed tool names

628 

629 - `class McpToolFilter`

630 

631 A filter object to specify which tools are allowed.

632 

633 - `read_only: bool`

634 

635 Indicates whether or not a tool modifies data or is read-only. If an

636 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

637 it will match this filter.

638 

639 - `tool_names: Array[String]`

640 

641 List of allowed tool names.

642 

643 - `authorization: String`

644 

645 An OAuth access token that can be used with a remote MCP server, either

646 with a custom MCP server URL or a service connector. Your application

647 must handle the OAuth authorization flow and provide the token here.

648 

649 - `connector_id: :connector_dropbox | :connector_gmail | :connector_googlecalendar | 5 more`

650 

651 Identifier for service connectors, like those available in ChatGPT. One of

652 `server_url` or `connector_id` must be provided. Learn more about service

653 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).

654 

655 Currently supported `connector_id` values are:

656 

657 - Dropbox: `connector_dropbox`

658 - Gmail: `connector_gmail`

659 - Google Calendar: `connector_googlecalendar`

660 - Google Drive: `connector_googledrive`

661 - Microsoft Teams: `connector_microsoftteams`

662 - Outlook Calendar: `connector_outlookcalendar`

663 - Outlook Email: `connector_outlookemail`

664 - SharePoint: `connector_sharepoint`

665 

666 - `:connector_dropbox`

667 

668 - `:connector_gmail`

669 

670 - `:connector_googlecalendar`

671 

672 - `:connector_googledrive`

673 

674 - `:connector_microsoftteams`

675 

676 - `:connector_outlookcalendar`

677 

678 - `:connector_outlookemail`

679 

680 - `:connector_sharepoint`

681 

682 - `defer_loading: bool`

683 

684 Whether this MCP tool is deferred and discovered via tool search.

685 

686 - `headers: Hash[Symbol, String]`

687 

688 Optional HTTP headers to send to the MCP server. Use for authentication

689 or other purposes.

690 

691 - `require_approval: McpToolApprovalFilter{ always, never} | :always | :never`

692 

693 Specify which of the MCP server's tools require approval.

694 

695 - `class McpToolApprovalFilter`

696 

697 Specify which of the MCP server's tools require approval. Can be

698 `always`, `never`, or a filter object associated with tools

699 that require approval.

700 

701 - `always: Always{ read_only, tool_names}`

702 

703 A filter object to specify which tools are allowed.

704 

705 - `read_only: bool`

706 

707 Indicates whether or not a tool modifies data or is read-only. If an

708 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

709 it will match this filter.

710 

711 - `tool_names: Array[String]`

712 

713 List of allowed tool names.

714 

715 - `never: Never{ read_only, tool_names}`

716 

717 A filter object to specify which tools are allowed.

718 

719 - `read_only: bool`

720 

721 Indicates whether or not a tool modifies data or is read-only. If an

722 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

723 it will match this filter.

724 

725 - `tool_names: Array[String]`

726 

727 List of allowed tool names.

728 

729 - `McpToolApprovalSetting = :always | :never`

730 

731 Specify a single approval policy for all tools. One of `always` or

732 `never`. When set to `always`, all tools will require approval. When

733 set to `never`, all tools will not require approval.

734 

735 - `:always`

736 

737 - `:never`

738 

739 - `server_description: String`

740 

741 Optional description of the MCP server, used to provide more context.

742 

743 - `server_url: String`

744 

745 The URL for the MCP server. One of `server_url` or `connector_id` must be

746 provided.

747 

748 - `tracing: RealtimeTracingConfig`

749 

750 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once

751 tracing is enabled for a session, the configuration cannot be modified.

752 

753 `auto` will create a trace for the session with default values for the

754 workflow name, group id, and metadata.

755 

756 - `RealtimeTracingConfig = :auto`

757 

758 Enables tracing and sets default values for tracing configuration options. Always `auto`.

759 

760 - `:auto`

761 

762 - `class TracingConfiguration`

763 

764 Granular configuration for tracing.

765 

766 - `group_id: String`

767 

768 The group id to attach to this trace to enable filtering and

769 grouping in the Traces Dashboard.

770 

771 - `metadata: untyped`

772 

773 The arbitrary metadata to attach to this trace to enable

774 filtering in the Traces Dashboard.

775 

776 - `workflow_name: String`

777 

778 The name of the workflow to attach to this trace. This is used to

779 name the trace in the Traces Dashboard.

780 

781 - `truncation: RealtimeTruncation`

782 

783 When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

784 

785 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

786 

787 Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

788 

789 Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.

790 

791 - `RealtimeTruncationStrategy = :auto | :disabled`

792 

793 The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit.

794 

795 - `:auto`

796 

797 - `:disabled`

798 

799 - `class RealtimeTruncationRetentionRatio`

800 

801 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

802 

803 - `retention_ratio: Float`

804 

805 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.

806 

807 - `type: :retention_ratio`

808 

809 Use retention ratio truncation.

810 

811 - `:retention_ratio`

812 

813 - `token_limits: TokenLimits{ post_instructions}`

814 

815 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.

816 

817 - `post_instructions: Integer`

818 

819 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.

820 

821 - `class RealtimeTranscriptionSessionCreateRequest`

822 

823 Realtime transcription session object configuration.

824 

825 - `type: :transcription`

826 

827 The type of session to create. Always `transcription` for transcription sessions.

828 

829 - `:transcription`

830 

831 - `audio: RealtimeTranscriptionSessionAudio`

832 

833 Configuration for input and output audio.

834 

835 - `input: RealtimeTranscriptionSessionAudioInput`

836 

837 - `format_: RealtimeAudioFormats`

838 

839 The PCM audio format. Only a 24kHz sample rate is supported.

840 

841 - `noise_reduction: NoiseReduction{ type}`

842 

843 Configuration for input audio noise reduction. This can be set to `null` to turn off.

844 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

845 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

846 

847 - `type: NoiseReductionType`

848 

849 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

850 

851 - `transcription: AudioTranscription`

852 

853 Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.

854 

855 - `turn_detection: RealtimeTranscriptionSessionAudioInputTurnDetection`

856 

857 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

858 

859 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

860 

861 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

862 

863 For `gpt-realtime-whisper` transcription sessions, turn detection must be

864 set to `null`; VAD is not supported.

865 

866 - `class ServerVad`

867 

868 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.

869 

870 - `type: :server_vad`

871 

872 Type of turn detection, `server_vad` to turn on simple Server VAD.

873 

874 - `:server_vad`

875 

876 - `create_response: bool`

877 

878 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

879 

880 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

881 

882 - `idle_timeout_ms: Integer`

883 

884 Optional timeout after which a model response will be triggered automatically. This is

885 useful for situations in which a long pause from the user is unexpected, such as a phone

886 call. The model will effectively prompt the user to continue the conversation based

887 on the current context.

888 

889 The timeout value will be applied after the last model response's audio has finished playing,

890 i.e. it's set to the `response.done` time plus audio playback duration.

891 

892 An `input_audio_buffer.timeout_triggered` event (plus events

893 associated with the Response) will be emitted when the timeout is reached.

894 Idle timeout is currently only supported for `server_vad` mode.

895 

896 - `interrupt_response: bool`

897 

898 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

899 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

900 

901 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

902 

903 - `prefix_padding_ms: Integer`

904 

905 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

906 milliseconds). Defaults to 300ms.

907 

908 - `silence_duration_ms: Integer`

909 

910 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

911 to 500ms. With shorter values the model will respond more quickly,

912 but may jump in on short pauses from the user.

913 

914 - `threshold: Float`

915 

916 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

917 higher threshold will require louder audio to activate the model, and

918 thus might perform better in noisy environments.

919 

920 - `class SemanticVad`

921 

922 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.

923 

924 - `type: :semantic_vad`

925 

926 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

927 

928 - `:semantic_vad`

929 

930 - `create_response: bool`

931 

932 Whether or not to automatically generate a response when a VAD stop event occurs.

933 

934 - `eagerness: :low | :medium | :high | :auto`

935 

936 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

937 

938 - `:low`

939 

940 - `:medium`

941 

942 - `:high`

943 

944 - `:auto`

945 

946 - `interrupt_response: bool`

947 

948 Whether or not to automatically interrupt any ongoing response with output to the default

949 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

950 

951 - `include: Array[:"item.input_audio_transcription.logprobs"]`

952 

953 Additional fields to include in server outputs.

954 

955 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

956 

957 - `:"item.input_audio_transcription.logprobs"`

958 

959### Returns

960 

961- `class ClientSecretCreateResponse`

962 

963 Response from creating a session and client secret for the Realtime API.

964 

965 - `expires_at: Integer`

966 

967 Expiration timestamp for the client secret, in seconds since epoch.

968 

969 - `session: RealtimeSessionCreateResponse | RealtimeTranscriptionSessionCreateResponse`

970 

971 The session configuration for either a realtime or transcription session.

972 

973 - `class RealtimeSessionCreateResponse`

974 

975 A Realtime session configuration object.

976 

977 - `id: String`

978 

979 Unique identifier for the session that looks like `sess_1234567890abcdef`.

980 

981 - `object: :"realtime.session"`

982 

983 The object type. Always `realtime.session`.

984 

985 - `:"realtime.session"`

986 

987 - `type: :realtime`

988 

989 The type of session to create. Always `realtime` for the Realtime API.

990 

991 - `:realtime`

992 

993 - `audio: Audio{ input, output}`

994 

995 Configuration for input and output audio.

996 

997 - `input: Input{ format_, noise_reduction, transcription, turn_detection}`

998 

999 - `format_: RealtimeAudioFormats`

1000 

1001 The format of the input audio.

1002 

1003 - `class AudioPCM`

1004 

1005 The PCM audio format. Only a 24kHz sample rate is supported.

1006 

1007 - `rate: 24000`

1008 

1009 The sample rate of the audio. Always `24000`.

1010 

1011 - `24000`

1012 

1013 - `type: :"audio/pcm"`

1014 

1015 The audio format. Always `audio/pcm`.

1016 

1017 - `:"audio/pcm"`

1018 

1019 - `class AudioPCMU`

1020 

1021 The G.711 μ-law format.

1022 

1023 - `type: :"audio/pcmu"`

1024 

1025 The audio format. Always `audio/pcmu`.

1026 

1027 - `:"audio/pcmu"`

1028 

1029 - `class AudioPCMA`

1030 

1031 The G.711 A-law format.

1032 

1033 - `type: :"audio/pcma"`

1034 

1035 The audio format. Always `audio/pcma`.

1036 

1037 - `:"audio/pcma"`

1038 

1039 - `noise_reduction: NoiseReduction{ type}`

1040 

1041 Configuration for input audio noise reduction. This can be set to `null` to turn off.

1042 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

1043 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

1044 

1045 - `type: NoiseReductionType`

1046 

1047 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

1048 

1049 - `:near_field`

1050 

1051 - `:far_field`

1052 

1053 - `transcription: AudioTranscription`

1054 

1055 - `delay: :minimal | :low | :medium | 2 more`

1056 

1057 Controls how long the model waits before emitting transcription text.

1058 Higher values can improve transcription accuracy at the cost of latency.

1059 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

1060 

1061 - `:minimal`

1062 

1063 - `:low`

1064 

1065 - `:medium`

1066 

1067 - `:high`

1068 

1069 - `:xhigh`

1070 

1071 - `language: String`

1072 

1073 The language of the input audio. Supplying the input language in

1074 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

1075 will improve accuracy and latency.

1076 

1077 - `model: String | :"whisper-1" | :"gpt-4o-mini-transcribe" | :"gpt-4o-mini-transcribe-2025-12-15" | 3 more`

1078 

1079 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

1080 

1081 - `String = String`

1082 

1083 - `Model = :"whisper-1" | :"gpt-4o-mini-transcribe" | :"gpt-4o-mini-transcribe-2025-12-15" | 3 more`

1084 

1085 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

1086 

1087 - `:"whisper-1"`

1088 

1089 - `:"gpt-4o-mini-transcribe"`

1090 

1091 - `:"gpt-4o-mini-transcribe-2025-12-15"`

1092 

1093 - `:"gpt-4o-transcribe"`

1094 

1095 - `:"gpt-4o-transcribe-diarize"`

1096 

1097 - `:"gpt-realtime-whisper"`

1098 

1099 - `prompt: String`

1100 

1101 An optional text to guide the model's style or continue a previous audio

1102 segment.

1103 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).

1104 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

1105 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

1106 

1107 - `turn_detection: ServerVad{ type, create_response, idle_timeout_ms, 4 more} | SemanticVad{ type, create_response, eagerness, interrupt_response}`

1108 

1109 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

1110 

1111 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

1112 

1113 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

1114 

1115 For `gpt-realtime-whisper` transcription sessions, turn detection must be

1116 set to `null`; VAD is not supported.

1117 

1118 - `class ServerVad`

1119 

1120 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.

1121 

1122 - `type: :server_vad`

1123 

1124 Type of turn detection, `server_vad` to turn on simple Server VAD.

1125 

1126 - `:server_vad`

1127 

1128 - `create_response: bool`

1129 

1130 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

1131 

1132 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

1133 

1134 - `idle_timeout_ms: Integer`

1135 

1136 Optional timeout after which a model response will be triggered automatically. This is

1137 useful for situations in which a long pause from the user is unexpected, such as a phone

1138 call. The model will effectively prompt the user to continue the conversation based

1139 on the current context.

1140 

1141 The timeout value will be applied after the last model response's audio has finished playing,

1142 i.e. it's set to the `response.done` time plus audio playback duration.

1143 

1144 An `input_audio_buffer.timeout_triggered` event (plus events

1145 associated with the Response) will be emitted when the timeout is reached.

1146 Idle timeout is currently only supported for `server_vad` mode.

1147 

1148 - `interrupt_response: bool`

1149 

1150 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

1151 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

1152 

1153 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

1154 

1155 - `prefix_padding_ms: Integer`

1156 

1157 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

1158 milliseconds). Defaults to 300ms.

1159 

1160 - `silence_duration_ms: Integer`

1161 

1162 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

1163 to 500ms. With shorter values the model will respond more quickly,

1164 but may jump in on short pauses from the user.

1165 

1166 - `threshold: Float`

1167 

1168 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

1169 higher threshold will require louder audio to activate the model, and

1170 thus might perform better in noisy environments.

1171 

1172 - `class SemanticVad`

1173 

1174 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.

1175 

1176 - `type: :semantic_vad`

1177 

1178 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

1179 

1180 - `:semantic_vad`

1181 

1182 - `create_response: bool`

1183 

1184 Whether or not to automatically generate a response when a VAD stop event occurs.

1185 

1186 - `eagerness: :low | :medium | :high | :auto`

1187 

1188 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

1189 

1190 - `:low`

1191 

1192 - `:medium`

1193 

1194 - `:high`

1195 

1196 - `:auto`

1197 

1198 - `interrupt_response: bool`

1199 

1200 Whether or not to automatically interrupt any ongoing response with output to the default

1201 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

1202 

1203 - `output: Output{ format_, speed, voice}`

1204 

1205 - `format_: RealtimeAudioFormats`

1206 

1207 The format of the output audio.

1208 

1209 - `speed: Float`

1210 

1211 The speed of the model's spoken response as a multiple of the original speed.

1212 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.

1213 

1214 This parameter is a post-processing adjustment to the audio after it is generated, it's

1215 also possible to prompt the model to speak faster or slower.

1216 

1217 - `voice: String | :alloy | :ash | :ballad | 7 more`

1218 

1219 The voice the model uses to respond. Voice cannot be changed during the

1220 session once the model has responded with audio at least once. Current

1221 voice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,

1222 `shimmer`, `verse`, `marin`, and `cedar`. We recommend `marin` and `cedar` for

1223 best quality.

1224 

1225 - `String = String`

1226 

1227 - `Voice = :alloy | :ash | :ballad | 7 more`

1228 

1229 The voice the model uses to respond. Voice cannot be changed during the

1230 session once the model has responded with audio at least once. Current

1231 voice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,

1232 `shimmer`, `verse`, `marin`, and `cedar`. We recommend `marin` and `cedar` for

1233 best quality.

1234 

1235 - `:alloy`

1236 

1237 - `:ash`

1238 

1239 - `:ballad`

1240 

1241 - `:coral`

1242 

1243 - `:echo`

1244 

1245 - `:sage`

1246 

1247 - `:shimmer`

1248 

1249 - `:verse`

1250 

1251 - `:marin`

1252 

1253 - `:cedar`

1254 

1255 - `expires_at: Integer`

1256 

1257 Expiration timestamp for the session, in seconds since epoch.

1258 

1259 - `include: Array[:"item.input_audio_transcription.logprobs"]`

1260 

1261 Additional fields to include in server outputs.

1262 

1263 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

1264 

1265 - `:"item.input_audio_transcription.logprobs"`

1266 

1267 - `instructions: String`

1268 

1269 The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.

1270 

1271 Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.

1272 

1273 - `max_output_tokens: Integer | :inf`

1274 

1275 Maximum number of output tokens for a single assistant response,

1276 inclusive of tool calls. Provide an integer between 1 and 4096 to

1277 limit output tokens, or `inf` for the maximum available tokens for a

1278 given model. Defaults to `inf`.

1279 

1280 - `Integer = Integer`

1281 

1282 - `MaxOutputTokens = :inf`

1283 

1284 - `:inf`

1285 

1286 - `model: String | :"gpt-realtime" | :"gpt-realtime-1.5" | :"gpt-realtime-2" | 14 more`

1287 

1288 The Realtime model used for this session.

1289 

1290 - `String = String`

1291 

1292 - `Model = :"gpt-realtime" | :"gpt-realtime-1.5" | :"gpt-realtime-2" | 14 more`

1293 

1294 The Realtime model used for this session.

1295 

1296 - `:"gpt-realtime"`

1297 

1298 - `:"gpt-realtime-1.5"`

1299 

1300 - `:"gpt-realtime-2"`

1301 

1302 - `:"gpt-realtime-2025-08-28"`

1303 

1304 - `:"gpt-4o-realtime-preview"`

1305 

1306 - `:"gpt-4o-realtime-preview-2024-10-01"`

1307 

1308 - `:"gpt-4o-realtime-preview-2024-12-17"`

1309 

1310 - `:"gpt-4o-realtime-preview-2025-06-03"`

1311 

1312 - `:"gpt-4o-mini-realtime-preview"`

1313 

1314 - `:"gpt-4o-mini-realtime-preview-2024-12-17"`

1315 

1316 - `:"gpt-realtime-mini"`

1317 

1318 - `:"gpt-realtime-mini-2025-10-06"`

1319 

1320 - `:"gpt-realtime-mini-2025-12-15"`

1321 

1322 - `:"gpt-audio-1.5"`

1323 

1324 - `:"gpt-audio-mini"`

1325 

1326 - `:"gpt-audio-mini-2025-10-06"`

1327 

1328 - `:"gpt-audio-mini-2025-12-15"`

1329 

1330 - `output_modalities: Array[:text | :audio]`

1331 

1332 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating

1333 that the model will respond with audio plus a transcript. `["text"]` can be used to make

1334 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.

1335 

1336 - `:text`

1337 

1338 - `:audio`

1339 

1340 - `prompt: ResponsePrompt`

1341 

1342 Reference to a prompt template and its variables.

1343 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).

1344 

1345 - `id: String`

1346 

1347 The unique identifier of the prompt template to use.

1348 

1349 - `variables: Hash[Symbol, String | ResponseInputText | ResponseInputImage | ResponseInputFile]`

1350 

1351 Optional map of values to substitute in for variables in your

1352 prompt. The substitution values can either be strings, or other

1353 Response input types like images or files.

1354 

1355 - `String = String`

1356 

1357 - `class ResponseInputText`

1358 

1359 A text input to the model.

1360 

1361 - `text: String`

1362 

1363 The text input to the model.

1364 

1365 - `type: :input_text`

1366 

1367 The type of the input item. Always `input_text`.

1368 

1369 - `:input_text`

1370 

1371 - `class ResponseInputImage`

1372 

1373 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).

1374 

1375 - `detail: :low | :high | :auto | :original`

1376 

1377 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.

1378 

1379 - `:low`

1380 

1381 - `:high`

1382 

1383 - `:auto`

1384 

1385 - `:original`

1386 

1387 - `type: :input_image`

1388 

1389 The type of the input item. Always `input_image`.

1390 

1391 - `:input_image`

1392 

1393 - `file_id: String`

1394 

1395 The ID of the file to be sent to the model.

1396 

1397 - `image_url: String`

1398 

1399 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.

1400 

1401 - `class ResponseInputFile`

1402 

1403 A file input to the model.

1404 

1405 - `type: :input_file`

1406 

1407 The type of the input item. Always `input_file`.

1408 

1409 - `:input_file`

1410 

1411 - `detail: :low | :high`

1412 

1413 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.

1414 

1415 - `:low`

1416 

1417 - `:high`

1418 

1419 - `file_data: String`

1420 

1421 The content of the file to be sent to the model.

1422 

1423 - `file_id: String`

1424 

1425 The ID of the file to be sent to the model.

1426 

1427 - `file_url: String`

1428 

1429 The URL of the file to be sent to the model.

1430 

1431 - `filename: String`

1432 

1433 The name of the file to be sent to the model.

1434 

1435 - `version: String`

1436 

1437 Optional version of the prompt template.

1438 

1439 - `reasoning: RealtimeReasoning`

1440 

1441 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.

1442 

1443 - `effort: RealtimeReasoningEffort`

1444 

1445 Constrains effort on reasoning for reasoning-capable Realtime models such as

1446 `gpt-realtime-2`.

1447 

1448 - `:minimal`

1449 

1450 - `:low`

1451 

1452 - `:medium`

1453 

1454 - `:high`

1455 

1456 - `:xhigh`

1457 

1458 - `tool_choice: ToolChoiceOptions | ToolChoiceFunction | ToolChoiceMcp`

1459 

1460 How the model chooses tools. Provide one of the string modes or force a specific

1461 function/MCP tool.

1462 

1463 - `ToolChoiceOptions = :none | :auto | :required`

1464 

1465 Controls which (if any) tool is called by the model.

1466 

1467 `none` means the model will not call any tool and instead generates a message.

1468 

1469 `auto` means the model can pick between generating a message or calling one or

1470 more tools.

1471 

1472 `required` means the model must call one or more tools.

1473 

1474 - `:none`

1475 

1476 - `:auto`

1477 

1478 - `:required`

1479 

1480 - `class ToolChoiceFunction`

1481 

1482 Use this option to force the model to call a specific function.

1483 

1484 - `name: String`

1485 

1486 The name of the function to call.

1487 

1488 - `type: :function`

1489 

1490 For function calling, the type is always `function`.

1491 

1492 - `:function`

1493 

1494 - `class ToolChoiceMcp`

1495 

1496 Use this option to force the model to call a specific tool on a remote MCP server.

1497 

1498 - `server_label: String`

1499 

1500 The label of the MCP server to use.

1501 

1502 - `type: :mcp`

1503 

1504 For MCP tools, the type is always `mcp`.

1505 

1506 - `:mcp`

1507 

1508 - `name: String`

1509 

1510 The name of the tool to call on the server.

1511 

1512 - `tools: Array[RealtimeFunctionTool | McpTool{ server_label, type, allowed_tools, 7 more}]`

1513 

1514 Tools available to the model.

1515 

1516 - `class RealtimeFunctionTool`

1517 

1518 - `description: String`

1519 

1520 The description of the function, including guidance on when and how

1521 to call it, and guidance about what to tell the user when calling

1522 (if anything).

1523 

1524 - `name: String`

1525 

1526 The name of the function.

1527 

1528 - `parameters: untyped`

1529 

1530 Parameters of the function in JSON Schema.

1531 

1532 - `type: :function`

1533 

1534 The type of the tool, i.e. `function`.

1535 

1536 - `:function`

1537 

1538 - `class McpTool`

1539 

1540 Give the model access to additional tools via remote Model Context Protocol

1541 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).

1542 

1543 - `server_label: String`

1544 

1545 A label for this MCP server, used to identify it in tool calls.

1546 

1547 - `type: :mcp`

1548 

1549 The type of the MCP tool. Always `mcp`.

1550 

1551 - `:mcp`

1552 

1553 - `allowed_tools: Array[String] | McpToolFilter{ read_only, tool_names}`

1554 

1555 List of allowed tool names or a filter object.

1556 

1557 - `McpAllowedTools = Array[String]`

1558 

1559 A string array of allowed tool names

1560 

1561 - `class McpToolFilter`

1562 

1563 A filter object to specify which tools are allowed.

1564 

1565 - `read_only: bool`

1566 

1567 Indicates whether or not a tool modifies data or is read-only. If an

1568 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1569 it will match this filter.

1570 

1571 - `tool_names: Array[String]`

1572 

1573 List of allowed tool names.

1574 

1575 - `authorization: String`

1576 

1577 An OAuth access token that can be used with a remote MCP server, either

1578 with a custom MCP server URL or a service connector. Your application

1579 must handle the OAuth authorization flow and provide the token here.

1580 

1581 - `connector_id: :connector_dropbox | :connector_gmail | :connector_googlecalendar | 5 more`

1582 

1583 Identifier for service connectors, like those available in ChatGPT. One of

1584 `server_url` or `connector_id` must be provided. Learn more about service

1585 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).

1586 

1587 Currently supported `connector_id` values are:

1588 

1589 - Dropbox: `connector_dropbox`

1590 - Gmail: `connector_gmail`

1591 - Google Calendar: `connector_googlecalendar`

1592 - Google Drive: `connector_googledrive`

1593 - Microsoft Teams: `connector_microsoftteams`

1594 - Outlook Calendar: `connector_outlookcalendar`

1595 - Outlook Email: `connector_outlookemail`

1596 - SharePoint: `connector_sharepoint`

1597 

1598 - `:connector_dropbox`

1599 

1600 - `:connector_gmail`

1601 

1602 - `:connector_googlecalendar`

1603 

1604 - `:connector_googledrive`

1605 

1606 - `:connector_microsoftteams`

1607 

1608 - `:connector_outlookcalendar`

1609 

1610 - `:connector_outlookemail`

1611 

1612 - `:connector_sharepoint`

1613 

1614 - `defer_loading: bool`

1615 

1616 Whether this MCP tool is deferred and discovered via tool search.

1617 

1618 - `headers: Hash[Symbol, String]`

1619 

1620 Optional HTTP headers to send to the MCP server. Use for authentication

1621 or other purposes.

1622 

1623 - `require_approval: McpToolApprovalFilter{ always, never} | :always | :never`

1624 

1625 Specify which of the MCP server's tools require approval.

1626 

1627 - `class McpToolApprovalFilter`

1628 

1629 Specify which of the MCP server's tools require approval. Can be

1630 `always`, `never`, or a filter object associated with tools

1631 that require approval.

1632 

1633 - `always: Always{ read_only, tool_names}`

1634 

1635 A filter object to specify which tools are allowed.

1636 

1637 - `read_only: bool`

1638 

1639 Indicates whether or not a tool modifies data or is read-only. If an

1640 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1641 it will match this filter.

1642 

1643 - `tool_names: Array[String]`

1644 

1645 List of allowed tool names.

1646 

1647 - `never: Never{ read_only, tool_names}`

1648 

1649 A filter object to specify which tools are allowed.

1650 

1651 - `read_only: bool`

1652 

1653 Indicates whether or not a tool modifies data or is read-only. If an

1654 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1655 it will match this filter.

1656 

1657 - `tool_names: Array[String]`

1658 

1659 List of allowed tool names.

1660 

1661 - `McpToolApprovalSetting = :always | :never`

1662 

1663 Specify a single approval policy for all tools. One of `always` or

1664 `never`. When set to `always`, all tools will require approval. When

1665 set to `never`, all tools will not require approval.

1666 

1667 - `:always`

1668 

1669 - `:never`

1670 

1671 - `server_description: String`

1672 

1673 Optional description of the MCP server, used to provide more context.

1674 

1675 - `server_url: String`

1676 

1677 The URL for the MCP server. One of `server_url` or `connector_id` must be

1678 provided.

1679 

1680 - `tracing: :auto | TracingConfiguration{ group_id, metadata, workflow_name}`

1681 

1682 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once

1683 tracing is enabled for a session, the configuration cannot be modified.

1684 

1685 `auto` will create a trace for the session with default values for the

1686 workflow name, group id, and metadata.

1687 

1688 - `Tracing = :auto`

1689 

1690 Enables tracing and sets default values for tracing configuration options. Always `auto`.

1691 

1692 - `:auto`

1693 

1694 - `class TracingConfiguration`

1695 

1696 Granular configuration for tracing.

1697 

1698 - `group_id: String`

1699 

1700 The group id to attach to this trace to enable filtering and

1701 grouping in the Traces Dashboard.

1702 

1703 - `metadata: untyped`

1704 

1705 The arbitrary metadata to attach to this trace to enable

1706 filtering in the Traces Dashboard.

1707 

1708 - `workflow_name: String`

1709 

1710 The name of the workflow to attach to this trace. This is used to

1711 name the trace in the Traces Dashboard.

1712 

1713 - `truncation: RealtimeTruncation`

1714 

1715 When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

1716 

1717 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

1718 

1719 Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

1720 

1721 Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.

1722 

1723 - `RealtimeTruncationStrategy = :auto | :disabled`

1724 

1725 The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit.

1726 

1727 - `:auto`

1728 

1729 - `:disabled`

1730 

1731 - `class RealtimeTruncationRetentionRatio`

1732 

1733 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

1734 

1735 - `retention_ratio: Float`

1736 

1737 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.

1738 

1739 - `type: :retention_ratio`

1740 

1741 Use retention ratio truncation.

1742 

1743 - `:retention_ratio`

1744 

1745 - `token_limits: TokenLimits{ post_instructions}`

1746 

1747 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.

1748 

1749 - `post_instructions: Integer`

1750 

1751 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.

1752 

1753 - `class RealtimeTranscriptionSessionCreateResponse`

1754 

1755 A Realtime transcription session configuration object.

1756 

1757 - `id: String`

1758 

1759 Unique identifier for the session that looks like `sess_1234567890abcdef`.

1760 

1761 - `object: String`

1762 

1763 The object type. Always `realtime.transcription_session`.

1764 

1765 - `type: :transcription`

1766 

1767 The type of session. Always `transcription` for transcription sessions.

1768 

1769 - `:transcription`

1770 

1771 - `audio: Audio{ input}`

1772 

1773 Configuration for input audio for the session.

1774 

1775 - `input: Input{ format_, noise_reduction, transcription, turn_detection}`

1776 

1777 - `format_: RealtimeAudioFormats`

1778 

1779 The PCM audio format. Only a 24kHz sample rate is supported.

1780 

1781 - `noise_reduction: NoiseReduction{ type}`

1782 

1783 Configuration for input audio noise reduction.

1784 

1785 - `type: NoiseReductionType`

1786 

1787 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

1788 

1789 - `transcription: AudioTranscription`

1790 

1791 - `turn_detection: RealtimeTranscriptionSessionTurnDetection`

1792 

1793 Configuration for turn detection. Can be set to `null` to turn off. Server

1794 VAD means that the model will detect the start and end of speech based on

1795 audio volume and respond at the end of user speech. For `gpt-realtime-whisper`, this must be `null`; VAD is not supported.

1796 

1797 - `prefix_padding_ms: Integer`

1798 

1799 Amount of audio to include before the VAD detected speech (in

1800 milliseconds). Defaults to 300ms.

1801 

1802 - `silence_duration_ms: Integer`

1803 

1804 Duration of silence to detect speech stop (in milliseconds). Defaults

1805 to 500ms. With shorter values the model will respond more quickly,

1806 but may jump in on short pauses from the user.

1807 

1808 - `threshold: Float`

1809 

1810 Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

1811 higher threshold will require louder audio to activate the model, and

1812 thus might perform better in noisy environments.

1813 

1814 - `type: String`

1815 

1816 Type of turn detection, only `server_vad` is currently supported.

1817 

1818 - `expires_at: Integer`

1819 

1820 Expiration timestamp for the session, in seconds since epoch.

1821 

1822 - `include: Array[:"item.input_audio_transcription.logprobs"]`

1823 

1824 Additional fields to include in server outputs.

1825 

1826 - `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

1827 

1828 - `:"item.input_audio_transcription.logprobs"`

1829 

1830 - `value: String`

1831 

1832 The generated client secret value.

1833 

1834### Example

1835 

1836```ruby

1837require "openai"

1838 

1839openai = OpenAI::Client.new(api_key: "My API Key")

1840 

1841client_secret = openai.realtime.client_secrets.create

1842 

1843puts(client_secret)

1844```

1845 

1846#### Response

1847 

1848```json

1849{

1850 "expires_at": 0,

1851 "session": {

1852 "id": "id",

1853 "object": "realtime.session",

1854 "type": "realtime",

1855 "audio": {

1856 "input": {

1857 "format": {

1858 "rate": 24000,

1859 "type": "audio/pcm"

1860 },

1861 "noise_reduction": {

1862 "type": "near_field"

1863 },

1864 "transcription": {

1865 "delay": "minimal",

1866 "language": "language",

1867 "model": "whisper-1",

1868 "prompt": "prompt"

1869 },

1870 "turn_detection": {

1871 "type": "server_vad",

1872 "create_response": true,

1873 "idle_timeout_ms": 5000,

1874 "interrupt_response": true,

1875 "prefix_padding_ms": 0,

1876 "silence_duration_ms": 0,

1877 "threshold": 0

1878 }

1879 },

1880 "output": {

1881 "format": {

1882 "rate": 24000,

1883 "type": "audio/pcm"

1884 },

1885 "speed": 0.25,

1886 "voice": "ash"

1887 }

1888 },

1889 "expires_at": 0,

1890 "include": [

1891 "item.input_audio_transcription.logprobs"

1892 ],

1893 "instructions": "instructions",

1894 "max_output_tokens": "inf",

1895 "model": "gpt-realtime",

1896 "output_modalities": [

1897 "text"

1898 ],

1899 "prompt": {

1900 "id": "id",

1901 "variables": {

1902 "foo": "string"

1903 },

1904 "version": "version"

1905 },

1906 "reasoning": {

1907 "effort": "minimal"

1908 },

1909 "tool_choice": "none",

1910 "tools": [

1911 {

1912 "description": "description",

1913 "name": "name",

1914 "parameters": {},

1915 "type": "function"

1916 }

1917 ],

1918 "tracing": "auto",

1919 "truncation": "auto"

1920 },

1921 "value": "value"

1922}

1923```

Details

1## Create video

2 

3`videos.create(**kwargs) -> Video`

4 

5**post** `/videos`

6 

7Create a new video generation job from a prompt and optional reference assets.

8 

9### Parameters

10 

11- `prompt: String`

12 

13 Text prompt that describes the video to generate.

14 

15- `input_reference: String | ImageInputReferenceParam`

16 

17 Optional reference asset upload or reference object that guides generation.

18 

19 - `String = String`

20 

21 Optional reference asset upload or reference object that guides generation.

22 

23 - `class ImageInputReferenceParam`

24 

25 - `file_id: String`

26 

27 - `image_url: String`

28 

29 A fully qualified URL or base64-encoded data URL.

30 

31- `model: VideoModel`

32 

33 The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to `sora-2`.

34 

35 - `String = String`

36 

37 - `VideoModel = :"sora-2" | :"sora-2-pro" | :"sora-2-2025-10-06" | 2 more`

38 

39 - `:"sora-2"`

40 

41 - `:"sora-2-pro"`

42 

43 - `:"sora-2-2025-10-06"`

44 

45 - `:"sora-2-pro-2025-10-06"`

46 

47 - `:"sora-2-2025-12-08"`

48 

49- `seconds: VideoSeconds`

50 

51 Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds.

52 

53 - `:"4"`

54 

55 - `:"8"`

56 

57 - `:"12"`

58 

59- `size: VideoSize`

60 

61 Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280.

62 

63 - `:"720x1280"`

64 

65 - `:"1280x720"`

66 

67 - `:"1024x1792"`

68 

69 - `:"1792x1024"`

70 

71### Returns

72 

73- `class Video`

74 

75 Structured information describing a generated video job.

76 

77 - `id: String`

78 

79 Unique identifier for the video job.

80 

81 - `completed_at: Integer`

82 

83 Unix timestamp (seconds) for when the job completed, if finished.

84 

85 - `created_at: Integer`

86 

87 Unix timestamp (seconds) for when the job was created.

88 

89 - `error: VideoCreateError`

90 

91 Error payload that explains why generation failed, if applicable.

92 

93 - `code: String`

94 

95 A machine-readable error code that was returned.

96 

97 - `message: String`

98 

99 A human-readable description of the error that was returned.

100 

101 - `expires_at: Integer`

102 

103 Unix timestamp (seconds) for when the downloadable assets expire, if set.

104 

105 - `model: VideoModel`

106 

107 The video generation model that produced the job.

108 

109 - `String = String`

110 

111 - `VideoModel = :"sora-2" | :"sora-2-pro" | :"sora-2-2025-10-06" | 2 more`

112 

113 - `:"sora-2"`

114 

115 - `:"sora-2-pro"`

116 

117 - `:"sora-2-2025-10-06"`

118 

119 - `:"sora-2-pro-2025-10-06"`

120 

121 - `:"sora-2-2025-12-08"`

122 

123 - `object: :video`

124 

125 The object type, which is always `video`.

126 

127 - `:video`

128 

129 - `progress: Integer`

130 

131 Approximate completion percentage for the generation task.

132 

133 - `prompt: String`

134 

135 The prompt that was used to generate the video.

136 

137 - `remixed_from_video_id: String`

138 

139 Identifier of the source video if this video is a remix.

140 

141 - `seconds: String | VideoSeconds`

142 

143 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

144 

145 - `String = String`

146 

147 - `VideoSeconds = :"4" | :"8" | :"12"`

148 

149 - `:"4"`

150 

151 - `:"8"`

152 

153 - `:"12"`

154 

155 - `size: VideoSize`

156 

157 The resolution of the generated video.

158 

159 - `:"720x1280"`

160 

161 - `:"1280x720"`

162 

163 - `:"1024x1792"`

164 

165 - `:"1792x1024"`

166 

167 - `status: :queued | :in_progress | :completed | :failed`

168 

169 Current lifecycle status of the video job.

170 

171 - `:queued`

172 

173 - `:in_progress`

174 

175 - `:completed`

176 

177 - `:failed`

178 

179### Example

180 

181```ruby

182require "openai"

183 

184openai = OpenAI::Client.new(api_key: "My API Key")

185 

186video = openai.videos.create(prompt: "x")

187 

188puts(video)

189```

190 

191#### Response

192 

193```json

194{

195 "id": "id",

196 "completed_at": 0,

197 "created_at": 0,

198 "error": {

199 "code": "code",

200 "message": "message"

201 },

202 "expires_at": 0,

203 "model": "sora-2",

204 "object": "video",

205 "progress": 0,

206 "prompt": "prompt",

207 "remixed_from_video_id": "remixed_from_video_id",

208 "seconds": "4",

209 "size": "720x1280",

210 "status": "queued"

211}

212```

213 

214### Example

215 

216```ruby

217require "openai"

218 

219openai = OpenAI::Client.new

220 

221video = openai.videos.create(prompt: "A calico cat playing a piano on stage")

222 

223puts(video)

224```

225 

226#### Response

227 

228```json

229{

230 "id": "video_123",

231 "object": "video",

232 "model": "sora-2",

233 "status": "queued",

234 "progress": 0,

235 "created_at": 1712697600,

236 "size": "1024x1792",

237 "seconds": "8",

238 "quality": "standard"

239}

240```

Details

1## Create a new video generation job by editing a source video or existing generated video.

2 

3`videos.edit(**kwargs) -> Video`

4 

5**post** `/videos/edits`

6 

7Create a new video generation job by editing a source video or existing generated video.

8 

9### Parameters

10 

11- `prompt: String`

12 

13 Text prompt that describes how to edit the source video.

14 

15- `video: String | VideoReferenceInputParam{ id}`

16 

17 Reference to the completed video to edit.

18 

19 - `String = String`

20 

21 Reference to the completed video to edit.

22 

23 - `class VideoReferenceInputParam`

24 

25 Reference to the completed video.

26 

27 - `id: String`

28 

29 The identifier of the completed video.

30 

31### Returns

32 

33- `class Video`

34 

35 Structured information describing a generated video job.

36 

37 - `id: String`

38 

39 Unique identifier for the video job.

40 

41 - `completed_at: Integer`

42 

43 Unix timestamp (seconds) for when the job completed, if finished.

44 

45 - `created_at: Integer`

46 

47 Unix timestamp (seconds) for when the job was created.

48 

49 - `error: VideoCreateError`

50 

51 Error payload that explains why generation failed, if applicable.

52 

53 - `code: String`

54 

55 A machine-readable error code that was returned.

56 

57 - `message: String`

58 

59 A human-readable description of the error that was returned.

60 

61 - `expires_at: Integer`

62 

63 Unix timestamp (seconds) for when the downloadable assets expire, if set.

64 

65 - `model: VideoModel`

66 

67 The video generation model that produced the job.

68 

69 - `String = String`

70 

71 - `VideoModel = :"sora-2" | :"sora-2-pro" | :"sora-2-2025-10-06" | 2 more`

72 

73 - `:"sora-2"`

74 

75 - `:"sora-2-pro"`

76 

77 - `:"sora-2-2025-10-06"`

78 

79 - `:"sora-2-pro-2025-10-06"`

80 

81 - `:"sora-2-2025-12-08"`

82 

83 - `object: :video`

84 

85 The object type, which is always `video`.

86 

87 - `:video`

88 

89 - `progress: Integer`

90 

91 Approximate completion percentage for the generation task.

92 

93 - `prompt: String`

94 

95 The prompt that was used to generate the video.

96 

97 - `remixed_from_video_id: String`

98 

99 Identifier of the source video if this video is a remix.

100 

101 - `seconds: String | VideoSeconds`

102 

103 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

104 

105 - `String = String`

106 

107 - `VideoSeconds = :"4" | :"8" | :"12"`

108 

109 - `:"4"`

110 

111 - `:"8"`

112 

113 - `:"12"`

114 

115 - `size: VideoSize`

116 

117 The resolution of the generated video.

118 

119 - `:"720x1280"`

120 

121 - `:"1280x720"`

122 

123 - `:"1024x1792"`

124 

125 - `:"1792x1024"`

126 

127 - `status: :queued | :in_progress | :completed | :failed`

128 

129 Current lifecycle status of the video job.

130 

131 - `:queued`

132 

133 - `:in_progress`

134 

135 - `:completed`

136 

137 - `:failed`

138 

139### Example

140 

141```ruby

142require "openai"

143 

144openai = OpenAI::Client.new(api_key: "My API Key")

145 

146video = openai.videos.edit(prompt: "x", video: StringIO.new("Example data"))

147 

148puts(video)

149```

150 

151#### Response

152 

153```json

154{

155 "id": "id",

156 "completed_at": 0,

157 "created_at": 0,

158 "error": {

159 "code": "code",

160 "message": "message"

161 },

162 "expires_at": 0,

163 "model": "sora-2",

164 "object": "video",

165 "progress": 0,

166 "prompt": "prompt",

167 "remixed_from_video_id": "remixed_from_video_id",

168 "seconds": "4",

169 "size": "720x1280",

170 "status": "queued"

171}

172```

Details

1## Create an extension of a completed video.

2 

3`videos.extend_(**kwargs) -> Video`

4 

5**post** `/videos/extensions`

6 

7Create an extension of a completed video.

8 

9### Parameters

10 

11- `prompt: String`

12 

13 Updated text prompt that directs the extension generation.

14 

15- `seconds: VideoSeconds`

16 

17 Length of the newly generated extension segment in seconds (allowed values: 4, 8, 12, 16, 20).

18 

19 - `:"4"`

20 

21 - `:"8"`

22 

23 - `:"12"`

24 

25- `video: String | VideoReferenceInputParam{ id}`

26 

27 Reference to the completed video to extend.

28 

29 - `String = String`

30 

31 Reference to the completed video to extend.

32 

33 - `class VideoReferenceInputParam`

34 

35 Reference to the completed video.

36 

37 - `id: String`

38 

39 The identifier of the completed video.

40 

41### Returns

42 

43- `class Video`

44 

45 Structured information describing a generated video job.

46 

47 - `id: String`

48 

49 Unique identifier for the video job.

50 

51 - `completed_at: Integer`

52 

53 Unix timestamp (seconds) for when the job completed, if finished.

54 

55 - `created_at: Integer`

56 

57 Unix timestamp (seconds) for when the job was created.

58 

59 - `error: VideoCreateError`

60 

61 Error payload that explains why generation failed, if applicable.

62 

63 - `code: String`

64 

65 A machine-readable error code that was returned.

66 

67 - `message: String`

68 

69 A human-readable description of the error that was returned.

70 

71 - `expires_at: Integer`

72 

73 Unix timestamp (seconds) for when the downloadable assets expire, if set.

74 

75 - `model: VideoModel`

76 

77 The video generation model that produced the job.

78 

79 - `String = String`

80 

81 - `VideoModel = :"sora-2" | :"sora-2-pro" | :"sora-2-2025-10-06" | 2 more`

82 

83 - `:"sora-2"`

84 

85 - `:"sora-2-pro"`

86 

87 - `:"sora-2-2025-10-06"`

88 

89 - `:"sora-2-pro-2025-10-06"`

90 

91 - `:"sora-2-2025-12-08"`

92 

93 - `object: :video`

94 

95 The object type, which is always `video`.

96 

97 - `:video`

98 

99 - `progress: Integer`

100 

101 Approximate completion percentage for the generation task.

102 

103 - `prompt: String`

104 

105 The prompt that was used to generate the video.

106 

107 - `remixed_from_video_id: String`

108 

109 Identifier of the source video if this video is a remix.

110 

111 - `seconds: String | VideoSeconds`

112 

113 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

114 

115 - `String = String`

116 

117 - `VideoSeconds = :"4" | :"8" | :"12"`

118 

119 - `:"4"`

120 

121 - `:"8"`

122 

123 - `:"12"`

124 

125 - `size: VideoSize`

126 

127 The resolution of the generated video.

128 

129 - `:"720x1280"`

130 

131 - `:"1280x720"`

132 

133 - `:"1024x1792"`

134 

135 - `:"1792x1024"`

136 

137 - `status: :queued | :in_progress | :completed | :failed`

138 

139 Current lifecycle status of the video job.

140 

141 - `:queued`

142 

143 - `:in_progress`

144 

145 - `:completed`

146 

147 - `:failed`

148 

149### Example

150 

151```ruby

152require "openai"

153 

154openai = OpenAI::Client.new(api_key: "My API Key")

155 

156video = openai.videos.extend_(prompt: "x", seconds: :"4", video: StringIO.new("Example data"))

157 

158puts(video)

159```

160 

161#### Response

162 

163```json

164{

165 "id": "id",

166 "completed_at": 0,

167 "created_at": 0,

168 "error": {

169 "code": "code",

170 "message": "message"

171 },

172 "expires_at": 0,

173 "model": "sora-2",

174 "object": "video",

175 "progress": 0,

176 "prompt": "prompt",

177 "remixed_from_video_id": "remixed_from_video_id",

178 "seconds": "4",

179 "size": "720x1280",

180 "status": "queued"

181}

182```

Details

1## List videos

2 

3`videos.list(**kwargs) -> ConversationCursorPage<Video>`

4 

5**get** `/videos`

6 

7List recently generated videos for the current project.

8 

9### Parameters

10 

11- `after: String`

12 

13 Identifier for the last item from the previous pagination request

14 

15- `limit: Integer`

16 

17 Number of items to retrieve

18 

19- `order: :asc | :desc`

20 

21 Sort order of results by timestamp. Use `asc` for ascending order or `desc` for descending order.

22 

23 - `:asc`

24 

25 - `:desc`

26 

27### Returns

28 

29- `class Video`

30 

31 Structured information describing a generated video job.

32 

33 - `id: String`

34 

35 Unique identifier for the video job.

36 

37 - `completed_at: Integer`

38 

39 Unix timestamp (seconds) for when the job completed, if finished.

40 

41 - `created_at: Integer`

42 

43 Unix timestamp (seconds) for when the job was created.

44 

45 - `error: VideoCreateError`

46 

47 Error payload that explains why generation failed, if applicable.

48 

49 - `code: String`

50 

51 A machine-readable error code that was returned.

52 

53 - `message: String`

54 

55 A human-readable description of the error that was returned.

56 

57 - `expires_at: Integer`

58 

59 Unix timestamp (seconds) for when the downloadable assets expire, if set.

60 

61 - `model: VideoModel`

62 

63 The video generation model that produced the job.

64 

65 - `String = String`

66 

67 - `VideoModel = :"sora-2" | :"sora-2-pro" | :"sora-2-2025-10-06" | 2 more`

68 

69 - `:"sora-2"`

70 

71 - `:"sora-2-pro"`

72 

73 - `:"sora-2-2025-10-06"`

74 

75 - `:"sora-2-pro-2025-10-06"`

76 

77 - `:"sora-2-2025-12-08"`

78 

79 - `object: :video`

80 

81 The object type, which is always `video`.

82 

83 - `:video`

84 

85 - `progress: Integer`

86 

87 Approximate completion percentage for the generation task.

88 

89 - `prompt: String`

90 

91 The prompt that was used to generate the video.

92 

93 - `remixed_from_video_id: String`

94 

95 Identifier of the source video if this video is a remix.

96 

97 - `seconds: String | VideoSeconds`

98 

99 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

100 

101 - `String = String`

102 

103 - `VideoSeconds = :"4" | :"8" | :"12"`

104 

105 - `:"4"`

106 

107 - `:"8"`

108 

109 - `:"12"`

110 

111 - `size: VideoSize`

112 

113 The resolution of the generated video.

114 

115 - `:"720x1280"`

116 

117 - `:"1280x720"`

118 

119 - `:"1024x1792"`

120 

121 - `:"1792x1024"`

122 

123 - `status: :queued | :in_progress | :completed | :failed`

124 

125 Current lifecycle status of the video job.

126 

127 - `:queued`

128 

129 - `:in_progress`

130 

131 - `:completed`

132 

133 - `:failed`

134 

135### Example

136 

137```ruby

138require "openai"

139 

140openai = OpenAI::Client.new(api_key: "My API Key")

141 

142page = openai.videos.list

143 

144puts(page)

145```

146 

147#### Response

148 

149```json

150{

151 "data": [

152 {

153 "id": "id",

154 "completed_at": 0,

155 "created_at": 0,

156 "error": {

157 "code": "code",

158 "message": "message"

159 },

160 "expires_at": 0,

161 "model": "sora-2",

162 "object": "video",

163 "progress": 0,

164 "prompt": "prompt",

165 "remixed_from_video_id": "remixed_from_video_id",

166 "seconds": "4",

167 "size": "720x1280",

168 "status": "queued"

169 }

170 ],

171 "first_id": "first_id",

172 "has_more": true,

173 "last_id": "last_id",

174 "object": "list"

175}

176```

177 

178### Example

179 

180```ruby

181require "openai"

182 

183openai = OpenAI::Client.new

184 

185page = openai.videos.list

186 

187puts(page)

188```

189 

190#### Response

191 

192```json

193{

194 "data": [

195 {

196 "id": "video_123",

197 "object": "video",

198 "model": "sora-2",

199 "status": "completed"

200 }

201 ],

202 "object": "list"

203}

204```

Details

1## Remix video

2 

3`videos.remix(video_id, **kwargs) -> Video`

4 

5**post** `/videos/{video_id}/remix`

6 

7Create a remix of a completed video using a refreshed prompt.

8 

9### Parameters

10 

11- `video_id: String`

12 

13- `prompt: String`

14 

15 Updated text prompt that directs the remix generation.

16 

17### Returns

18 

19- `class Video`

20 

21 Structured information describing a generated video job.

22 

23 - `id: String`

24 

25 Unique identifier for the video job.

26 

27 - `completed_at: Integer`

28 

29 Unix timestamp (seconds) for when the job completed, if finished.

30 

31 - `created_at: Integer`

32 

33 Unix timestamp (seconds) for when the job was created.

34 

35 - `error: VideoCreateError`

36 

37 Error payload that explains why generation failed, if applicable.

38 

39 - `code: String`

40 

41 A machine-readable error code that was returned.

42 

43 - `message: String`

44 

45 A human-readable description of the error that was returned.

46 

47 - `expires_at: Integer`

48 

49 Unix timestamp (seconds) for when the downloadable assets expire, if set.

50 

51 - `model: VideoModel`

52 

53 The video generation model that produced the job.

54 

55 - `String = String`

56 

57 - `VideoModel = :"sora-2" | :"sora-2-pro" | :"sora-2-2025-10-06" | 2 more`

58 

59 - `:"sora-2"`

60 

61 - `:"sora-2-pro"`

62 

63 - `:"sora-2-2025-10-06"`

64 

65 - `:"sora-2-pro-2025-10-06"`

66 

67 - `:"sora-2-2025-12-08"`

68 

69 - `object: :video`

70 

71 The object type, which is always `video`.

72 

73 - `:video`

74 

75 - `progress: Integer`

76 

77 Approximate completion percentage for the generation task.

78 

79 - `prompt: String`

80 

81 The prompt that was used to generate the video.

82 

83 - `remixed_from_video_id: String`

84 

85 Identifier of the source video if this video is a remix.

86 

87 - `seconds: String | VideoSeconds`

88 

89 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

90 

91 - `String = String`

92 

93 - `VideoSeconds = :"4" | :"8" | :"12"`

94 

95 - `:"4"`

96 

97 - `:"8"`

98 

99 - `:"12"`

100 

101 - `size: VideoSize`

102 

103 The resolution of the generated video.

104 

105 - `:"720x1280"`

106 

107 - `:"1280x720"`

108 

109 - `:"1024x1792"`

110 

111 - `:"1792x1024"`

112 

113 - `status: :queued | :in_progress | :completed | :failed`

114 

115 Current lifecycle status of the video job.

116 

117 - `:queued`

118 

119 - `:in_progress`

120 

121 - `:completed`

122 

123 - `:failed`

124 

125### Example

126 

127```ruby

128require "openai"

129 

130openai = OpenAI::Client.new(api_key: "My API Key")

131 

132video = openai.videos.remix("video_123", prompt: "x")

133 

134puts(video)

135```

136 

137#### Response

138 

139```json

140{

141 "id": "id",

142 "completed_at": 0,

143 "created_at": 0,

144 "error": {

145 "code": "code",

146 "message": "message"

147 },

148 "expires_at": 0,

149 "model": "sora-2",

150 "object": "video",

151 "progress": 0,

152 "prompt": "prompt",

153 "remixed_from_video_id": "remixed_from_video_id",

154 "seconds": "4",

155 "size": "720x1280",

156 "status": "queued"

157}

158```

159 

160### Example

161 

162```ruby

163require "openai"

164 

165openai = OpenAI::Client.new

166 

167video = openai.videos.remix("video_123", prompt: "Extend the scene with the cat taking a bow to the cheering audience")

168 

169puts(video)

170```

171 

172#### Response

173 

174```json

175{

176 "id": "video_456",

177 "object": "video",

178 "model": "sora-2",

179 "status": "queued",

180 "progress": 0,

181 "created_at": 1712698600,

182 "size": "720x1280",

183 "seconds": "8",

184 "remixed_from_video_id": "video_123"

185}

186```

Details

1## Retrieve video

2 

3`videos.retrieve(video_id) -> Video`

4 

5**get** `/videos/{video_id}`

6 

7Fetch the latest metadata for a generated video.

8 

9### Parameters

10 

11- `video_id: String`

12 

13### Returns

14 

15- `class Video`

16 

17 Structured information describing a generated video job.

18 

19 - `id: String`

20 

21 Unique identifier for the video job.

22 

23 - `completed_at: Integer`

24 

25 Unix timestamp (seconds) for when the job completed, if finished.

26 

27 - `created_at: Integer`

28 

29 Unix timestamp (seconds) for when the job was created.

30 

31 - `error: VideoCreateError`

32 

33 Error payload that explains why generation failed, if applicable.

34 

35 - `code: String`

36 

37 A machine-readable error code that was returned.

38 

39 - `message: String`

40 

41 A human-readable description of the error that was returned.

42 

43 - `expires_at: Integer`

44 

45 Unix timestamp (seconds) for when the downloadable assets expire, if set.

46 

47 - `model: VideoModel`

48 

49 The video generation model that produced the job.

50 

51 - `String = String`

52 

53 - `VideoModel = :"sora-2" | :"sora-2-pro" | :"sora-2-2025-10-06" | 2 more`

54 

55 - `:"sora-2"`

56 

57 - `:"sora-2-pro"`

58 

59 - `:"sora-2-2025-10-06"`

60 

61 - `:"sora-2-pro-2025-10-06"`

62 

63 - `:"sora-2-2025-12-08"`

64 

65 - `object: :video`

66 

67 The object type, which is always `video`.

68 

69 - `:video`

70 

71 - `progress: Integer`

72 

73 Approximate completion percentage for the generation task.

74 

75 - `prompt: String`

76 

77 The prompt that was used to generate the video.

78 

79 - `remixed_from_video_id: String`

80 

81 Identifier of the source video if this video is a remix.

82 

83 - `seconds: String | VideoSeconds`

84 

85 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

86 

87 - `String = String`

88 

89 - `VideoSeconds = :"4" | :"8" | :"12"`

90 

91 - `:"4"`

92 

93 - `:"8"`

94 

95 - `:"12"`

96 

97 - `size: VideoSize`

98 

99 The resolution of the generated video.

100 

101 - `:"720x1280"`

102 

103 - `:"1280x720"`

104 

105 - `:"1024x1792"`

106 

107 - `:"1792x1024"`

108 

109 - `status: :queued | :in_progress | :completed | :failed`

110 

111 Current lifecycle status of the video job.

112 

113 - `:queued`

114 

115 - `:in_progress`

116 

117 - `:completed`

118 

119 - `:failed`

120 

121### Example

122 

123```ruby

124require "openai"

125 

126openai = OpenAI::Client.new(api_key: "My API Key")

127 

128video = openai.videos.retrieve("video_123")

129 

130puts(video)

131```

132 

133#### Response

134 

135```json

136{

137 "id": "id",

138 "completed_at": 0,

139 "created_at": 0,

140 "error": {

141 "code": "code",

142 "message": "message"

143 },

144 "expires_at": 0,

145 "model": "sora-2",

146 "object": "video",

147 "progress": 0,

148 "prompt": "prompt",

149 "remixed_from_video_id": "remixed_from_video_id",

150 "seconds": "4",

151 "size": "720x1280",

152 "status": "queued"

153}

154```

155 

156### Example

157 

158```ruby

159require "openai"

160 

161openai = OpenAI::Client.new

162 

163video = openai.videos.retrieve("video_123")

164 

165puts(video)

166```

Details

1## Create speech

2 

3`client.audio.speech.create(SpeechCreateParamsbody, RequestOptionsoptions?): Response`

4 

5**post** `/audio/speech`

6 

7Generates audio from the input text.

8 

9Returns the audio file content, or a stream of audio events.

10 

11### Parameters

12 

13- `body: SpeechCreateParams`

14 

15 - `input: string`

16 

17 The text to generate audio for. The maximum length is 4096 characters.

18 

19 - `model: (string & {}) | SpeechModel`

20 

21 One of the available [TTS models](https://platform.openai.com/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.

22 

23 - `(string & {})`

24 

25 - `SpeechModel = "tts-1" | "tts-1-hd" | "gpt-4o-mini-tts" | "gpt-4o-mini-tts-2025-12-15"`

26 

27 - `"tts-1"`

28 

29 - `"tts-1-hd"`

30 

31 - `"gpt-4o-mini-tts"`

32 

33 - `"gpt-4o-mini-tts-2025-12-15"`

34 

35 - `voice: string | "alloy" | "ash" | "ballad" | 7 more | ID`

36 

37 The voice to use when generating the audio. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, `verse`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ "id": "voice_1234" }`. Previews of the voices are available in the [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).

38 

39 - `string`

40 

41 - `"alloy" | "ash" | "ballad" | 7 more`

42 

43 - `"alloy"`

44 

45 - `"ash"`

46 

47 - `"ballad"`

48 

49 - `"coral"`

50 

51 - `"echo"`

52 

53 - `"sage"`

54 

55 - `"shimmer"`

56 

57 - `"verse"`

58 

59 - `"marin"`

60 

61 - `"cedar"`

62 

63 - `ID`

64 

65 Custom voice reference.

66 

67 - `id: string`

68 

69 The custom voice ID, e.g. `voice_1234`.

70 

71 - `instructions?: string`

72 

73 Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.

74 

75 - `response_format?: "mp3" | "opus" | "aac" | 3 more`

76 

77 The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.

78 

79 - `"mp3"`

80 

81 - `"opus"`

82 

83 - `"aac"`

84 

85 - `"flac"`

86 

87 - `"wav"`

88 

89 - `"pcm"`

90 

91 - `speed?: number`

92 

93 The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.

94 

95 - `stream_format?: "sse" | "audio"`

96 

97 The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.

98 

99 - `"sse"`

100 

101 - `"audio"`

102 

103### Returns

104 

105- `unnamed_schema_8 = Response`

106 

107### Example

108 

109```typescript

110import OpenAI from 'openai';

111 

112const client = new OpenAI({

113 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

114});

115 

116const speech = await client.audio.speech.create({

117 input: 'input',

118 model: 'tts-1',

119 voice: 'alloy',

120});

121 

122console.log(speech);

123 

124const content = await speech.blob();

125console.log(content);

126```

127 

128### Example

129 

130```typescript

131import fs from "fs";

132import path from "path";

133import OpenAI from "openai";

134 

135const openai = new OpenAI();

136 

137const speechFile = path.resolve("./speech.mp3");

138 

139async function main() {

140 const mp3 = await openai.audio.speech.create({

141 model: "gpt-4o-mini-tts",

142 voice: "alloy",

143 input: "Today is a wonderful day to build something people love!",

144 });

145 console.log(speechFile);

146 const buffer = Buffer.from(await mp3.arrayBuffer());

147 await fs.promises.writeFile(speechFile, buffer);

148}

149main();

150```

Details

1## Create transcription

2 

3`client.audio.transcriptions.create(TranscriptionCreateParamsbody, RequestOptionsoptions?): TranscriptionCreateResponse | Stream<TranscriptionStreamEvent>`

4 

5**post** `/audio/transcriptions`

6 

7Transcribes audio into the input language.

8 

9Returns a transcription object in `json`, `diarized_json`, or `verbose_json`

10format, or a stream of transcript events.

11 

12### Parameters

13 

14- `TranscriptionCreateParams = TranscriptionCreateParamsNonStreaming | TranscriptionCreateParamsStreaming`

15 

16 - `TranscriptionCreateParamsBase`

17 

18 - `file: Uploadable`

19 

20 The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.

21 

22 - `model: (string & {}) | AudioModel`

23 

24 ID of the model to use. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1` (which is powered by our open source Whisper V2 model), and `gpt-4o-transcribe-diarize`.

25 

26 - `(string & {})`

27 

28 - `AudioModel = "whisper-1" | "gpt-4o-transcribe" | "gpt-4o-mini-transcribe" | 2 more`

29 

30 - `"whisper-1"`

31 

32 - `"gpt-4o-transcribe"`

33 

34 - `"gpt-4o-mini-transcribe"`

35 

36 - `"gpt-4o-mini-transcribe-2025-12-15"`

37 

38 - `"gpt-4o-transcribe-diarize"`

39 

40 - `chunking_strategy?: "auto" | VadConfig | null`

41 

42 Controls how the audio is cut into chunks. When set to `"auto"`, the server first normalizes loudness and then uses voice activity detection (VAD) to choose boundaries. `server_vad` object can be provided to tweak VAD detection parameters manually. If unset, the audio is transcribed as a single block. Required when using `gpt-4o-transcribe-diarize` for inputs longer than 30 seconds.

43 

44 - `"auto"`

45 

46 - `"auto"`

47 

48 - `VadConfig`

49 

50 - `type: "server_vad"`

51 

52 Must be set to `server_vad` to enable manual chunking using server side VAD.

53 

54 - `"server_vad"`

55 

56 - `prefix_padding_ms?: number`

57 

58 Amount of audio to include before the VAD detected speech (in

59 milliseconds).

60 

61 - `silence_duration_ms?: number`

62 

63 Duration of silence to detect speech stop (in milliseconds).

64 With shorter values the model will respond more quickly,

65 but may jump in on short pauses from the user.

66 

67 - `threshold?: number`

68 

69 Sensitivity threshold (0.0 to 1.0) for voice activity detection. A

70 higher threshold will require louder audio to activate the model, and

71 thus might perform better in noisy environments.

72 

73 - `include?: Array<TranscriptionInclude>`

74 

75 Additional information to include in the transcription response.

76 `logprobs` will return the log probabilities of the tokens in the

77 response to understand the model's confidence in the transcription.

78 `logprobs` only works with response_format set to `json` and only with

79 the models `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is not supported when using `gpt-4o-transcribe-diarize`.

80 

81 - `"logprobs"`

82 

83 - `known_speaker_names?: Array<string>`

84 

85 Optional list of speaker names that correspond to the audio samples provided in `known_speaker_references[]`. Each entry should be a short identifier (for example `customer` or `agent`). Up to 4 speakers are supported.

86 

87 - `known_speaker_references?: Array<string>`

88 

89 Optional list of audio samples (as [data URLs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)) that contain known speaker references matching `known_speaker_names[]`. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported by `file`.

90 

91 - `language?: string`

92 

93 The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format will improve accuracy and latency.

94 

95 - `prompt?: string`

96 

97 An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting) should match the audio language. This field is not supported when using `gpt-4o-transcribe-diarize`.

98 

99 - `response_format?: AudioResponseFormat`

100 

101 The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, `vtt`, or `diarized_json`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`. For `gpt-4o-transcribe-diarize`, the supported formats are `json`, `text`, and `diarized_json`, with `diarized_json` required to receive speaker annotations.

102 

103 - `"json"`

104 

105 - `"text"`

106 

107 - `"srt"`

108 

109 - `"verbose_json"`

110 

111 - `"vtt"`

112 

113 - `"diarized_json"`

114 

115 - `stream?: false | null`

116 

117 If set to true, the model response data will be streamed to the client

118 as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).

119 See the [Streaming section of the Speech-to-Text guide](https://platform.openai.com/docs/guides/speech-to-text?lang=curl#streaming-transcriptions)

120 for more information.

121 

122 Note: Streaming is not supported for the `whisper-1` model and will be ignored.

123 

124 - `false`

125 

126 - `temperature?: number`

127 

128 The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.

129 

130 - `timestamp_granularities?: Array<"word" | "segment">`

131 

132 The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.

133 This option is not available for `gpt-4o-transcribe-diarize`.

134 

135 - `"word"`

136 

137 - `"segment"`

138 

139 - `TranscriptionCreateParamsNonStreaming extends TranscriptionCreateParamsBase`

140 

141 - `stream?: false | null`

142 

143 If set to true, the model response data will be streamed to the client

144 as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).

145 See the [Streaming section of the Speech-to-Text guide](https://platform.openai.com/docs/guides/speech-to-text?lang=curl#streaming-transcriptions)

146 for more information.

147 

148 Note: Streaming is not supported for the `whisper-1` model and will be ignored.

149 

150 - `TranscriptionCreateParamsStreaming extends TranscriptionCreateParamsBase`

151 

152 - `stream: true`

153 

154 If set to true, the model response data will be streamed to the client

155 as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).

156 See the [Streaming section of the Speech-to-Text guide](https://platform.openai.com/docs/guides/speech-to-text?lang=curl#streaming-transcriptions)

157 for more information.

158 

159 Note: Streaming is not supported for the `whisper-1` model and will be ignored.

160 

161 - `true`

162 

163### Returns

164 

165- `TranscriptionCreateResponse = Transcription | TranscriptionDiarized | TranscriptionVerbose`

166 

167 Represents a transcription response returned by model, based on the provided input.

168 

169 - `Transcription`

170 

171 Represents a transcription response returned by model, based on the provided input.

172 

173 - `text: string`

174 

175 The transcribed text.

176 

177 - `logprobs?: Array<Logprob>`

178 

179 The log probabilities of the tokens in the transcription. Only returned with the models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added to the `include` array.

180 

181 - `token?: string`

182 

183 The token in the transcription.

184 

185 - `bytes?: Array<number>`

186 

187 The bytes of the token.

188 

189 - `logprob?: number`

190 

191 The log probability of the token.

192 

193 - `usage?: Tokens | Duration`

194 

195 Token usage statistics for the request.

196 

197 - `Tokens`

198 

199 Usage statistics for models billed by token usage.

200 

201 - `input_tokens: number`

202 

203 Number of input tokens billed for this request.

204 

205 - `output_tokens: number`

206 

207 Number of output tokens generated.

208 

209 - `total_tokens: number`

210 

211 Total number of tokens used (input + output).

212 

213 - `type: "tokens"`

214 

215 The type of the usage object. Always `tokens` for this variant.

216 

217 - `"tokens"`

218 

219 - `input_token_details?: InputTokenDetails`

220 

221 Details about the input tokens billed for this request.

222 

223 - `audio_tokens?: number`

224 

225 Number of audio tokens billed for this request.

226 

227 - `text_tokens?: number`

228 

229 Number of text tokens billed for this request.

230 

231 - `Duration`

232 

233 Usage statistics for models billed by audio input duration.

234 

235 - `seconds: number`

236 

237 Duration of the input audio in seconds.

238 

239 - `type: "duration"`

240 

241 The type of the usage object. Always `duration` for this variant.

242 

243 - `"duration"`

244 

245 - `TranscriptionDiarized`

246 

247 Represents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.

248 

249 - `duration: number`

250 

251 Duration of the input audio in seconds.

252 

253 - `segments: Array<TranscriptionDiarizedSegment>`

254 

255 Segments of the transcript annotated with timestamps and speaker labels.

256 

257 - `id: string`

258 

259 Unique identifier for the segment.

260 

261 - `end: number`

262 

263 End timestamp of the segment in seconds.

264 

265 - `speaker: string`

266 

267 Speaker label for this segment. When known speakers are provided, the label matches `known_speaker_names[]`. Otherwise speakers are labeled sequentially using capital letters (`A`, `B`, ...).

268 

269 - `start: number`

270 

271 Start timestamp of the segment in seconds.

272 

273 - `text: string`

274 

275 Transcript text for this segment.

276 

277 - `type: "transcript.text.segment"`

278 

279 The type of the segment. Always `transcript.text.segment`.

280 

281 - `"transcript.text.segment"`

282 

283 - `task: "transcribe"`

284 

285 The type of task that was run. Always `transcribe`.

286 

287 - `"transcribe"`

288 

289 - `text: string`

290 

291 The concatenated transcript text for the entire audio input.

292 

293 - `usage?: Tokens | Duration`

294 

295 Token or duration usage statistics for the request.

296 

297 - `Tokens`

298 

299 Usage statistics for models billed by token usage.

300 

301 - `input_tokens: number`

302 

303 Number of input tokens billed for this request.

304 

305 - `output_tokens: number`

306 

307 Number of output tokens generated.

308 

309 - `total_tokens: number`

310 

311 Total number of tokens used (input + output).

312 

313 - `type: "tokens"`

314 

315 The type of the usage object. Always `tokens` for this variant.

316 

317 - `"tokens"`

318 

319 - `input_token_details?: InputTokenDetails`

320 

321 Details about the input tokens billed for this request.

322 

323 - `audio_tokens?: number`

324 

325 Number of audio tokens billed for this request.

326 

327 - `text_tokens?: number`

328 

329 Number of text tokens billed for this request.

330 

331 - `Duration`

332 

333 Usage statistics for models billed by audio input duration.

334 

335 - `seconds: number`

336 

337 Duration of the input audio in seconds.

338 

339 - `type: "duration"`

340 

341 The type of the usage object. Always `duration` for this variant.

342 

343 - `"duration"`

344 

345 - `TranscriptionVerbose`

346 

347 Represents a verbose json transcription response returned by model, based on the provided input.

348 

349 - `duration: number`

350 

351 The duration of the input audio.

352 

353 - `language: string`

354 

355 The language of the input audio.

356 

357 - `text: string`

358 

359 The transcribed text.

360 

361 - `segments?: Array<TranscriptionSegment>`

362 

363 Segments of the transcribed text and their corresponding details.

364 

365 - `id: number`

366 

367 Unique identifier of the segment.

368 

369 - `avg_logprob: number`

370 

371 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.

372 

373 - `compression_ratio: number`

374 

375 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.

376 

377 - `end: number`

378 

379 End time of the segment in seconds.

380 

381 - `no_speech_prob: number`

382 

383 Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.

384 

385 - `seek: number`

386 

387 Seek offset of the segment.

388 

389 - `start: number`

390 

391 Start time of the segment in seconds.

392 

393 - `temperature: number`

394 

395 Temperature parameter used for generating the segment.

396 

397 - `text: string`

398 

399 Text content of the segment.

400 

401 - `tokens: Array<number>`

402 

403 Array of token IDs for the text content.

404 

405 - `usage?: Usage`

406 

407 Usage statistics for models billed by audio input duration.

408 

409 - `seconds: number`

410 

411 Duration of the input audio in seconds.

412 

413 - `type: "duration"`

414 

415 The type of the usage object. Always `duration` for this variant.

416 

417 - `"duration"`

418 

419 - `words?: Array<TranscriptionWord>`

420 

421 Extracted words and their corresponding timestamps.

422 

423 - `end: number`

424 

425 End time of the word in seconds.

426 

427 - `start: number`

428 

429 Start time of the word in seconds.

430 

431 - `word: string`

432 

433 The text content of the word.

434 

435### Example

436 

437```typescript

438import fs from 'fs';

439import OpenAI from 'openai';

440 

441const client = new OpenAI({

442 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

443});

444 

445const transcription = await client.audio.transcriptions.create({

446 file: fs.createReadStream('speech.mp3'),

447 model: 'gpt-4o-transcribe',

448});

449 

450console.log(transcription);

451```

452 

453#### Response

454 

455```json

456{

457 "text": "text",

458 "logprobs": [

459 {

460 "token": "token",

461 "bytes": [

462 0

463 ],

464 "logprob": 0

465 }

466 ],

467 "usage": {

468 "input_tokens": 0,

469 "output_tokens": 0,

470 "total_tokens": 0,

471 "type": "tokens",

472 "input_token_details": {

473 "audio_tokens": 0,

474 "text_tokens": 0

475 }

476 }

477}

478```

479 

480### Example

481 

482```typescript

483import fs from "fs";

484import OpenAI from "openai";

485 

486const openai = new OpenAI();

487 

488async function main() {

489 const transcription = await openai.audio.transcriptions.create({

490 file: fs.createReadStream("audio.mp3"),

491 model: "gpt-4o-transcribe",

492 });

493 

494 console.log(transcription.text);

495}

496main();

497```

498 

499#### Response

500 

501```json

502{

503 "text": "Imagine the wildest idea that you've ever had, and you're curious about how it might scale to something that's a 100, a 1,000 times bigger. This is a place where you can get to do that.",

504 "usage": {

505 "type": "tokens",

506 "input_tokens": 14,

507 "input_token_details": {

508 "text_tokens": 0,

509 "audio_tokens": 14

510 },

511 "output_tokens": 45,

512 "total_tokens": 59

513 }

514}

515```

516 

517### Diarization

518 

519```typescript

520import fs from "fs";

521import OpenAI from "openai";

522 

523const openai = new OpenAI();

524 

525const speakerRef = fs.readFileSync("agent.wav").toString("base64");

526 

527const transcript = await openai.audio.transcriptions.create({

528 file: fs.createReadStream("meeting.wav"),

529 model: "gpt-4o-transcribe-diarize",

530 response_format: "diarized_json",

531 chunking_strategy: "auto",

532 extra_body: {

533 known_speaker_names: ["agent"],

534 known_speaker_references: [`data:audio/wav;base64,${speakerRef}`],

535 },

536});

537 

538console.log(transcript.segments);

539```

540 

541#### Response

542 

543```json

544{

545 "task": "transcribe",

546 "duration": 27.4,

547 "text": "Agent: Thanks for calling OpenAI support.\nA: Hi, I'm trying to enable diarization.\nAgent: Happy to walk you through the steps.",

548 "segments": [

549 {

550 "type": "transcript.text.segment",

551 "id": "seg_001",

552 "start": 0.0,

553 "end": 4.7,

554 "text": "Thanks for calling OpenAI support.",

555 "speaker": "agent"

556 },

557 {

558 "type": "transcript.text.segment",

559 "id": "seg_002",

560 "start": 4.7,

561 "end": 11.8,

562 "text": "Hi, I'm trying to enable diarization.",

563 "speaker": "A"

564 },

565 {

566 "type": "transcript.text.segment",

567 "id": "seg_003",

568 "start": 12.1,

569 "end": 18.5,

570 "text": "Happy to walk you through the steps.",

571 "speaker": "agent"

572 }

573 ],

574 "usage": {

575 "type": "duration",

576 "seconds": 27

577 }

578}

579```

580 

581### Streaming

582 

583```typescript

584import fs from "fs";

585import OpenAI from "openai";

586 

587const openai = new OpenAI();

588 

589const stream = await openai.audio.transcriptions.create({

590 file: fs.createReadStream("audio.mp3"),

591 model: "gpt-4o-mini-transcribe",

592 stream: true,

593});

594 

595for await (const event of stream) {

596 console.log(event);

597}

598```

599 

600#### Response

601 

602```json

603data: {"type":"transcript.text.delta","delta":"I","logprobs":[{"token":"I","logprob":-0.00007588794,"bytes":[73]}]}

604 

605data: {"type":"transcript.text.delta","delta":" see","logprobs":[{"token":" see","logprob":-3.1281633e-7,"bytes":[32,115,101,101]}]}

606 

607data: {"type":"transcript.text.delta","delta":" skies","logprobs":[{"token":" skies","logprob":-2.3392786e-6,"bytes":[32,115,107,105,101,115]}]}

608 

609data: {"type":"transcript.text.delta","delta":" of","logprobs":[{"token":" of","logprob":-3.1281633e-7,"bytes":[32,111,102]}]}

610 

611data: {"type":"transcript.text.delta","delta":" blue","logprobs":[{"token":" blue","logprob":-1.0280384e-6,"bytes":[32,98,108,117,101]}]}

612 

613data: {"type":"transcript.text.delta","delta":" and","logprobs":[{"token":" and","logprob":-0.0005108566,"bytes":[32,97,110,100]}]}

614 

615data: {"type":"transcript.text.delta","delta":" clouds","logprobs":[{"token":" clouds","logprob":-1.9361265e-7,"bytes":[32,99,108,111,117,100,115]}]}

616 

617data: {"type":"transcript.text.delta","delta":" of","logprobs":[{"token":" of","logprob":-1.9361265e-7,"bytes":[32,111,102]}]}

618 

619data: {"type":"transcript.text.delta","delta":" white","logprobs":[{"token":" white","logprob":-7.89631e-7,"bytes":[32,119,104,105,116,101]}]}

620 

621data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.0014890312,"bytes":[44]}]}

622 

623data: {"type":"transcript.text.delta","delta":" the","logprobs":[{"token":" the","logprob":-0.0110956915,"bytes":[32,116,104,101]}]}

624 

625data: {"type":"transcript.text.delta","delta":" bright","logprobs":[{"token":" bright","logprob":0.0,"bytes":[32,98,114,105,103,104,116]}]}

626 

627data: {"type":"transcript.text.delta","delta":" blessed","logprobs":[{"token":" blessed","logprob":-0.000045848617,"bytes":[32,98,108,101,115,115,101,100]}]}

628 

629data: {"type":"transcript.text.delta","delta":" days","logprobs":[{"token":" days","logprob":-0.000010802739,"bytes":[32,100,97,121,115]}]}

630 

631data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.00001700133,"bytes":[44]}]}

632 

633data: {"type":"transcript.text.delta","delta":" the","logprobs":[{"token":" the","logprob":-0.0000118755715,"bytes":[32,116,104,101]}]}

634 

635data: {"type":"transcript.text.delta","delta":" dark","logprobs":[{"token":" dark","logprob":-5.5122365e-7,"bytes":[32,100,97,114,107]}]}

636 

637data: {"type":"transcript.text.delta","delta":" sacred","logprobs":[{"token":" sacred","logprob":-5.4385737e-6,"bytes":[32,115,97,99,114,101,100]}]}

638 

639data: {"type":"transcript.text.delta","delta":" nights","logprobs":[{"token":" nights","logprob":-4.00813e-6,"bytes":[32,110,105,103,104,116,115]}]}

640 

641data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.0036910512,"bytes":[44]}]}

642 

643data: {"type":"transcript.text.delta","delta":" and","logprobs":[{"token":" and","logprob":-0.0031903093,"bytes":[32,97,110,100]}]}

644 

645data: {"type":"transcript.text.delta","delta":" I","logprobs":[{"token":" I","logprob":-1.504853e-6,"bytes":[32,73]}]}

646 

647data: {"type":"transcript.text.delta","delta":" think","logprobs":[{"token":" think","logprob":-4.3202e-7,"bytes":[32,116,104,105,110,107]}]}

648 

649data: {"type":"transcript.text.delta","delta":" to","logprobs":[{"token":" to","logprob":-1.9361265e-7,"bytes":[32,116,111]}]}

650 

651data: {"type":"transcript.text.delta","delta":" myself","logprobs":[{"token":" myself","logprob":-1.7432603e-6,"bytes":[32,109,121,115,101,108,102]}]}

652 

653data: {"type":"transcript.text.delta","delta":",","logprobs":[{"token":",","logprob":-0.29254505,"bytes":[44]}]}

654 

655data: {"type":"transcript.text.delta","delta":" what","logprobs":[{"token":" what","logprob":-0.016815351,"bytes":[32,119,104,97,116]}]}

656 

657data: {"type":"transcript.text.delta","delta":" a","logprobs":[{"token":" a","logprob":-3.1281633e-7,"bytes":[32,97]}]}

658 

659data: {"type":"transcript.text.delta","delta":" wonderful","logprobs":[{"token":" wonderful","logprob":-2.1008714e-6,"bytes":[32,119,111,110,100,101,114,102,117,108]}]}

660 

661data: {"type":"transcript.text.delta","delta":" world","logprobs":[{"token":" world","logprob":-8.180258e-6,"bytes":[32,119,111,114,108,100]}]}

662 

663data: {"type":"transcript.text.delta","delta":".","logprobs":[{"token":".","logprob":-0.014231676,"bytes":[46]}]}

664 

665data: {"type":"transcript.text.done","text":"I see skies of blue and clouds of white, the bright blessed days, the dark sacred nights, and I think to myself, what a wonderful world.","logprobs":[{"token":"I","logprob":-0.00007588794,"bytes":[73]},{"token":" see","logprob":-3.1281633e-7,"bytes":[32,115,101,101]},{"token":" skies","logprob":-2.3392786e-6,"bytes":[32,115,107,105,101,115]},{"token":" of","logprob":-3.1281633e-7,"bytes":[32,111,102]},{"token":" blue","logprob":-1.0280384e-6,"bytes":[32,98,108,117,101]},{"token":" and","logprob":-0.0005108566,"bytes":[32,97,110,100]},{"token":" clouds","logprob":-1.9361265e-7,"bytes":[32,99,108,111,117,100,115]},{"token":" of","logprob":-1.9361265e-7,"bytes":[32,111,102]},{"token":" white","logprob":-7.89631e-7,"bytes":[32,119,104,105,116,101]},{"token":",","logprob":-0.0014890312,"bytes":[44]},{"token":" the","logprob":-0.0110956915,"bytes":[32,116,104,101]},{"token":" bright","logprob":0.0,"bytes":[32,98,114,105,103,104,116]},{"token":" blessed","logprob":-0.000045848617,"bytes":[32,98,108,101,115,115,101,100]},{"token":" days","logprob":-0.000010802739,"bytes":[32,100,97,121,115]},{"token":",","logprob":-0.00001700133,"bytes":[44]},{"token":" the","logprob":-0.0000118755715,"bytes":[32,116,104,101]},{"token":" dark","logprob":-5.5122365e-7,"bytes":[32,100,97,114,107]},{"token":" sacred","logprob":-5.4385737e-6,"bytes":[32,115,97,99,114,101,100]},{"token":" nights","logprob":-4.00813e-6,"bytes":[32,110,105,103,104,116,115]},{"token":",","logprob":-0.0036910512,"bytes":[44]},{"token":" and","logprob":-0.0031903093,"bytes":[32,97,110,100]},{"token":" I","logprob":-1.504853e-6,"bytes":[32,73]},{"token":" think","logprob":-4.3202e-7,"bytes":[32,116,104,105,110,107]},{"token":" to","logprob":-1.9361265e-7,"bytes":[32,116,111]},{"token":" myself","logprob":-1.7432603e-6,"bytes":[32,109,121,115,101,108,102]},{"token":",","logprob":-0.29254505,"bytes":[44]},{"token":" what","logprob":-0.016815351,"bytes":[32,119,104,97,116]},{"token":" a","logprob":-3.1281633e-7,"bytes":[32,97]},{"token":" wonderful","logprob":-2.1008714e-6,"bytes":[32,119,111,110,100,101,114,102,117,108]},{"token":" world","logprob":-8.180258e-6,"bytes":[32,119,111,114,108,100]},{"token":".","logprob":-0.014231676,"bytes":[46]}],"usage":{"input_tokens":14,"input_token_details":{"text_tokens":0,"audio_tokens":14},"output_tokens":45,"total_tokens":59}}

666```

667 

668### Logprobs

669 

670```typescript

671import fs from "fs";

672import OpenAI from "openai";

673 

674const openai = new OpenAI();

675 

676async function main() {

677 const transcription = await openai.audio.transcriptions.create({

678 file: fs.createReadStream("audio.mp3"),

679 model: "gpt-4o-transcribe",

680 response_format: "json",

681 include: ["logprobs"]

682 });

683 

684 console.log(transcription);

685}

686main();

687```

688 

689#### Response

690 

691```json

692{

693 "text": "Hey, my knee is hurting and I want to see the doctor tomorrow ideally.",

694 "logprobs": [

695 { "token": "Hey", "logprob": -1.0415299, "bytes": [72, 101, 121] },

696 { "token": ",", "logprob": -9.805982e-5, "bytes": [44] },

697 { "token": " my", "logprob": -0.00229799, "bytes": [32, 109, 121] },

698 {

699 "token": " knee",

700 "logprob": -4.7159858e-5,

701 "bytes": [32, 107, 110, 101, 101]

702 },

703 { "token": " is", "logprob": -0.043909557, "bytes": [32, 105, 115] },

704 {

705 "token": " hurting",

706 "logprob": -1.1041146e-5,

707 "bytes": [32, 104, 117, 114, 116, 105, 110, 103]

708 },

709 { "token": " and", "logprob": -0.011076359, "bytes": [32, 97, 110, 100] },

710 { "token": " I", "logprob": -5.3193703e-6, "bytes": [32, 73] },

711 {

712 "token": " want",

713 "logprob": -0.0017156356,

714 "bytes": [32, 119, 97, 110, 116]

715 },

716 { "token": " to", "logprob": -7.89631e-7, "bytes": [32, 116, 111] },

717 { "token": " see", "logprob": -5.5122365e-7, "bytes": [32, 115, 101, 101] },

718 { "token": " the", "logprob": -0.0040786397, "bytes": [32, 116, 104, 101] },

719 {

720 "token": " doctor",

721 "logprob": -2.3392786e-6,

722 "bytes": [32, 100, 111, 99, 116, 111, 114]

723 },

724 {

725 "token": " tomorrow",

726 "logprob": -7.89631e-7,

727 "bytes": [32, 116, 111, 109, 111, 114, 114, 111, 119]

728 },

729 {

730 "token": " ideally",

731 "logprob": -0.5800861,

732 "bytes": [32, 105, 100, 101, 97, 108, 108, 121]

733 },

734 { "token": ".", "logprob": -0.00011093382, "bytes": [46] }

735 ],

736 "usage": {

737 "type": "tokens",

738 "input_tokens": 14,

739 "input_token_details": {

740 "text_tokens": 0,

741 "audio_tokens": 14

742 },

743 "output_tokens": 45,

744 "total_tokens": 59

745 }

746}

747```

748 

749### Word timestamps

750 

751```typescript

752import fs from "fs";

753import OpenAI from "openai";

754 

755const openai = new OpenAI();

756 

757async function main() {

758 const transcription = await openai.audio.transcriptions.create({

759 file: fs.createReadStream("audio.mp3"),

760 model: "whisper-1",

761 response_format: "verbose_json",

762 timestamp_granularities: ["word"]

763 });

764 

765 console.log(transcription.text);

766}

767main();

768```

769 

770#### Response

771 

772```json

773{

774 "task": "transcribe",

775 "language": "english",

776 "duration": 8.470000267028809,

777 "text": "The beach was a popular spot on a hot summer day. People were swimming in the ocean, building sandcastles, and playing beach volleyball.",

778 "words": [

779 {

780 "word": "The",

781 "start": 0.0,

782 "end": 0.23999999463558197

783 },

784 ...

785 {

786 "word": "volleyball",

787 "start": 7.400000095367432,

788 "end": 7.900000095367432

789 }

790 ],

791 "usage": {

792 "type": "duration",

793 "seconds": 9

794 }

795}

796```

797 

798### Segment timestamps

799 

800```typescript

801import fs from "fs";

802import OpenAI from "openai";

803 

804const openai = new OpenAI();

805 

806async function main() {

807 const transcription = await openai.audio.transcriptions.create({

808 file: fs.createReadStream("audio.mp3"),

809 model: "whisper-1",

810 response_format: "verbose_json",

811 timestamp_granularities: ["segment"]

812 });

813 

814 console.log(transcription.text);

815}

816main();

817```

818 

819#### Response

820 

821```json

822{

823 "task": "transcribe",

824 "language": "english",

825 "duration": 8.470000267028809,

826 "text": "The beach was a popular spot on a hot summer day. People were swimming in the ocean, building sandcastles, and playing beach volleyball.",

827 "segments": [

828 {

829 "id": 0,

830 "seek": 0,

831 "start": 0.0,

832 "end": 3.319999933242798,

833 "text": " The beach was a popular spot on a hot summer day.",

834 "tokens": [

835 50364, 440, 7534, 390, 257, 3743, 4008, 322, 257, 2368, 4266, 786, 13, 50530

836 ],

837 "temperature": 0.0,

838 "avg_logprob": -0.2860786020755768,

839 "compression_ratio": 1.2363636493682861,

840 "no_speech_prob": 0.00985979475080967

841 },

842 ...

843 ],

844 "usage": {

845 "type": "duration",

846 "seconds": 9

847 }

848}

849```

Details

1## Create translation

2 

3`client.audio.translations.create(TranslationCreateParamsbody, RequestOptionsoptions?): TranslationCreateResponse`

4 

5**post** `/audio/translations`

6 

7Translates audio into English.

8 

9### Parameters

10 

11- `body: TranslationCreateParams`

12 

13 - `file: Uploadable`

14 

15 The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.

16 

17 - `model: (string & {}) | AudioModel`

18 

19 ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.

20 

21 - `(string & {})`

22 

23 - `AudioModel = "whisper-1" | "gpt-4o-transcribe" | "gpt-4o-mini-transcribe" | 2 more`

24 

25 - `"whisper-1"`

26 

27 - `"gpt-4o-transcribe"`

28 

29 - `"gpt-4o-mini-transcribe"`

30 

31 - `"gpt-4o-mini-transcribe-2025-12-15"`

32 

33 - `"gpt-4o-transcribe-diarize"`

34 

35 - `prompt?: string`

36 

37 An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting) should be in English.

38 

39 - `response_format?: "json" | "text" | "srt" | 2 more`

40 

41 The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.

42 

43 - `"json"`

44 

45 - `"text"`

46 

47 - `"srt"`

48 

49 - `"verbose_json"`

50 

51 - `"vtt"`

52 

53 - `temperature?: number`

54 

55 The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit.

56 

57### Returns

58 

59- `TranslationCreateResponse = Translation | TranslationVerbose`

60 

61 - `Translation`

62 

63 - `text: string`

64 

65 - `TranslationVerbose`

66 

67 - `duration: number`

68 

69 The duration of the input audio.

70 

71 - `language: string`

72 

73 The language of the output translation (always `english`).

74 

75 - `text: string`

76 

77 The translated text.

78 

79 - `segments?: Array<TranscriptionSegment>`

80 

81 Segments of the translated text and their corresponding details.

82 

83 - `id: number`

84 

85 Unique identifier of the segment.

86 

87 - `avg_logprob: number`

88 

89 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.

90 

91 - `compression_ratio: number`

92 

93 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.

94 

95 - `end: number`

96 

97 End time of the segment in seconds.

98 

99 - `no_speech_prob: number`

100 

101 Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent.

102 

103 - `seek: number`

104 

105 Seek offset of the segment.

106 

107 - `start: number`

108 

109 Start time of the segment in seconds.

110 

111 - `temperature: number`

112 

113 Temperature parameter used for generating the segment.

114 

115 - `text: string`

116 

117 Text content of the segment.

118 

119 - `tokens: Array<number>`

120 

121 Array of token IDs for the text content.

122 

123### Example

124 

125```typescript

126import fs from 'fs';

127import OpenAI from 'openai';

128 

129const client = new OpenAI({

130 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

131});

132 

133const translation = await client.audio.translations.create({

134 file: fs.createReadStream('speech.mp3'),

135 model: 'whisper-1',

136});

137 

138console.log(translation);

139```

140 

141#### Response

142 

143```json

144{

145 "text": "text"

146}

147```

148 

149### Example

150 

151```typescript

152import fs from "fs";

153import OpenAI from "openai";

154 

155const openai = new OpenAI();

156 

157async function main() {

158 const translation = await openai.audio.translations.create({

159 file: fs.createReadStream("speech.mp3"),

160 model: "whisper-1",

161 });

162 

163 console.log(translation.text);

164}

165main();

166```

167 

168#### Response

169 

170```json

171{

172 "text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"

173}

174```

Details

1## Create completion

2 

3`client.completions.create(CompletionCreateParamsbody, RequestOptionsoptions?): Completion | Stream<Completion>`

4 

5**post** `/completions`

6 

7Creates a completion for the provided prompt and parameters.

8 

9Returns a completion object, or a sequence of completion objects if the request is streamed.

10 

11### Parameters

12 

13- `CompletionCreateParams = CompletionCreateParamsNonStreaming | CompletionCreateParamsStreaming`

14 

15 - `CompletionCreateParamsBase`

16 

17 - `model: (string & {}) | "gpt-3.5-turbo-instruct" | "davinci-002" | "babbage-002"`

18 

19 ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them.

20 

21 - `(string & {})`

22 

23 - `"gpt-3.5-turbo-instruct" | "davinci-002" | "babbage-002"`

24 

25 - `"gpt-3.5-turbo-instruct"`

26 

27 - `"davinci-002"`

28 

29 - `"babbage-002"`

30 

31 - `prompt: string | Array<string> | Array<number> | Array<Array<number>> | null`

32 

33 The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.

34 

35 Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.

36 

37 - `string`

38 

39 - `Array<string>`

40 

41 - `Array<number>`

42 

43 - `Array<Array<number>>`

44 

45 - `best_of?: number | null`

46 

47 Generates `best_of` completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed.

48 

49 When used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`.

50 

51 **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.

52 

53 - `echo?: boolean | null`

54 

55 Echo back the prompt in addition to the completion

56 

57 - `frequency_penalty?: number | null`

58 

59 Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

60 

61 [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)

62 

63 - `logit_bias?: Record<string, number> | null`

64 

65 Modify the likelihood of specified tokens appearing in the completion.

66 

67 Accepts a JSON object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.

68 

69 As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token from being generated.

70 

71 - `logprobs?: number | null`

72 

73 Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response.

74 

75 The maximum value for `logprobs` is 5.

76 

77 - `max_tokens?: number | null`

78 

79 The maximum number of [tokens](/tokenizer) that can be generated in the completion.

80 

81 The token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens.

82 

83 - `n?: number | null`

84 

85 How many completions to generate for each prompt.

86 

87 **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`.

88 

89 - `presence_penalty?: number | null`

90 

91 Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

92 

93 [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)

94 

95 - `seed?: number | null`

96 

97 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.

98 

99 Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.

100 

101 - `stop?: string | null | Array<string>`

102 

103 Not supported with latest reasoning models `o3` and `o4-mini`.

104 

105 Up to 4 sequences where the API will stop generating further tokens. The

106 returned text will not contain the stop sequence.

107 

108 - `string | null`

109 

110 - `Array<string>`

111 

112 - `stream?: false | null`

113 

114 Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).

115 

116 - `false`

117 

118 - `stream_options?: ChatCompletionStreamOptions | null`

119 

120 Options for streaming response. Only set this when you set `stream: true`.

121 

122 - `include_obfuscation?: boolean`

123 

124 When true, stream obfuscation will be enabled. Stream obfuscation adds

125 random characters to an `obfuscation` field on streaming delta events to

126 normalize payload sizes as a mitigation to certain side-channel attacks.

127 These obfuscation fields are included by default, but add a small amount

128 of overhead to the data stream. You can set `include_obfuscation` to

129 false to optimize for bandwidth if you trust the network links between

130 your application and the OpenAI API.

131 

132 - `include_usage?: boolean`

133 

134 If set, an additional chunk will be streamed before the `data: [DONE]`

135 message. The `usage` field on this chunk shows the token usage statistics

136 for the entire request, and the `choices` field will always be an empty

137 array.

138 

139 All other chunks will also include a `usage` field, but with a null

140 value. **NOTE:** If the stream is interrupted, you may not receive the

141 final usage chunk which contains the total token usage for the request.

142 

143 - `suffix?: string | null`

144 

145 The suffix that comes after a completion of inserted text.

146 

147 This parameter is only supported for `gpt-3.5-turbo-instruct`.

148 

149 - `temperature?: number | null`

150 

151 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.

152 

153 We generally recommend altering this or `top_p` but not both.

154 

155 - `top_p?: number | null`

156 

157 An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

158 

159 We generally recommend altering this or `temperature` but not both.

160 

161 - `user?: string`

162 

163 A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

164 

165 - `CompletionCreateParamsNonStreaming extends CompletionCreateParamsBase`

166 

167 - `stream?: false | null`

168 

169 Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).

170 

171 - `CompletionCreateParamsStreaming extends CompletionCreateParamsBase`

172 

173 - `stream: true`

174 

175 Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).

176 

177 - `true`

178 

179### Returns

180 

181- `Completion`

182 

183 Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint).

184 

185 - `id: string`

186 

187 A unique identifier for the completion.

188 

189 - `choices: Array<CompletionChoice>`

190 

191 The list of completion choices the model generated for the input prompt.

192 

193 - `finish_reason: "stop" | "length" | "content_filter"`

194 

195 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,

196 `length` if the maximum number of tokens specified in the request was reached,

197 or `content_filter` if content was omitted due to a flag from our content filters.

198 

199 - `"stop"`

200 

201 - `"length"`

202 

203 - `"content_filter"`

204 

205 - `index: number`

206 

207 - `logprobs: Logprobs | null`

208 

209 - `text_offset?: Array<number>`

210 

211 - `token_logprobs?: Array<number>`

212 

213 - `tokens?: Array<string>`

214 

215 - `top_logprobs?: Array<Record<string, number>>`

216 

217 - `text: string`

218 

219 - `created: number`

220 

221 The Unix timestamp (in seconds) of when the completion was created.

222 

223 - `model: string`

224 

225 The model used for completion.

226 

227 - `object: "text_completion"`

228 

229 The object type, which is always "text_completion"

230 

231 - `"text_completion"`

232 

233 - `system_fingerprint?: string`

234 

235 This fingerprint represents the backend configuration that the model runs with.

236 

237 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.

238 

239 - `usage?: CompletionUsage`

240 

241 Usage statistics for the completion request.

242 

243 - `completion_tokens: number`

244 

245 Number of tokens in the generated completion.

246 

247 - `prompt_tokens: number`

248 

249 Number of tokens in the prompt.

250 

251 - `total_tokens: number`

252 

253 Total number of tokens used in the request (prompt + completion).

254 

255 - `completion_tokens_details?: CompletionTokensDetails`

256 

257 Breakdown of tokens used in a completion.

258 

259 - `accepted_prediction_tokens?: number`

260 

261 When using Predicted Outputs, the number of tokens in the

262 prediction that appeared in the completion.

263 

264 - `audio_tokens?: number`

265 

266 Audio input tokens generated by the model.

267 

268 - `reasoning_tokens?: number`

269 

270 Tokens generated by the model for reasoning.

271 

272 - `rejected_prediction_tokens?: number`

273 

274 When using Predicted Outputs, the number of tokens in the

275 prediction that did not appear in the completion. However, like

276 reasoning tokens, these tokens are still counted in the total

277 completion tokens for purposes of billing, output, and context window

278 limits.

279 

280 - `prompt_tokens_details?: PromptTokensDetails`

281 

282 Breakdown of tokens used in the prompt.

283 

284 - `audio_tokens?: number`

285 

286 Audio input tokens present in the prompt.

287 

288 - `cached_tokens?: number`

289 

290 Cached tokens present in the prompt.

291 

292### Example

293 

294```typescript

295import OpenAI from 'openai';

296 

297const client = new OpenAI({

298 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

299});

300 

301const completion = await client.completions.create({

302 model: 'gpt-3.5-turbo-instruct',

303 prompt: 'This is a test.',

304});

305 

306console.log(completion);

307```

308 

309#### Response

310 

311```json

312{

313 "id": "id",

314 "choices": [

315 {

316 "finish_reason": "stop",

317 "index": 0,

318 "logprobs": {

319 "text_offset": [

320 0

321 ],

322 "token_logprobs": [

323 0

324 ],

325 "tokens": [

326 "string"

327 ],

328 "top_logprobs": [

329 {

330 "foo": 0

331 }

332 ]

333 },

334 "text": "text"

335 }

336 ],

337 "created": 0,

338 "model": "model",

339 "object": "text_completion",

340 "system_fingerprint": "system_fingerprint",

341 "usage": {

342 "completion_tokens": 0,

343 "prompt_tokens": 0,

344 "total_tokens": 0,

345 "completion_tokens_details": {

346 "accepted_prediction_tokens": 0,

347 "audio_tokens": 0,

348 "reasoning_tokens": 0,

349 "rejected_prediction_tokens": 0

350 },

351 "prompt_tokens_details": {

352 "audio_tokens": 0,

353 "cached_tokens": 0

354 }

355 }

356}

357```

358 

359### No streaming

360 

361```typescript

362import OpenAI from "openai";

363 

364const openai = new OpenAI();

365 

366async function main() {

367 const completion = await openai.completions.create({

368 model: "VAR_completion_model_id",

369 prompt: "Say this is a test.",

370 max_tokens: 7,

371 temperature: 0,

372 });

373 

374 console.log(completion);

375}

376main();

377```

378 

379#### Response

380 

381```json

382{

383 "id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",

384 "object": "text_completion",

385 "created": 1589478378,

386 "model": "VAR_completion_model_id",

387 "system_fingerprint": "fp_44709d6fcb",

388 "choices": [

389 {

390 "text": "\n\nThis is indeed a test",

391 "index": 0,

392 "logprobs": null,

393 "finish_reason": "length"

394 }

395 ],

396 "usage": {

397 "prompt_tokens": 5,

398 "completion_tokens": 7,

399 "total_tokens": 12

400 }

401}

402```

403 

404### Streaming

405 

406```typescript

407import OpenAI from "openai";

408 

409const openai = new OpenAI();

410 

411async function main() {

412 const stream = await openai.completions.create({

413 model: "VAR_completion_model_id",

414 prompt: "Say this is a test.",

415 stream: true,

416 });

417 

418 for await (const chunk of stream) {

419 console.log(chunk.choices[0].text)

420 }

421}

422main();

423```

424 

425#### Response

426 

427```json

428{

429 "id": "cmpl-7iA7iJjj8V2zOkCGvWF2hAkDWBQZe",

430 "object": "text_completion",

431 "created": 1690759702,

432 "choices": [

433 {

434 "text": "This",

435 "index": 0,

436 "logprobs": null,

437 "finish_reason": null

438 }

439 ],

440 "model": "gpt-3.5-turbo-instruct"

441 "system_fingerprint": "fp_44709d6fcb",

442}

443```

Details

1## Create container file

2 

3`client.containers.files.create(stringcontainerID, FileCreateParamsbody, RequestOptionsoptions?): FileCreateResponse`

4 

5**post** `/containers/{container_id}/files`

6 

7Create a Container File

8 

9You can send either a multipart/form-data request with the raw file content, or a JSON request with a file ID.

10 

11### Parameters

12 

13- `containerID: string`

14 

15- `body: FileCreateParams`

16 

17 - `file?: Uploadable`

18 

19 The File object (not file name) to be uploaded.

20 

21 - `file_id?: string`

22 

23 Name of the file to create.

24 

25### Returns

26 

27- `FileCreateResponse`

28 

29 - `id: string`

30 

31 Unique identifier for the file.

32 

33 - `bytes: number`

34 

35 Size of the file in bytes.

36 

37 - `container_id: string`

38 

39 The container this file belongs to.

40 

41 - `created_at: number`

42 

43 Unix timestamp (in seconds) when the file was created.

44 

45 - `object: "container.file"`

46 

47 The type of this object (`container.file`).

48 

49 - `"container.file"`

50 

51 - `path: string`

52 

53 Path of the file in the container.

54 

55 - `source: string`

56 

57 Source of the file (e.g., `user`, `assistant`).

58 

59### Example

60 

61```typescript

62import fs from 'fs';

63import OpenAI from 'openai';

64 

65const client = new OpenAI({

66 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

67});

68 

69const file = await client.containers.files.create('container_id');

70 

71console.log(file.id);

72```

73 

74#### Response

75 

76```json

77{

78 "id": "id",

79 "bytes": 0,

80 "container_id": "container_id",

81 "created_at": 0,

82 "object": "container.file",

83 "path": "path",

84 "source": "source"

85}

86```

Details

1## Upload file

2 

3`client.files.create(FileCreateParamsbody, RequestOptionsoptions?): FileObject`

4 

5**post** `/files`

6 

7Upload a file that can be used across various endpoints. Individual files

8can be up to 512 MB, and each project can store up to 2.5 TB of files in

9total. There is no organization-wide storage limit. Uploads to this

10endpoint are rate-limited to 1,000 requests per minute per authenticated

11user.

12 

13- The Assistants API supports files up to 2 million tokens and of specific

14 file types. See the [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for

15 details.

16- The Fine-tuning API only supports `.jsonl` files. The input also has

17 certain required formats for fine-tuning

18 [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or

19 [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input) models.

20- The Batch API only supports `.jsonl` files up to 200 MB in size. The input

21 also has a specific required

22 [format](https://platform.openai.com/docs/api-reference/batch/request-input).

23- For Retrieval or `file_search` ingestion, upload files here first. If

24 you need to attach multiple uploaded files to the same vector store, use

25 [`/vector_stores/{vector_store_id}/file_batches`](https://platform.openai.com/docs/api-reference/vector-stores-file-batches/createBatch)

26 instead of attaching them one by one. Vector store attachment has separate

27 limits from file upload, including 2,000 attached files per minute per

28 organization.

29 

30Please [contact us](https://help.openai.com/) if you need to increase these

31storage limits.

32 

33### Parameters

34 

35- `body: FileCreateParams`

36 

37 - `file: Uploadable`

38 

39 The File object (not file name) to be uploaded.

40 

41 - `purpose: FilePurpose`

42 

43 The intended purpose of the uploaded file. One of:

44 

45 - `assistants`: Used in the Assistants API

46 - `batch`: Used in the Batch API

47 - `fine-tune`: Used for fine-tuning

48 - `vision`: Images used for vision fine-tuning

49 - `user_data`: Flexible file type for any purpose

50 - `evals`: Used for eval data sets

51 

52 - `"assistants"`

53 

54 - `"batch"`

55 

56 - `"fine-tune"`

57 

58 - `"vision"`

59 

60 - `"user_data"`

61 

62 - `"evals"`

63 

64 - `expires_after?: ExpiresAfter`

65 

66 The expiration policy for a file. By default, files with `purpose=batch` expire after 30 days and all other files are persisted until they are manually deleted.

67 

68 - `anchor: "created_at"`

69 

70 Anchor timestamp after which the expiration policy applies. Supported anchors: `created_at`.

71 

72 - `"created_at"`

73 

74 - `seconds: number`

75 

76 The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).

77 

78### Returns

79 

80- `FileObject`

81 

82 The `File` object represents a document that has been uploaded to OpenAI.

83 

84 - `id: string`

85 

86 The file identifier, which can be referenced in the API endpoints.

87 

88 - `bytes: number`

89 

90 The size of the file, in bytes.

91 

92 - `created_at: number`

93 

94 The Unix timestamp (in seconds) for when the file was created.

95 

96 - `filename: string`

97 

98 The name of the file.

99 

100 - `object: "file"`

101 

102 The object type, which is always `file`.

103 

104 - `"file"`

105 

106 - `purpose: "assistants" | "assistants_output" | "batch" | 5 more`

107 

108 The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.

109 

110 - `"assistants"`

111 

112 - `"assistants_output"`

113 

114 - `"batch"`

115 

116 - `"batch_output"`

117 

118 - `"fine-tune"`

119 

120 - `"fine-tune-results"`

121 

122 - `"vision"`

123 

124 - `"user_data"`

125 

126 - `status: "uploaded" | "processed" | "error"`

127 

128 Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.

129 

130 - `"uploaded"`

131 

132 - `"processed"`

133 

134 - `"error"`

135 

136 - `expires_at?: number`

137 

138 The Unix timestamp (in seconds) for when the file will expire.

139 

140 - `status_details?: string`

141 

142 Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.

143 

144### Example

145 

146```typescript

147import fs from 'fs';

148import OpenAI from 'openai';

149 

150const client = new OpenAI({

151 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

152});

153 

154const fileObject = await client.files.create({

155 file: fs.createReadStream('fine-tune.jsonl'),

156 purpose: 'assistants',

157});

158 

159console.log(fileObject.id);

160```

161 

162#### Response

163 

164```json

165{

166 "id": "id",

167 "bytes": 0,

168 "created_at": 0,

169 "filename": "filename",

170 "object": "file",

171 "purpose": "assistants",

172 "status": "uploaded",

173 "expires_at": 0,

174 "status_details": "status_details"

175}

176```

177 

178### Example

179 

180```typescript

181import fs from "fs";

182import OpenAI from "openai";

183 

184const openai = new OpenAI();

185 

186async function main() {

187 const file = await openai.files.create({

188 file: fs.createReadStream("mydata.jsonl"),

189 purpose: "fine-tune",

190 expires_after: {

191 anchor: "created_at",

192 seconds: 2592000

193 }

194 });

195 

196 console.log(file);

197}

198 

199main();

200```

201 

202#### Response

203 

204```json

205{

206 "id": "file-abc123",

207 "object": "file",

208 "bytes": 120000,

209 "created_at": 1677610602,

210 "expires_at": 1677614202,

211 "filename": "mydata.jsonl",

212 "purpose": "fine-tune",

213}

214```

Details

1## Create image variation

2 

3`client.images.createVariation(ImageCreateVariationParamsbody, RequestOptionsoptions?): ImagesResponse`

4 

5**post** `/images/variations`

6 

7Creates a variation of a given image. This endpoint only supports `dall-e-2`.

8 

9### Parameters

10 

11- `body: ImageCreateVariationParams`

12 

13 - `image: Uploadable`

14 

15 The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.

16 

17 - `model?: (string & {}) | ImageModel | null`

18 

19 The model to use for image generation. Only `dall-e-2` is supported at this time.

20 

21 - `(string & {})`

22 

23 - `ImageModel = "gpt-image-1" | "gpt-image-1-mini" | "gpt-image-2" | 5 more`

24 

25 - `"gpt-image-1"`

26 

27 - `"gpt-image-1-mini"`

28 

29 - `"gpt-image-2"`

30 

31 - `"gpt-image-2-2026-04-21"`

32 

33 - `"gpt-image-1.5"`

34 

35 - `"chatgpt-image-latest"`

36 

37 - `"dall-e-2"`

38 

39 - `"dall-e-3"`

40 

41 - `n?: number | null`

42 

43 The number of images to generate. Must be between 1 and 10.

44 

45 - `response_format?: "url" | "b64_json" | null`

46 

47 The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated.

48 

49 - `"url"`

50 

51 - `"b64_json"`

52 

53 - `size?: "256x256" | "512x512" | "1024x1024" | null`

54 

55 The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.

56 

57 - `"256x256"`

58 

59 - `"512x512"`

60 

61 - `"1024x1024"`

62 

63 - `user?: string`

64 

65 A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

66 

67### Returns

68 

69- `ImagesResponse`

70 

71 The response from the image generation endpoint.

72 

73 - `created: number`

74 

75 The Unix timestamp (in seconds) of when the image was created.

76 

77 - `background?: "transparent" | "opaque"`

78 

79 The background parameter used for the image generation. Either `transparent` or `opaque`.

80 

81 - `"transparent"`

82 

83 - `"opaque"`

84 

85 - `data?: Array<Image>`

86 

87 The list of generated images.

88 

89 - `b64_json?: string`

90 

91 The base64-encoded JSON of the generated image. Returned by default for the GPT image models, and only present if `response_format` is set to `b64_json` for `dall-e-2` and `dall-e-3`.

92 

93 - `revised_prompt?: string`

94 

95 For `dall-e-3` only, the revised prompt that was used to generate the image.

96 

97 - `url?: string`

98 

99 When using `dall-e-2` or `dall-e-3`, the URL of the generated image if `response_format` is set to `url` (default value). Unsupported for the GPT image models.

100 

101 - `output_format?: "png" | "webp" | "jpeg"`

102 

103 The output format of the image generation. Either `png`, `webp`, or `jpeg`.

104 

105 - `"png"`

106 

107 - `"webp"`

108 

109 - `"jpeg"`

110 

111 - `quality?: "low" | "medium" | "high"`

112 

113 The quality of the image generated. Either `low`, `medium`, or `high`.

114 

115 - `"low"`

116 

117 - `"medium"`

118 

119 - `"high"`

120 

121 - `size?: "1024x1024" | "1024x1536" | "1536x1024"`

122 

123 The size of the image generated. Either `1024x1024`, `1024x1536`, or `1536x1024`.

124 

125 - `"1024x1024"`

126 

127 - `"1024x1536"`

128 

129 - `"1536x1024"`

130 

131 - `usage?: Usage`

132 

133 For `gpt-image-1` only, the token usage information for the image generation.

134 

135 - `input_tokens: number`

136 

137 The number of tokens (images and text) in the input prompt.

138 

139 - `input_tokens_details: InputTokensDetails`

140 

141 The input tokens detailed information for the image generation.

142 

143 - `image_tokens: number`

144 

145 The number of image tokens in the input prompt.

146 

147 - `text_tokens: number`

148 

149 The number of text tokens in the input prompt.

150 

151 - `output_tokens: number`

152 

153 The number of output tokens generated by the model.

154 

155 - `total_tokens: number`

156 

157 The total number of tokens (images and text) used for the image generation.

158 

159 - `output_tokens_details?: OutputTokensDetails`

160 

161 The output token details for the image generation.

162 

163 - `image_tokens: number`

164 

165 The number of image output tokens generated by the model.

166 

167 - `text_tokens: number`

168 

169 The number of text output tokens generated by the model.

170 

171### Example

172 

173```typescript

174import fs from 'fs';

175import OpenAI from 'openai';

176 

177const client = new OpenAI({

178 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

179});

180 

181const imagesResponse = await client.images.createVariation({

182 image: fs.createReadStream('otter.png'),

183});

184 

185console.log(imagesResponse.created);

186```

187 

188#### Response

189 

190```json

191{

192 "created": 0,

193 "background": "transparent",

194 "data": [

195 {

196 "b64_json": "b64_json",

197 "revised_prompt": "revised_prompt",

198 "url": "https://example.com"

199 }

200 ],

201 "output_format": "png",

202 "quality": "low",

203 "size": "1024x1024",

204 "usage": {

205 "input_tokens": 0,

206 "input_tokens_details": {

207 "image_tokens": 0,

208 "text_tokens": 0

209 },

210 "output_tokens": 0,

211 "total_tokens": 0,

212 "output_tokens_details": {

213 "image_tokens": 0,

214 "text_tokens": 0

215 }

216 }

217}

218```

219 

220### Example

221 

222```typescript

223import fs from "fs";

224import OpenAI from "openai";

225 

226const openai = new OpenAI();

227 

228async function main() {

229 const image = await openai.images.createVariation({

230 image: fs.createReadStream("otter.png"),

231 });

232 

233 console.log(image.data);

234}

235main();

236```

237 

238#### Response

239 

240```json

241{

242 "created": 1589478378,

243 "data": [

244 {

245 "url": "https://..."

246 },

247 {

248 "url": "https://..."

249 }

250 ]

251}

252```

Details

1## Create image edit

2 

3`client.images.edit(ImageEditParamsbody, RequestOptionsoptions?): ImagesResponse | Stream<ImageEditStreamEvent>`

4 

5**post** `/images/edits`

6 

7Creates an edited or extended image given one or more source images and a prompt. This endpoint supports GPT Image models (`gpt-image-1.5`, `gpt-image-1`, `gpt-image-1-mini`, and `chatgpt-image-latest`) and `dall-e-2`.

8 

9### Parameters

10 

11- `ImageEditParams = ImageEditParamsNonStreaming | ImageEditParamsStreaming`

12 

13 - `ImageEditParamsBase`

14 

15 - `image: Uploadable | Array<Uploadable>`

16 

17 The image(s) to edit. Must be a supported image file or an array of images.

18 

19 For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`,

20 `gpt-image-1.5`, `gpt-image-2`, `gpt-image-2-2026-04-21`, and

21 `chatgpt-image-latest`), each image should be a `png`, `webp`, or

22 `jpg` file less than 50MB. You can provide up to 16 images.

23 

24 For `dall-e-2`, you can only provide one image, and it should be a

25 square `png` file less than 4MB.

26 

27 - `Uploadable`

28 

29 - `Array<Uploadable>`

30 

31 - `prompt: string`

32 

33 A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2`, and 32000 characters for the GPT image models.

34 

35 - `background?: "transparent" | "opaque" | "auto" | null`

36 

37 Allows to set transparency for the background of the generated image(s).

38 This parameter is only supported for GPT image models that support

39 transparent backgrounds. Must be one of `transparent`, `opaque`, or

40 `auto` (default value). When `auto` is used, the model will

41 automatically determine the best background for the image.

42 

43 `gpt-image-2` and `gpt-image-2-2026-04-21` do not support

44 transparent backgrounds. Requests with `background` set to

45 `transparent` will return an error for these models; use `opaque` or

46 `auto` instead.

47 

48 If `transparent`, the output format needs to support transparency,

49 so it should be set to either `png` (default value) or `webp`.

50 

51 - `"transparent"`

52 

53 - `"opaque"`

54 

55 - `"auto"`

56 

57 - `input_fidelity?: "high" | "low" | null`

58 

59 Control how much effort the model will exert to match the style and features, especially facial features, of input images. This parameter is only supported for `gpt-image-1` and `gpt-image-1.5` and later models, unsupported for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.

60 

61 - `"high"`

62 

63 - `"low"`

64 

65 - `mask?: Uploadable`

66 

67 An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. If there are multiple images provided, the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`.

68 

69 - `model?: (string & {}) | ImageModel | null`

70 

71 The model to use for image generation. One of `dall-e-2` or a GPT image model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to `gpt-image-1.5`.

72 

73 - `(string & {})`

74 

75 - `ImageModel = "gpt-image-1" | "gpt-image-1-mini" | "gpt-image-2" | 5 more`

76 

77 - `"gpt-image-1"`

78 

79 - `"gpt-image-1-mini"`

80 

81 - `"gpt-image-2"`

82 

83 - `"gpt-image-2-2026-04-21"`

84 

85 - `"gpt-image-1.5"`

86 

87 - `"chatgpt-image-latest"`

88 

89 - `"dall-e-2"`

90 

91 - `"dall-e-3"`

92 

93 - `n?: number | null`

94 

95 The number of images to generate. Must be between 1 and 10.

96 

97 - `output_compression?: number | null`

98 

99 The compression level (0-100%) for the generated images. This parameter

100 is only supported for the GPT image models with the `webp` or `jpeg` output

101 formats, and defaults to 100.

102 

103 - `output_format?: "png" | "jpeg" | "webp" | null`

104 

105 The format in which the generated images are returned. This parameter is

106 only supported for the GPT image models. Must be one of `png`, `jpeg`, or `webp`.

107 The default value is `png`.

108 

109 - `"png"`

110 

111 - `"jpeg"`

112 

113 - `"webp"`

114 

115 - `partial_images?: number | null`

116 

117 The number of partial images to generate. This parameter is used for

118 streaming responses that return partial images. Value must be between 0 and 3.

119 When set to 0, the response will be a single image sent in one streaming event.

120 

121 Note that the final image may be sent before the full number of partial images

122 are generated if the full image is generated more quickly.

123 

124 - `quality?: "standard" | "low" | "medium" | 2 more | null`

125 

126 The quality of the image that will be generated for GPT image models. Defaults to `auto`.

127 

128 - `"standard"`

129 

130 - `"low"`

131 

132 - `"medium"`

133 

134 - `"high"`

135 

136 - `"auto"`

137 

138 - `response_format?: "url" | "b64_json" | null`

139 

140 The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. This parameter is only supported for `dall-e-2` (default is `url` for `dall-e-2`), as GPT image models always return base64-encoded images.

141 

142 - `"url"`

143 

144 - `"b64_json"`

145 

146 - `size?: (string & {}) | "256x256" | "512x512" | "1024x1024" | 3 more | null`

147 

148 The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`.

149 

150 - `(string & {})`

151 

152 - `"256x256" | "512x512" | "1024x1024" | 3 more`

153 

154 - `"256x256"`

155 

156 - `"512x512"`

157 

158 - `"1024x1024"`

159 

160 - `"1536x1024"`

161 

162 - `"1024x1536"`

163 

164 - `"auto"`

165 

166 - `stream?: false | null`

167 

168 Edit the image in streaming mode. Defaults to `false`. See the

169 [Image generation guide](https://platform.openai.com/docs/guides/image-generation) for more information.

170 

171 - `false`

172 

173 - `user?: string`

174 

175 A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).

176 

177 - `ImageEditParamsNonStreaming extends ImageEditParamsBase`

178 

179 - `stream?: false | null`

180 

181 Edit the image in streaming mode. Defaults to `false`. See the

182 [Image generation guide](https://platform.openai.com/docs/guides/image-generation) for more information.

183 

184 - `ImageEditParamsStreaming extends ImageEditParamsBase`

185 

186 - `stream: true`

187 

188 Edit the image in streaming mode. Defaults to `false`. See the

189 [Image generation guide](https://platform.openai.com/docs/guides/image-generation) for more information.

190 

191 - `true`

192 

193### Returns

194 

195- `ImagesResponse`

196 

197 The response from the image generation endpoint.

198 

199 - `created: number`

200 

201 The Unix timestamp (in seconds) of when the image was created.

202 

203 - `background?: "transparent" | "opaque"`

204 

205 The background parameter used for the image generation. Either `transparent` or `opaque`.

206 

207 - `"transparent"`

208 

209 - `"opaque"`

210 

211 - `data?: Array<Image>`

212 

213 The list of generated images.

214 

215 - `b64_json?: string`

216 

217 The base64-encoded JSON of the generated image. Returned by default for the GPT image models, and only present if `response_format` is set to `b64_json` for `dall-e-2` and `dall-e-3`.

218 

219 - `revised_prompt?: string`

220 

221 For `dall-e-3` only, the revised prompt that was used to generate the image.

222 

223 - `url?: string`

224 

225 When using `dall-e-2` or `dall-e-3`, the URL of the generated image if `response_format` is set to `url` (default value). Unsupported for the GPT image models.

226 

227 - `output_format?: "png" | "webp" | "jpeg"`

228 

229 The output format of the image generation. Either `png`, `webp`, or `jpeg`.

230 

231 - `"png"`

232 

233 - `"webp"`

234 

235 - `"jpeg"`

236 

237 - `quality?: "low" | "medium" | "high"`

238 

239 The quality of the image generated. Either `low`, `medium`, or `high`.

240 

241 - `"low"`

242 

243 - `"medium"`

244 

245 - `"high"`

246 

247 - `size?: "1024x1024" | "1024x1536" | "1536x1024"`

248 

249 The size of the image generated. Either `1024x1024`, `1024x1536`, or `1536x1024`.

250 

251 - `"1024x1024"`

252 

253 - `"1024x1536"`

254 

255 - `"1536x1024"`

256 

257 - `usage?: Usage`

258 

259 For `gpt-image-1` only, the token usage information for the image generation.

260 

261 - `input_tokens: number`

262 

263 The number of tokens (images and text) in the input prompt.

264 

265 - `input_tokens_details: InputTokensDetails`

266 

267 The input tokens detailed information for the image generation.

268 

269 - `image_tokens: number`

270 

271 The number of image tokens in the input prompt.

272 

273 - `text_tokens: number`

274 

275 The number of text tokens in the input prompt.

276 

277 - `output_tokens: number`

278 

279 The number of output tokens generated by the model.

280 

281 - `total_tokens: number`

282 

283 The total number of tokens (images and text) used for the image generation.

284 

285 - `output_tokens_details?: OutputTokensDetails`

286 

287 The output token details for the image generation.

288 

289 - `image_tokens: number`

290 

291 The number of image output tokens generated by the model.

292 

293 - `text_tokens: number`

294 

295 The number of text output tokens generated by the model.

296 

297### Example

298 

299```typescript

300import fs from 'fs';

301import OpenAI from 'openai';

302 

303const client = new OpenAI({

304 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

305});

306 

307const imagesResponse = await client.images.edit({

308 image: fs.createReadStream('path/to/file'),

309 prompt: 'A cute baby sea otter wearing a beret',

310});

311 

312console.log(imagesResponse);

313```

314 

315#### Response

316 

317```json

318{

319 "created": 0,

320 "background": "transparent",

321 "data": [

322 {

323 "b64_json": "b64_json",

324 "revised_prompt": "revised_prompt",

325 "url": "https://example.com"

326 }

327 ],

328 "output_format": "png",

329 "quality": "low",

330 "size": "1024x1024",

331 "usage": {

332 "input_tokens": 0,

333 "input_tokens_details": {

334 "image_tokens": 0,

335 "text_tokens": 0

336 },

337 "output_tokens": 0,

338 "total_tokens": 0,

339 "output_tokens_details": {

340 "image_tokens": 0,

341 "text_tokens": 0

342 }

343 }

344}

345```

346 

347### Edit image

348 

349```typescript

350import fs from "fs";

351import OpenAI, { toFile } from "openai";

352 

353const client = new OpenAI();

354 

355const imageFiles = [

356 "bath-bomb.png",

357 "body-lotion.png",

358 "incense-kit.png",

359 "soap.png",

360];

361 

362const images = await Promise.all(

363 imageFiles.map(async (file) =>

364 await toFile(fs.createReadStream(file), null, {

365 type: "image/png",

366 })

367 ),

368);

369 

370const rsp = await client.images.edit({

371 model: "gpt-image-1.5",

372 image: images,

373 prompt: "Create a lovely gift basket with these four items in it",

374});

375 

376// Save the image to a file

377const image_base64 = rsp.data[0].b64_json;

378const image_bytes = Buffer.from(image_base64, "base64");

379fs.writeFileSync("basket.png", image_bytes);

380```

381 

382### Streaming

383 

384```typescript

385import fs from "fs";

386import OpenAI, { toFile } from "openai";

387 

388const client = new OpenAI();

389 

390const imageFiles = [

391 "bath-bomb.png",

392 "body-lotion.png",

393 "incense-kit.png",

394 "soap.png",

395];

396 

397const images = await Promise.all(

398 imageFiles.map(async (file) =>

399 await toFile(fs.createReadStream(file), null, {

400 type: "image/png",

401 })

402 ),

403);

404 

405const stream = await client.images.edit({

406 model: "gpt-image-1.5",

407 image: images,

408 prompt: "Create a lovely gift basket with these four items in it",

409 stream: true,

410});

411 

412for await (const event of stream) {

413 console.log(event);

414}

415```

416 

417#### Response

418 

419```json

420event: image_edit.partial_image

421data: {"type":"image_edit.partial_image","b64_json":"...","partial_image_index":0}

422 

423event: image_edit.completed

424data: {"type":"image_edit.completed","b64_json":"...","usage":{"total_tokens":100,"input_tokens":50,"output_tokens":50,"input_tokens_details":{"text_tokens":10,"image_tokens":40}}}

425```

Details

1## Create client secret

2 

3`client.realtime.clientSecrets.create(ClientSecretCreateParamsbody, RequestOptionsoptions?): ClientSecretCreateResponse`

4 

5**post** `/realtime/client_secrets`

6 

7Create a Realtime client secret with an associated session configuration.

8 

9Client secrets are short-lived tokens that can be passed to a client app,

10such as a web frontend or mobile client, which grants access to the Realtime API without

11leaking your main API key. You can configure a custom TTL for each client secret.

12 

13You can also attach session configuration options to the client secret, which will be

14applied to any sessions created using that client secret, but these can also be overridden

15by the client connection.

16 

17[Learn more about authentication with client secrets over WebRTC](https://platform.openai.com/docs/guides/realtime-webrtc).

18 

19Returns the created client secret and the effective session object. The client secret is a string that looks like `ek_1234`.

20 

21### Parameters

22 

23- `body: ClientSecretCreateParams`

24 

25 - `expires_after?: ExpiresAfter`

26 

27 Configuration for the client secret expiration. Expiration refers to the time after which

28 a client secret will no longer be valid for creating sessions. The session itself may

29 continue after that time once started. A secret can be used to create multiple sessions

30 until it expires.

31 

32 - `anchor?: "created_at"`

33 

34 The anchor point for the client secret expiration, meaning that `seconds` will be added to the `created_at` time of the client secret to produce an expiration timestamp. Only `created_at` is currently supported.

35 

36 - `"created_at"`

37 

38 - `seconds?: number`

39 

40 The number of seconds from the anchor point to the expiration. Select a value between `10` and `7200` (2 hours). This default to 600 seconds (10 minutes) if not specified.

41 

42 - `session?: RealtimeSessionCreateRequest | RealtimeTranscriptionSessionCreateRequest`

43 

44 Session configuration to use for the client secret. Choose either a realtime

45 session or a transcription session.

46 

47 - `RealtimeSessionCreateRequest`

48 

49 Realtime session object configuration.

50 

51 - `type: "realtime"`

52 

53 The type of session to create. Always `realtime` for the Realtime API.

54 

55 - `"realtime"`

56 

57 - `audio?: RealtimeAudioConfig`

58 

59 Configuration for input and output audio.

60 

61 - `input?: RealtimeAudioConfigInput`

62 

63 - `format?: RealtimeAudioFormats`

64 

65 The format of the input audio.

66 

67 - `AudioPCM`

68 

69 The PCM audio format. Only a 24kHz sample rate is supported.

70 

71 - `rate?: 24000`

72 

73 The sample rate of the audio. Always `24000`.

74 

75 - `24000`

76 

77 - `type?: "audio/pcm"`

78 

79 The audio format. Always `audio/pcm`.

80 

81 - `"audio/pcm"`

82 

83 - `AudioPCMU`

84 

85 The G.711 μ-law format.

86 

87 - `type?: "audio/pcmu"`

88 

89 The audio format. Always `audio/pcmu`.

90 

91 - `"audio/pcmu"`

92 

93 - `AudioPCMA`

94 

95 The G.711 A-law format.

96 

97 - `type?: "audio/pcma"`

98 

99 The audio format. Always `audio/pcma`.

100 

101 - `"audio/pcma"`

102 

103 - `noise_reduction?: NoiseReduction`

104 

105 Configuration for input audio noise reduction. This can be set to `null` to turn off.

106 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

107 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

108 

109 - `type?: NoiseReductionType`

110 

111 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

112 

113 - `"near_field"`

114 

115 - `"far_field"`

116 

117 - `transcription?: AudioTranscription`

118 

119 Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.

120 

121 - `delay?: "minimal" | "low" | "medium" | 2 more`

122 

123 Controls how long the model waits before emitting transcription text.

124 Higher values can improve transcription accuracy at the cost of latency.

125 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

126 

127 - `"minimal"`

128 

129 - `"low"`

130 

131 - `"medium"`

132 

133 - `"high"`

134 

135 - `"xhigh"`

136 

137 - `language?: string`

138 

139 The language of the input audio. Supplying the input language in

140 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

141 will improve accuracy and latency.

142 

143 - `model?: (string & {}) | "whisper-1" | "gpt-4o-mini-transcribe" | "gpt-4o-mini-transcribe-2025-12-15" | 3 more`

144 

145 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

146 

147 - `(string & {})`

148 

149 - `"whisper-1" | "gpt-4o-mini-transcribe" | "gpt-4o-mini-transcribe-2025-12-15" | 3 more`

150 

151 - `"whisper-1"`

152 

153 - `"gpt-4o-mini-transcribe"`

154 

155 - `"gpt-4o-mini-transcribe-2025-12-15"`

156 

157 - `"gpt-4o-transcribe"`

158 

159 - `"gpt-4o-transcribe-diarize"`

160 

161 - `"gpt-realtime-whisper"`

162 

163 - `prompt?: string`

164 

165 An optional text to guide the model's style or continue a previous audio

166 segment.

167 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).

168 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

169 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

170 

171 - `turn_detection?: RealtimeAudioInputTurnDetection | null`

172 

173 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

174 

175 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

176 

177 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

178 

179 For `gpt-realtime-whisper` transcription sessions, turn detection must be

180 set to `null`; VAD is not supported.

181 

182 - `ServerVad`

183 

184 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.

185 

186 - `type: "server_vad"`

187 

188 Type of turn detection, `server_vad` to turn on simple Server VAD.

189 

190 - `"server_vad"`

191 

192 - `create_response?: boolean`

193 

194 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

195 

196 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

197 

198 - `idle_timeout_ms?: number | null`

199 

200 Optional timeout after which a model response will be triggered automatically. This is

201 useful for situations in which a long pause from the user is unexpected, such as a phone

202 call. The model will effectively prompt the user to continue the conversation based

203 on the current context.

204 

205 The timeout value will be applied after the last model response's audio has finished playing,

206 i.e. it's set to the `response.done` time plus audio playback duration.

207 

208 An `input_audio_buffer.timeout_triggered` event (plus events

209 associated with the Response) will be emitted when the timeout is reached.

210 Idle timeout is currently only supported for `server_vad` mode.

211 

212 - `interrupt_response?: boolean`

213 

214 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

215 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

216 

217 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

218 

219 - `prefix_padding_ms?: number`

220 

221 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

222 milliseconds). Defaults to 300ms.

223 

224 - `silence_duration_ms?: number`

225 

226 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

227 to 500ms. With shorter values the model will respond more quickly,

228 but may jump in on short pauses from the user.

229 

230 - `threshold?: number`

231 

232 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

233 higher threshold will require louder audio to activate the model, and

234 thus might perform better in noisy environments.

235 

236 - `SemanticVad`

237 

238 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.

239 

240 - `type: "semantic_vad"`

241 

242 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

243 

244 - `"semantic_vad"`

245 

246 - `create_response?: boolean`

247 

248 Whether or not to automatically generate a response when a VAD stop event occurs.

249 

250 - `eagerness?: "low" | "medium" | "high" | "auto"`

251 

252 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

253 

254 - `"low"`

255 

256 - `"medium"`

257 

258 - `"high"`

259 

260 - `"auto"`

261 

262 - `interrupt_response?: boolean`

263 

264 Whether or not to automatically interrupt any ongoing response with output to the default

265 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

266 

267 - `output?: RealtimeAudioConfigOutput`

268 

269 - `format?: RealtimeAudioFormats`

270 

271 The format of the output audio.

272 

273 - `speed?: number`

274 

275 The speed of the model's spoken response as a multiple of the original speed.

276 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.

277 

278 This parameter is a post-processing adjustment to the audio after it is generated, it's

279 also possible to prompt the model to speak faster or slower.

280 

281 - `voice?: string | "alloy" | "ash" | "ballad" | 7 more | ID`

282 

283 The voice the model uses to respond. Supported built-in voices are

284 `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,

285 `marin`, and `cedar`. You may also provide a custom voice object with

286 an `id`, for example `{ "id": "voice_1234" }`. Voice cannot be changed

287 during the session once the model has responded with audio at least once.

288 We recommend `marin` and `cedar` for best quality.

289 

290 - `string`

291 

292 - `"alloy" | "ash" | "ballad" | 7 more`

293 

294 - `"alloy"`

295 

296 - `"ash"`

297 

298 - `"ballad"`

299 

300 - `"coral"`

301 

302 - `"echo"`

303 

304 - `"sage"`

305 

306 - `"shimmer"`

307 

308 - `"verse"`

309 

310 - `"marin"`

311 

312 - `"cedar"`

313 

314 - `ID`

315 

316 Custom voice reference.

317 

318 - `id: string`

319 

320 The custom voice ID, e.g. `voice_1234`.

321 

322 - `include?: Array<"item.input_audio_transcription.logprobs">`

323 

324 Additional fields to include in server outputs.

325 

326 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

327 

328 - `"item.input_audio_transcription.logprobs"`

329 

330 - `instructions?: string`

331 

332 The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.

333 

334 Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.

335 

336 - `max_output_tokens?: number | "inf"`

337 

338 Maximum number of output tokens for a single assistant response,

339 inclusive of tool calls. Provide an integer between 1 and 4096 to

340 limit output tokens, or `inf` for the maximum available tokens for a

341 given model. Defaults to `inf`.

342 

343 - `number`

344 

345 - `"inf"`

346 

347 - `"inf"`

348 

349 - `model?: (string & {}) | "gpt-realtime" | "gpt-realtime-1.5" | "gpt-realtime-2" | 14 more`

350 

351 The Realtime model used for this session.

352 

353 - `(string & {})`

354 

355 - `"gpt-realtime" | "gpt-realtime-1.5" | "gpt-realtime-2" | 14 more`

356 

357 - `"gpt-realtime"`

358 

359 - `"gpt-realtime-1.5"`

360 

361 - `"gpt-realtime-2"`

362 

363 - `"gpt-realtime-2025-08-28"`

364 

365 - `"gpt-4o-realtime-preview"`

366 

367 - `"gpt-4o-realtime-preview-2024-10-01"`

368 

369 - `"gpt-4o-realtime-preview-2024-12-17"`

370 

371 - `"gpt-4o-realtime-preview-2025-06-03"`

372 

373 - `"gpt-4o-mini-realtime-preview"`

374 

375 - `"gpt-4o-mini-realtime-preview-2024-12-17"`

376 

377 - `"gpt-realtime-mini"`

378 

379 - `"gpt-realtime-mini-2025-10-06"`

380 

381 - `"gpt-realtime-mini-2025-12-15"`

382 

383 - `"gpt-audio-1.5"`

384 

385 - `"gpt-audio-mini"`

386 

387 - `"gpt-audio-mini-2025-10-06"`

388 

389 - `"gpt-audio-mini-2025-12-15"`

390 

391 - `output_modalities?: Array<"text" | "audio">`

392 

393 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating

394 that the model will respond with audio plus a transcript. `["text"]` can be used to make

395 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.

396 

397 - `"text"`

398 

399 - `"audio"`

400 

401 - `parallel_tool_calls?: boolean`

402 

403 Whether the model may call multiple tools in parallel. Only supported by

404 reasoning Realtime models such as `gpt-realtime-2`.

405 

406 - `prompt?: ResponsePrompt | null`

407 

408 Reference to a prompt template and its variables.

409 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).

410 

411 - `id: string`

412 

413 The unique identifier of the prompt template to use.

414 

415 - `variables?: Record<string, string | ResponseInputText | ResponseInputImage | ResponseInputFile> | null`

416 

417 Optional map of values to substitute in for variables in your

418 prompt. The substitution values can either be strings, or other

419 Response input types like images or files.

420 

421 - `string`

422 

423 - `ResponseInputText`

424 

425 A text input to the model.

426 

427 - `text: string`

428 

429 The text input to the model.

430 

431 - `type: "input_text"`

432 

433 The type of the input item. Always `input_text`.

434 

435 - `"input_text"`

436 

437 - `ResponseInputImage`

438 

439 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).

440 

441 - `detail: "low" | "high" | "auto" | "original"`

442 

443 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.

444 

445 - `"low"`

446 

447 - `"high"`

448 

449 - `"auto"`

450 

451 - `"original"`

452 

453 - `type: "input_image"`

454 

455 The type of the input item. Always `input_image`.

456 

457 - `"input_image"`

458 

459 - `file_id?: string | null`

460 

461 The ID of the file to be sent to the model.

462 

463 - `image_url?: string | null`

464 

465 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.

466 

467 - `ResponseInputFile`

468 

469 A file input to the model.

470 

471 - `type: "input_file"`

472 

473 The type of the input item. Always `input_file`.

474 

475 - `"input_file"`

476 

477 - `detail?: "low" | "high"`

478 

479 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.

480 

481 - `"low"`

482 

483 - `"high"`

484 

485 - `file_data?: string`

486 

487 The content of the file to be sent to the model.

488 

489 - `file_id?: string | null`

490 

491 The ID of the file to be sent to the model.

492 

493 - `file_url?: string`

494 

495 The URL of the file to be sent to the model.

496 

497 - `filename?: string`

498 

499 The name of the file to be sent to the model.

500 

501 - `version?: string | null`

502 

503 Optional version of the prompt template.

504 

505 - `reasoning?: RealtimeReasoning`

506 

507 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.

508 

509 - `effort?: RealtimeReasoningEffort`

510 

511 Constrains effort on reasoning for reasoning-capable Realtime models such as

512 `gpt-realtime-2`.

513 

514 - `"minimal"`

515 

516 - `"low"`

517 

518 - `"medium"`

519 

520 - `"high"`

521 

522 - `"xhigh"`

523 

524 - `tool_choice?: RealtimeToolChoiceConfig`

525 

526 How the model chooses tools. Provide one of the string modes or force a specific

527 function/MCP tool.

528 

529 - `ToolChoiceOptions = "none" | "auto" | "required"`

530 

531 Controls which (if any) tool is called by the model.

532 

533 `none` means the model will not call any tool and instead generates a message.

534 

535 `auto` means the model can pick between generating a message or calling one or

536 more tools.

537 

538 `required` means the model must call one or more tools.

539 

540 - `"none"`

541 

542 - `"auto"`

543 

544 - `"required"`

545 

546 - `ToolChoiceFunction`

547 

548 Use this option to force the model to call a specific function.

549 

550 - `name: string`

551 

552 The name of the function to call.

553 

554 - `type: "function"`

555 

556 For function calling, the type is always `function`.

557 

558 - `"function"`

559 

560 - `ToolChoiceMcp`

561 

562 Use this option to force the model to call a specific tool on a remote MCP server.

563 

564 - `server_label: string`

565 

566 The label of the MCP server to use.

567 

568 - `type: "mcp"`

569 

570 For MCP tools, the type is always `mcp`.

571 

572 - `"mcp"`

573 

574 - `name?: string | null`

575 

576 The name of the tool to call on the server.

577 

578 - `tools?: RealtimeToolsConfig`

579 

580 Tools available to the model.

581 

582 - `RealtimeFunctionTool`

583 

584 - `description?: string`

585 

586 The description of the function, including guidance on when and how

587 to call it, and guidance about what to tell the user when calling

588 (if anything).

589 

590 - `name?: string`

591 

592 The name of the function.

593 

594 - `parameters?: unknown`

595 

596 Parameters of the function in JSON Schema.

597 

598 - `type?: "function"`

599 

600 The type of the tool, i.e. `function`.

601 

602 - `"function"`

603 

604 - `Mcp`

605 

606 Give the model access to additional tools via remote Model Context Protocol

607 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).

608 

609 - `server_label: string`

610 

611 A label for this MCP server, used to identify it in tool calls.

612 

613 - `type: "mcp"`

614 

615 The type of the MCP tool. Always `mcp`.

616 

617 - `"mcp"`

618 

619 - `allowed_tools?: Array<string> | McpToolFilter | null`

620 

621 List of allowed tool names or a filter object.

622 

623 - `Array<string>`

624 

625 - `McpToolFilter`

626 

627 A filter object to specify which tools are allowed.

628 

629 - `read_only?: boolean`

630 

631 Indicates whether or not a tool modifies data or is read-only. If an

632 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

633 it will match this filter.

634 

635 - `tool_names?: Array<string>`

636 

637 List of allowed tool names.

638 

639 - `authorization?: string`

640 

641 An OAuth access token that can be used with a remote MCP server, either

642 with a custom MCP server URL or a service connector. Your application

643 must handle the OAuth authorization flow and provide the token here.

644 

645 - `connector_id?: "connector_dropbox" | "connector_gmail" | "connector_googlecalendar" | 5 more`

646 

647 Identifier for service connectors, like those available in ChatGPT. One of

648 `server_url` or `connector_id` must be provided. Learn more about service

649 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).

650 

651 Currently supported `connector_id` values are:

652 

653 - Dropbox: `connector_dropbox`

654 - Gmail: `connector_gmail`

655 - Google Calendar: `connector_googlecalendar`

656 - Google Drive: `connector_googledrive`

657 - Microsoft Teams: `connector_microsoftteams`

658 - Outlook Calendar: `connector_outlookcalendar`

659 - Outlook Email: `connector_outlookemail`

660 - SharePoint: `connector_sharepoint`

661 

662 - `"connector_dropbox"`

663 

664 - `"connector_gmail"`

665 

666 - `"connector_googlecalendar"`

667 

668 - `"connector_googledrive"`

669 

670 - `"connector_microsoftteams"`

671 

672 - `"connector_outlookcalendar"`

673 

674 - `"connector_outlookemail"`

675 

676 - `"connector_sharepoint"`

677 

678 - `defer_loading?: boolean`

679 

680 Whether this MCP tool is deferred and discovered via tool search.

681 

682 - `headers?: Record<string, string> | null`

683 

684 Optional HTTP headers to send to the MCP server. Use for authentication

685 or other purposes.

686 

687 - `require_approval?: McpToolApprovalFilter | "always" | "never" | null`

688 

689 Specify which of the MCP server's tools require approval.

690 

691 - `McpToolApprovalFilter`

692 

693 Specify which of the MCP server's tools require approval. Can be

694 `always`, `never`, or a filter object associated with tools

695 that require approval.

696 

697 - `always?: Always`

698 

699 A filter object to specify which tools are allowed.

700 

701 - `read_only?: boolean`

702 

703 Indicates whether or not a tool modifies data or is read-only. If an

704 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

705 it will match this filter.

706 

707 - `tool_names?: Array<string>`

708 

709 List of allowed tool names.

710 

711 - `never?: Never`

712 

713 A filter object to specify which tools are allowed.

714 

715 - `read_only?: boolean`

716 

717 Indicates whether or not a tool modifies data or is read-only. If an

718 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

719 it will match this filter.

720 

721 - `tool_names?: Array<string>`

722 

723 List of allowed tool names.

724 

725 - `"always" | "never"`

726 

727 - `"always"`

728 

729 - `"never"`

730 

731 - `server_description?: string`

732 

733 Optional description of the MCP server, used to provide more context.

734 

735 - `server_url?: string`

736 

737 The URL for the MCP server. One of `server_url` or `connector_id` must be

738 provided.

739 

740 - `tracing?: RealtimeTracingConfig | null`

741 

742 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once

743 tracing is enabled for a session, the configuration cannot be modified.

744 

745 `auto` will create a trace for the session with default values for the

746 workflow name, group id, and metadata.

747 

748 - `"auto"`

749 

750 - `"auto"`

751 

752 - `TracingConfiguration`

753 

754 Granular configuration for tracing.

755 

756 - `group_id?: string`

757 

758 The group id to attach to this trace to enable filtering and

759 grouping in the Traces Dashboard.

760 

761 - `metadata?: unknown`

762 

763 The arbitrary metadata to attach to this trace to enable

764 filtering in the Traces Dashboard.

765 

766 - `workflow_name?: string`

767 

768 The name of the workflow to attach to this trace. This is used to

769 name the trace in the Traces Dashboard.

770 

771 - `truncation?: RealtimeTruncation`

772 

773 When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

774 

775 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

776 

777 Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

778 

779 Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.

780 

781 - `"auto" | "disabled"`

782 

783 - `"auto"`

784 

785 - `"disabled"`

786 

787 - `RealtimeTruncationRetentionRatio`

788 

789 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

790 

791 - `retention_ratio: number`

792 

793 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.

794 

795 - `type: "retention_ratio"`

796 

797 Use retention ratio truncation.

798 

799 - `"retention_ratio"`

800 

801 - `token_limits?: TokenLimits`

802 

803 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.

804 

805 - `post_instructions?: number`

806 

807 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.

808 

809 - `RealtimeTranscriptionSessionCreateRequest`

810 

811 Realtime transcription session object configuration.

812 

813 - `type: "transcription"`

814 

815 The type of session to create. Always `transcription` for transcription sessions.

816 

817 - `"transcription"`

818 

819 - `audio?: RealtimeTranscriptionSessionAudio`

820 

821 Configuration for input and output audio.

822 

823 - `input?: RealtimeTranscriptionSessionAudioInput`

824 

825 - `format?: RealtimeAudioFormats`

826 

827 The PCM audio format. Only a 24kHz sample rate is supported.

828 

829 - `noise_reduction?: NoiseReduction`

830 

831 Configuration for input audio noise reduction. This can be set to `null` to turn off.

832 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

833 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

834 

835 - `type?: NoiseReductionType`

836 

837 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

838 

839 - `transcription?: AudioTranscription`

840 

841 Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](https://platform.openai.com/docs/api-reference/audio/createTranscription) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.

842 

843 - `turn_detection?: RealtimeTranscriptionSessionAudioInputTurnDetection | null`

844 

845 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

846 

847 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

848 

849 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

850 

851 For `gpt-realtime-whisper` transcription sessions, turn detection must be

852 set to `null`; VAD is not supported.

853 

854 - `ServerVad`

855 

856 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.

857 

858 - `type: "server_vad"`

859 

860 Type of turn detection, `server_vad` to turn on simple Server VAD.

861 

862 - `"server_vad"`

863 

864 - `create_response?: boolean`

865 

866 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

867 

868 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

869 

870 - `idle_timeout_ms?: number | null`

871 

872 Optional timeout after which a model response will be triggered automatically. This is

873 useful for situations in which a long pause from the user is unexpected, such as a phone

874 call. The model will effectively prompt the user to continue the conversation based

875 on the current context.

876 

877 The timeout value will be applied after the last model response's audio has finished playing,

878 i.e. it's set to the `response.done` time plus audio playback duration.

879 

880 An `input_audio_buffer.timeout_triggered` event (plus events

881 associated with the Response) will be emitted when the timeout is reached.

882 Idle timeout is currently only supported for `server_vad` mode.

883 

884 - `interrupt_response?: boolean`

885 

886 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

887 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

888 

889 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

890 

891 - `prefix_padding_ms?: number`

892 

893 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

894 milliseconds). Defaults to 300ms.

895 

896 - `silence_duration_ms?: number`

897 

898 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

899 to 500ms. With shorter values the model will respond more quickly,

900 but may jump in on short pauses from the user.

901 

902 - `threshold?: number`

903 

904 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

905 higher threshold will require louder audio to activate the model, and

906 thus might perform better in noisy environments.

907 

908 - `SemanticVad`

909 

910 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.

911 

912 - `type: "semantic_vad"`

913 

914 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

915 

916 - `"semantic_vad"`

917 

918 - `create_response?: boolean`

919 

920 Whether or not to automatically generate a response when a VAD stop event occurs.

921 

922 - `eagerness?: "low" | "medium" | "high" | "auto"`

923 

924 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

925 

926 - `"low"`

927 

928 - `"medium"`

929 

930 - `"high"`

931 

932 - `"auto"`

933 

934 - `interrupt_response?: boolean`

935 

936 Whether or not to automatically interrupt any ongoing response with output to the default

937 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

938 

939 - `include?: Array<"item.input_audio_transcription.logprobs">`

940 

941 Additional fields to include in server outputs.

942 

943 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

944 

945 - `"item.input_audio_transcription.logprobs"`

946 

947### Returns

948 

949- `ClientSecretCreateResponse`

950 

951 Response from creating a session and client secret for the Realtime API.

952 

953 - `expires_at: number`

954 

955 Expiration timestamp for the client secret, in seconds since epoch.

956 

957 - `session: RealtimeSessionCreateResponse | RealtimeTranscriptionSessionCreateResponse`

958 

959 The session configuration for either a realtime or transcription session.

960 

961 - `RealtimeSessionCreateResponse`

962 

963 A Realtime session configuration object.

964 

965 - `id: string`

966 

967 Unique identifier for the session that looks like `sess_1234567890abcdef`.

968 

969 - `object: "realtime.session"`

970 

971 The object type. Always `realtime.session`.

972 

973 - `"realtime.session"`

974 

975 - `type: "realtime"`

976 

977 The type of session to create. Always `realtime` for the Realtime API.

978 

979 - `"realtime"`

980 

981 - `audio?: Audio`

982 

983 Configuration for input and output audio.

984 

985 - `input?: Input`

986 

987 - `format?: RealtimeAudioFormats`

988 

989 The format of the input audio.

990 

991 - `AudioPCM`

992 

993 The PCM audio format. Only a 24kHz sample rate is supported.

994 

995 - `rate?: 24000`

996 

997 The sample rate of the audio. Always `24000`.

998 

999 - `24000`

1000 

1001 - `type?: "audio/pcm"`

1002 

1003 The audio format. Always `audio/pcm`.

1004 

1005 - `"audio/pcm"`

1006 

1007 - `AudioPCMU`

1008 

1009 The G.711 μ-law format.

1010 

1011 - `type?: "audio/pcmu"`

1012 

1013 The audio format. Always `audio/pcmu`.

1014 

1015 - `"audio/pcmu"`

1016 

1017 - `AudioPCMA`

1018 

1019 The G.711 A-law format.

1020 

1021 - `type?: "audio/pcma"`

1022 

1023 The audio format. Always `audio/pcma`.

1024 

1025 - `"audio/pcma"`

1026 

1027 - `noise_reduction?: NoiseReduction`

1028 

1029 Configuration for input audio noise reduction. This can be set to `null` to turn off.

1030 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.

1031 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.

1032 

1033 - `type?: NoiseReductionType`

1034 

1035 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

1036 

1037 - `"near_field"`

1038 

1039 - `"far_field"`

1040 

1041 - `transcription?: AudioTranscription`

1042 

1043 - `delay?: "minimal" | "low" | "medium" | 2 more`

1044 

1045 Controls how long the model waits before emitting transcription text.

1046 Higher values can improve transcription accuracy at the cost of latency.

1047 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.

1048 

1049 - `"minimal"`

1050 

1051 - `"low"`

1052 

1053 - `"medium"`

1054 

1055 - `"high"`

1056 

1057 - `"xhigh"`

1058 

1059 - `language?: string`

1060 

1061 The language of the input audio. Supplying the input language in

1062 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format

1063 will improve accuracy and latency.

1064 

1065 - `model?: (string & {}) | "whisper-1" | "gpt-4o-mini-transcribe" | "gpt-4o-mini-transcribe-2025-12-15" | 3 more`

1066 

1067 The model to use for transcription. Current options are `whisper-1`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.

1068 

1069 - `(string & {})`

1070 

1071 - `"whisper-1" | "gpt-4o-mini-transcribe" | "gpt-4o-mini-transcribe-2025-12-15" | 3 more`

1072 

1073 - `"whisper-1"`

1074 

1075 - `"gpt-4o-mini-transcribe"`

1076 

1077 - `"gpt-4o-mini-transcribe-2025-12-15"`

1078 

1079 - `"gpt-4o-transcribe"`

1080 

1081 - `"gpt-4o-transcribe-diarize"`

1082 

1083 - `"gpt-realtime-whisper"`

1084 

1085 - `prompt?: string`

1086 

1087 An optional text to guide the model's style or continue a previous audio

1088 segment.

1089 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).

1090 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".

1091 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.

1092 

1093 - `turn_detection?: ServerVad | SemanticVad | null`

1094 

1095 Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to `null` to turn off, in which case the client must manually trigger model response.

1096 

1097 Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

1098 

1099 Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

1100 

1101 For `gpt-realtime-whisper` transcription sessions, turn detection must be

1102 set to `null`; VAD is not supported.

1103 

1104 - `ServerVad`

1105 

1106 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.

1107 

1108 - `type: "server_vad"`

1109 

1110 Type of turn detection, `server_vad` to turn on simple Server VAD.

1111 

1112 - `"server_vad"`

1113 

1114 - `create_response?: boolean`

1115 

1116 Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.

1117 

1118 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

1119 

1120 - `idle_timeout_ms?: number | null`

1121 

1122 Optional timeout after which a model response will be triggered automatically. This is

1123 useful for situations in which a long pause from the user is unexpected, such as a phone

1124 call. The model will effectively prompt the user to continue the conversation based

1125 on the current context.

1126 

1127 The timeout value will be applied after the last model response's audio has finished playing,

1128 i.e. it's set to the `response.done` time plus audio playback duration.

1129 

1130 An `input_audio_buffer.timeout_triggered` event (plus events

1131 associated with the Response) will be emitted when the timeout is reached.

1132 Idle timeout is currently only supported for `server_vad` mode.

1133 

1134 - `interrupt_response?: boolean`

1135 

1136 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default

1137 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.

1138 

1139 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.

1140 

1141 - `prefix_padding_ms?: number`

1142 

1143 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in

1144 milliseconds). Defaults to 300ms.

1145 

1146 - `silence_duration_ms?: number`

1147 

1148 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults

1149 to 500ms. With shorter values the model will respond more quickly,

1150 but may jump in on short pauses from the user.

1151 

1152 - `threshold?: number`

1153 

1154 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

1155 higher threshold will require louder audio to activate the model, and

1156 thus might perform better in noisy environments.

1157 

1158 - `SemanticVad`

1159 

1160 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.

1161 

1162 - `type: "semantic_vad"`

1163 

1164 Type of turn detection, `semantic_vad` to turn on Semantic VAD.

1165 

1166 - `"semantic_vad"`

1167 

1168 - `create_response?: boolean`

1169 

1170 Whether or not to automatically generate a response when a VAD stop event occurs.

1171 

1172 - `eagerness?: "low" | "medium" | "high" | "auto"`

1173 

1174 Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.

1175 

1176 - `"low"`

1177 

1178 - `"medium"`

1179 

1180 - `"high"`

1181 

1182 - `"auto"`

1183 

1184 - `interrupt_response?: boolean`

1185 

1186 Whether or not to automatically interrupt any ongoing response with output to the default

1187 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.

1188 

1189 - `output?: Output`

1190 

1191 - `format?: RealtimeAudioFormats`

1192 

1193 The format of the output audio.

1194 

1195 - `speed?: number`

1196 

1197 The speed of the model's spoken response as a multiple of the original speed.

1198 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.

1199 

1200 This parameter is a post-processing adjustment to the audio after it is generated, it's

1201 also possible to prompt the model to speak faster or slower.

1202 

1203 - `voice?: (string & {}) | "alloy" | "ash" | "ballad" | 7 more`

1204 

1205 The voice the model uses to respond. Voice cannot be changed during the

1206 session once the model has responded with audio at least once. Current

1207 voice options are `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`,

1208 `shimmer`, `verse`, `marin`, and `cedar`. We recommend `marin` and `cedar` for

1209 best quality.

1210 

1211 - `(string & {})`

1212 

1213 - `"alloy" | "ash" | "ballad" | 7 more`

1214 

1215 - `"alloy"`

1216 

1217 - `"ash"`

1218 

1219 - `"ballad"`

1220 

1221 - `"coral"`

1222 

1223 - `"echo"`

1224 

1225 - `"sage"`

1226 

1227 - `"shimmer"`

1228 

1229 - `"verse"`

1230 

1231 - `"marin"`

1232 

1233 - `"cedar"`

1234 

1235 - `expires_at?: number`

1236 

1237 Expiration timestamp for the session, in seconds since epoch.

1238 

1239 - `include?: Array<"item.input_audio_transcription.logprobs">`

1240 

1241 Additional fields to include in server outputs.

1242 

1243 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

1244 

1245 - `"item.input_audio_transcription.logprobs"`

1246 

1247 - `instructions?: string`

1248 

1249 The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.

1250 

1251 Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.

1252 

1253 - `max_output_tokens?: number | "inf"`

1254 

1255 Maximum number of output tokens for a single assistant response,

1256 inclusive of tool calls. Provide an integer between 1 and 4096 to

1257 limit output tokens, or `inf` for the maximum available tokens for a

1258 given model. Defaults to `inf`.

1259 

1260 - `number`

1261 

1262 - `"inf"`

1263 

1264 - `"inf"`

1265 

1266 - `model?: (string & {}) | "gpt-realtime" | "gpt-realtime-1.5" | "gpt-realtime-2" | 14 more`

1267 

1268 The Realtime model used for this session.

1269 

1270 - `(string & {})`

1271 

1272 - `"gpt-realtime" | "gpt-realtime-1.5" | "gpt-realtime-2" | 14 more`

1273 

1274 - `"gpt-realtime"`

1275 

1276 - `"gpt-realtime-1.5"`

1277 

1278 - `"gpt-realtime-2"`

1279 

1280 - `"gpt-realtime-2025-08-28"`

1281 

1282 - `"gpt-4o-realtime-preview"`

1283 

1284 - `"gpt-4o-realtime-preview-2024-10-01"`

1285 

1286 - `"gpt-4o-realtime-preview-2024-12-17"`

1287 

1288 - `"gpt-4o-realtime-preview-2025-06-03"`

1289 

1290 - `"gpt-4o-mini-realtime-preview"`

1291 

1292 - `"gpt-4o-mini-realtime-preview-2024-12-17"`

1293 

1294 - `"gpt-realtime-mini"`

1295 

1296 - `"gpt-realtime-mini-2025-10-06"`

1297 

1298 - `"gpt-realtime-mini-2025-12-15"`

1299 

1300 - `"gpt-audio-1.5"`

1301 

1302 - `"gpt-audio-mini"`

1303 

1304 - `"gpt-audio-mini-2025-10-06"`

1305 

1306 - `"gpt-audio-mini-2025-12-15"`

1307 

1308 - `output_modalities?: Array<"text" | "audio">`

1309 

1310 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating

1311 that the model will respond with audio plus a transcript. `["text"]` can be used to make

1312 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.

1313 

1314 - `"text"`

1315 

1316 - `"audio"`

1317 

1318 - `prompt?: ResponsePrompt | null`

1319 

1320 Reference to a prompt template and its variables.

1321 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).

1322 

1323 - `id: string`

1324 

1325 The unique identifier of the prompt template to use.

1326 

1327 - `variables?: Record<string, string | ResponseInputText | ResponseInputImage | ResponseInputFile> | null`

1328 

1329 Optional map of values to substitute in for variables in your

1330 prompt. The substitution values can either be strings, or other

1331 Response input types like images or files.

1332 

1333 - `string`

1334 

1335 - `ResponseInputText`

1336 

1337 A text input to the model.

1338 

1339 - `text: string`

1340 

1341 The text input to the model.

1342 

1343 - `type: "input_text"`

1344 

1345 The type of the input item. Always `input_text`.

1346 

1347 - `"input_text"`

1348 

1349 - `ResponseInputImage`

1350 

1351 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).

1352 

1353 - `detail: "low" | "high" | "auto" | "original"`

1354 

1355 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.

1356 

1357 - `"low"`

1358 

1359 - `"high"`

1360 

1361 - `"auto"`

1362 

1363 - `"original"`

1364 

1365 - `type: "input_image"`

1366 

1367 The type of the input item. Always `input_image`.

1368 

1369 - `"input_image"`

1370 

1371 - `file_id?: string | null`

1372 

1373 The ID of the file to be sent to the model.

1374 

1375 - `image_url?: string | null`

1376 

1377 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.

1378 

1379 - `ResponseInputFile`

1380 

1381 A file input to the model.

1382 

1383 - `type: "input_file"`

1384 

1385 The type of the input item. Always `input_file`.

1386 

1387 - `"input_file"`

1388 

1389 - `detail?: "low" | "high"`

1390 

1391 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.

1392 

1393 - `"low"`

1394 

1395 - `"high"`

1396 

1397 - `file_data?: string`

1398 

1399 The content of the file to be sent to the model.

1400 

1401 - `file_id?: string | null`

1402 

1403 The ID of the file to be sent to the model.

1404 

1405 - `file_url?: string`

1406 

1407 The URL of the file to be sent to the model.

1408 

1409 - `filename?: string`

1410 

1411 The name of the file to be sent to the model.

1412 

1413 - `version?: string | null`

1414 

1415 Optional version of the prompt template.

1416 

1417 - `reasoning?: RealtimeReasoning`

1418 

1419 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.

1420 

1421 - `effort?: RealtimeReasoningEffort`

1422 

1423 Constrains effort on reasoning for reasoning-capable Realtime models such as

1424 `gpt-realtime-2`.

1425 

1426 - `"minimal"`

1427 

1428 - `"low"`

1429 

1430 - `"medium"`

1431 

1432 - `"high"`

1433 

1434 - `"xhigh"`

1435 

1436 - `tool_choice?: ToolChoiceOptions | ToolChoiceFunction | ToolChoiceMcp`

1437 

1438 How the model chooses tools. Provide one of the string modes or force a specific

1439 function/MCP tool.

1440 

1441 - `ToolChoiceOptions = "none" | "auto" | "required"`

1442 

1443 Controls which (if any) tool is called by the model.

1444 

1445 `none` means the model will not call any tool and instead generates a message.

1446 

1447 `auto` means the model can pick between generating a message or calling one or

1448 more tools.

1449 

1450 `required` means the model must call one or more tools.

1451 

1452 - `"none"`

1453 

1454 - `"auto"`

1455 

1456 - `"required"`

1457 

1458 - `ToolChoiceFunction`

1459 

1460 Use this option to force the model to call a specific function.

1461 

1462 - `name: string`

1463 

1464 The name of the function to call.

1465 

1466 - `type: "function"`

1467 

1468 For function calling, the type is always `function`.

1469 

1470 - `"function"`

1471 

1472 - `ToolChoiceMcp`

1473 

1474 Use this option to force the model to call a specific tool on a remote MCP server.

1475 

1476 - `server_label: string`

1477 

1478 The label of the MCP server to use.

1479 

1480 - `type: "mcp"`

1481 

1482 For MCP tools, the type is always `mcp`.

1483 

1484 - `"mcp"`

1485 

1486 - `name?: string | null`

1487 

1488 The name of the tool to call on the server.

1489 

1490 - `tools?: Array<RealtimeFunctionTool | McpTool>`

1491 

1492 Tools available to the model.

1493 

1494 - `RealtimeFunctionTool`

1495 

1496 - `description?: string`

1497 

1498 The description of the function, including guidance on when and how

1499 to call it, and guidance about what to tell the user when calling

1500 (if anything).

1501 

1502 - `name?: string`

1503 

1504 The name of the function.

1505 

1506 - `parameters?: unknown`

1507 

1508 Parameters of the function in JSON Schema.

1509 

1510 - `type?: "function"`

1511 

1512 The type of the tool, i.e. `function`.

1513 

1514 - `"function"`

1515 

1516 - `McpTool`

1517 

1518 Give the model access to additional tools via remote Model Context Protocol

1519 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).

1520 

1521 - `server_label: string`

1522 

1523 A label for this MCP server, used to identify it in tool calls.

1524 

1525 - `type: "mcp"`

1526 

1527 The type of the MCP tool. Always `mcp`.

1528 

1529 - `"mcp"`

1530 

1531 - `allowed_tools?: Array<string> | McpToolFilter | null`

1532 

1533 List of allowed tool names or a filter object.

1534 

1535 - `Array<string>`

1536 

1537 - `McpToolFilter`

1538 

1539 A filter object to specify which tools are allowed.

1540 

1541 - `read_only?: boolean`

1542 

1543 Indicates whether or not a tool modifies data or is read-only. If an

1544 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1545 it will match this filter.

1546 

1547 - `tool_names?: Array<string>`

1548 

1549 List of allowed tool names.

1550 

1551 - `authorization?: string`

1552 

1553 An OAuth access token that can be used with a remote MCP server, either

1554 with a custom MCP server URL or a service connector. Your application

1555 must handle the OAuth authorization flow and provide the token here.

1556 

1557 - `connector_id?: "connector_dropbox" | "connector_gmail" | "connector_googlecalendar" | 5 more`

1558 

1559 Identifier for service connectors, like those available in ChatGPT. One of

1560 `server_url` or `connector_id` must be provided. Learn more about service

1561 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).

1562 

1563 Currently supported `connector_id` values are:

1564 

1565 - Dropbox: `connector_dropbox`

1566 - Gmail: `connector_gmail`

1567 - Google Calendar: `connector_googlecalendar`

1568 - Google Drive: `connector_googledrive`

1569 - Microsoft Teams: `connector_microsoftteams`

1570 - Outlook Calendar: `connector_outlookcalendar`

1571 - Outlook Email: `connector_outlookemail`

1572 - SharePoint: `connector_sharepoint`

1573 

1574 - `"connector_dropbox"`

1575 

1576 - `"connector_gmail"`

1577 

1578 - `"connector_googlecalendar"`

1579 

1580 - `"connector_googledrive"`

1581 

1582 - `"connector_microsoftteams"`

1583 

1584 - `"connector_outlookcalendar"`

1585 

1586 - `"connector_outlookemail"`

1587 

1588 - `"connector_sharepoint"`

1589 

1590 - `defer_loading?: boolean`

1591 

1592 Whether this MCP tool is deferred and discovered via tool search.

1593 

1594 - `headers?: Record<string, string> | null`

1595 

1596 Optional HTTP headers to send to the MCP server. Use for authentication

1597 or other purposes.

1598 

1599 - `require_approval?: McpToolApprovalFilter | "always" | "never" | null`

1600 

1601 Specify which of the MCP server's tools require approval.

1602 

1603 - `McpToolApprovalFilter`

1604 

1605 Specify which of the MCP server's tools require approval. Can be

1606 `always`, `never`, or a filter object associated with tools

1607 that require approval.

1608 

1609 - `always?: Always`

1610 

1611 A filter object to specify which tools are allowed.

1612 

1613 - `read_only?: boolean`

1614 

1615 Indicates whether or not a tool modifies data or is read-only. If an

1616 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1617 it will match this filter.

1618 

1619 - `tool_names?: Array<string>`

1620 

1621 List of allowed tool names.

1622 

1623 - `never?: Never`

1624 

1625 A filter object to specify which tools are allowed.

1626 

1627 - `read_only?: boolean`

1628 

1629 Indicates whether or not a tool modifies data or is read-only. If an

1630 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),

1631 it will match this filter.

1632 

1633 - `tool_names?: Array<string>`

1634 

1635 List of allowed tool names.

1636 

1637 - `"always" | "never"`

1638 

1639 - `"always"`

1640 

1641 - `"never"`

1642 

1643 - `server_description?: string`

1644 

1645 Optional description of the MCP server, used to provide more context.

1646 

1647 - `server_url?: string`

1648 

1649 The URL for the MCP server. One of `server_url` or `connector_id` must be

1650 provided.

1651 

1652 - `tracing?: "auto" | TracingConfiguration | null`

1653 

1654 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once

1655 tracing is enabled for a session, the configuration cannot be modified.

1656 

1657 `auto` will create a trace for the session with default values for the

1658 workflow name, group id, and metadata.

1659 

1660 - `"auto"`

1661 

1662 - `"auto"`

1663 

1664 - `TracingConfiguration`

1665 

1666 Granular configuration for tracing.

1667 

1668 - `group_id?: string`

1669 

1670 The group id to attach to this trace to enable filtering and

1671 grouping in the Traces Dashboard.

1672 

1673 - `metadata?: unknown`

1674 

1675 The arbitrary metadata to attach to this trace to enable

1676 filtering in the Traces Dashboard.

1677 

1678 - `workflow_name?: string`

1679 

1680 The name of the workflow to attach to this trace. This is used to

1681 name the trace in the Traces Dashboard.

1682 

1683 - `truncation?: RealtimeTruncation`

1684 

1685 When the number of tokens in a conversation exceeds the model's input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model's context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

1686 

1687 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

1688 

1689 Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

1690 

1691 Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model's input token limit.

1692 

1693 - `"auto" | "disabled"`

1694 

1695 - `"auto"`

1696 

1697 - `"disabled"`

1698 

1699 - `RealtimeTruncationRetentionRatio`

1700 

1701 Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

1702 

1703 - `retention_ratio: number`

1704 

1705 Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.

1706 

1707 - `type: "retention_ratio"`

1708 

1709 Use retention ratio truncation.

1710 

1711 - `"retention_ratio"`

1712 

1713 - `token_limits?: TokenLimits`

1714 

1715 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.

1716 

1717 - `post_instructions?: number`

1718 

1719 Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.

1720 

1721 - `RealtimeTranscriptionSessionCreateResponse`

1722 

1723 A Realtime transcription session configuration object.

1724 

1725 - `id: string`

1726 

1727 Unique identifier for the session that looks like `sess_1234567890abcdef`.

1728 

1729 - `object: string`

1730 

1731 The object type. Always `realtime.transcription_session`.

1732 

1733 - `type: "transcription"`

1734 

1735 The type of session. Always `transcription` for transcription sessions.

1736 

1737 - `"transcription"`

1738 

1739 - `audio?: Audio`

1740 

1741 Configuration for input audio for the session.

1742 

1743 - `input?: Input`

1744 

1745 - `format?: RealtimeAudioFormats`

1746 

1747 The PCM audio format. Only a 24kHz sample rate is supported.

1748 

1749 - `noise_reduction?: NoiseReduction`

1750 

1751 Configuration for input audio noise reduction.

1752 

1753 - `type?: NoiseReductionType`

1754 

1755 Type of noise reduction. `near_field` is for close-talking microphones such as headphones, `far_field` is for far-field microphones such as laptop or conference room microphones.

1756 

1757 - `transcription?: AudioTranscription`

1758 

1759 - `turn_detection?: RealtimeTranscriptionSessionTurnDetection | null`

1760 

1761 Configuration for turn detection. Can be set to `null` to turn off. Server

1762 VAD means that the model will detect the start and end of speech based on

1763 audio volume and respond at the end of user speech. For `gpt-realtime-whisper`, this must be `null`; VAD is not supported.

1764 

1765 - `prefix_padding_ms?: number`

1766 

1767 Amount of audio to include before the VAD detected speech (in

1768 milliseconds). Defaults to 300ms.

1769 

1770 - `silence_duration_ms?: number`

1771 

1772 Duration of silence to detect speech stop (in milliseconds). Defaults

1773 to 500ms. With shorter values the model will respond more quickly,

1774 but may jump in on short pauses from the user.

1775 

1776 - `threshold?: number`

1777 

1778 Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A

1779 higher threshold will require louder audio to activate the model, and

1780 thus might perform better in noisy environments.

1781 

1782 - `type?: string`

1783 

1784 Type of turn detection, only `server_vad` is currently supported.

1785 

1786 - `expires_at?: number`

1787 

1788 Expiration timestamp for the session, in seconds since epoch.

1789 

1790 - `include?: Array<"item.input_audio_transcription.logprobs">`

1791 

1792 Additional fields to include in server outputs.

1793 

1794 - `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.

1795 

1796 - `"item.input_audio_transcription.logprobs"`

1797 

1798 - `value: string`

1799 

1800 The generated client secret value.

1801 

1802### Example

1803 

1804```typescript

1805import OpenAI from 'openai';

1806 

1807const client = new OpenAI({

1808 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

1809});

1810 

1811const clientSecret = await client.realtime.clientSecrets.create();

1812 

1813console.log(clientSecret.expires_at);

1814```

1815 

1816#### Response

1817 

1818```json

1819{

1820 "expires_at": 0,

1821 "session": {

1822 "id": "id",

1823 "object": "realtime.session",

1824 "type": "realtime",

1825 "audio": {

1826 "input": {

1827 "format": {

1828 "rate": 24000,

1829 "type": "audio/pcm"

1830 },

1831 "noise_reduction": {

1832 "type": "near_field"

1833 },

1834 "transcription": {

1835 "delay": "minimal",

1836 "language": "language",

1837 "model": "whisper-1",

1838 "prompt": "prompt"

1839 },

1840 "turn_detection": {

1841 "type": "server_vad",

1842 "create_response": true,

1843 "idle_timeout_ms": 5000,

1844 "interrupt_response": true,

1845 "prefix_padding_ms": 0,

1846 "silence_duration_ms": 0,

1847 "threshold": 0

1848 }

1849 },

1850 "output": {

1851 "format": {

1852 "rate": 24000,

1853 "type": "audio/pcm"

1854 },

1855 "speed": 0.25,

1856 "voice": "ash"

1857 }

1858 },

1859 "expires_at": 0,

1860 "include": [

1861 "item.input_audio_transcription.logprobs"

1862 ],

1863 "instructions": "instructions",

1864 "max_output_tokens": "inf",

1865 "model": "gpt-realtime",

1866 "output_modalities": [

1867 "text"

1868 ],

1869 "prompt": {

1870 "id": "id",

1871 "variables": {

1872 "foo": "string"

1873 },

1874 "version": "version"

1875 },

1876 "reasoning": {

1877 "effort": "minimal"

1878 },

1879 "tool_choice": "none",

1880 "tools": [

1881 {

1882 "description": "description",

1883 "name": "name",

1884 "parameters": {},

1885 "type": "function"

1886 }

1887 ],

1888 "tracing": "auto",

1889 "truncation": "auto"

1890 },

1891 "value": "value"

1892}

1893```

Details

1## Add upload part

2 

3`client.uploads.parts.create(stringuploadID, PartCreateParamsbody, RequestOptionsoptions?): UploadPart`

4 

5**post** `/uploads/{upload_id}/parts`

6 

7Adds a [Part](https://platform.openai.com/docs/api-reference/uploads/part-object) to an [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object. A Part represents a chunk of bytes from the file you are trying to upload.

8 

9Each Part can be at most 64 MB, and you can add Parts until you hit the Upload maximum of 8 GB.

10 

11It is possible to add multiple Parts in parallel. You can decide the intended order of the Parts when you [complete the Upload](https://platform.openai.com/docs/api-reference/uploads/complete).

12 

13### Parameters

14 

15- `uploadID: string`

16 

17- `body: PartCreateParams`

18 

19 - `data: Uploadable`

20 

21 The chunk of bytes for this Part.

22 

23### Returns

24 

25- `UploadPart`

26 

27 The upload Part represents a chunk of bytes we can add to an Upload object.

28 

29 - `id: string`

30 

31 The upload Part unique identifier, which can be referenced in API endpoints.

32 

33 - `created_at: number`

34 

35 The Unix timestamp (in seconds) for when the Part was created.

36 

37 - `object: "upload.part"`

38 

39 The object type, which is always `upload.part`.

40 

41 - `"upload.part"`

42 

43 - `upload_id: string`

44 

45 The ID of the Upload object that this Part was added to.

46 

47### Example

48 

49```typescript

50import fs from 'fs';

51import OpenAI from 'openai';

52 

53const client = new OpenAI({

54 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

55});

56 

57const uploadPart = await client.uploads.parts.create('upload_abc123', {

58 data: fs.createReadStream('path/to/file'),

59});

60 

61console.log(uploadPart.id);

62```

63 

64#### Response

65 

66```json

67{

68 "id": "id",

69 "created_at": 0,

70 "object": "upload.part",

71 "upload_id": "upload_id"

72}

73```

Details

1## Create video

2 

3`client.videos.create(VideoCreateParamsbody, RequestOptionsoptions?): Video`

4 

5**post** `/videos`

6 

7Create a new video generation job from a prompt and optional reference assets.

8 

9### Parameters

10 

11- `body: VideoCreateParams`

12 

13 - `prompt: string`

14 

15 Text prompt that describes the video to generate.

16 

17 - `input_reference?: Uploadable | ImageInputReferenceParam`

18 

19 Optional reference asset upload or reference object that guides generation.

20 

21 - `Uploadable`

22 

23 - `ImageInputReferenceParam`

24 

25 - `file_id?: string`

26 

27 - `image_url?: string`

28 

29 A fully qualified URL or base64-encoded data URL.

30 

31 - `model?: VideoModel`

32 

33 The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults to `sora-2`.

34 

35 - `(string & {})`

36 

37 - `"sora-2" | "sora-2-pro" | "sora-2-2025-10-06" | 2 more`

38 

39 - `"sora-2"`

40 

41 - `"sora-2-pro"`

42 

43 - `"sora-2-2025-10-06"`

44 

45 - `"sora-2-pro-2025-10-06"`

46 

47 - `"sora-2-2025-12-08"`

48 

49 - `seconds?: VideoSeconds`

50 

51 Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds.

52 

53 - `"4"`

54 

55 - `"8"`

56 

57 - `"12"`

58 

59 - `size?: VideoSize`

60 

61 Output resolution formatted as width x height (allowed values: 720x1280, 1280x720, 1024x1792, 1792x1024). Defaults to 720x1280.

62 

63 - `"720x1280"`

64 

65 - `"1280x720"`

66 

67 - `"1024x1792"`

68 

69 - `"1792x1024"`

70 

71### Returns

72 

73- `Video`

74 

75 Structured information describing a generated video job.

76 

77 - `id: string`

78 

79 Unique identifier for the video job.

80 

81 - `completed_at: number | null`

82 

83 Unix timestamp (seconds) for when the job completed, if finished.

84 

85 - `created_at: number`

86 

87 Unix timestamp (seconds) for when the job was created.

88 

89 - `error: VideoCreateError | null`

90 

91 Error payload that explains why generation failed, if applicable.

92 

93 - `code: string`

94 

95 A machine-readable error code that was returned.

96 

97 - `message: string`

98 

99 A human-readable description of the error that was returned.

100 

101 - `expires_at: number | null`

102 

103 Unix timestamp (seconds) for when the downloadable assets expire, if set.

104 

105 - `model: VideoModel`

106 

107 The video generation model that produced the job.

108 

109 - `(string & {})`

110 

111 - `"sora-2" | "sora-2-pro" | "sora-2-2025-10-06" | 2 more`

112 

113 - `"sora-2"`

114 

115 - `"sora-2-pro"`

116 

117 - `"sora-2-2025-10-06"`

118 

119 - `"sora-2-pro-2025-10-06"`

120 

121 - `"sora-2-2025-12-08"`

122 

123 - `object: "video"`

124 

125 The object type, which is always `video`.

126 

127 - `"video"`

128 

129 - `progress: number`

130 

131 Approximate completion percentage for the generation task.

132 

133 - `prompt: string | null`

134 

135 The prompt that was used to generate the video.

136 

137 - `remixed_from_video_id: string | null`

138 

139 Identifier of the source video if this video is a remix.

140 

141 - `seconds: (string & {}) | VideoSeconds`

142 

143 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

144 

145 - `(string & {})`

146 

147 - `VideoSeconds = "4" | "8" | "12"`

148 

149 - `"4"`

150 

151 - `"8"`

152 

153 - `"12"`

154 

155 - `size: VideoSize`

156 

157 The resolution of the generated video.

158 

159 - `"720x1280"`

160 

161 - `"1280x720"`

162 

163 - `"1024x1792"`

164 

165 - `"1792x1024"`

166 

167 - `status: "queued" | "in_progress" | "completed" | "failed"`

168 

169 Current lifecycle status of the video job.

170 

171 - `"queued"`

172 

173 - `"in_progress"`

174 

175 - `"completed"`

176 

177 - `"failed"`

178 

179### Example

180 

181```typescript

182import OpenAI from 'openai';

183 

184const client = new OpenAI({

185 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

186});

187 

188const video = await client.videos.create({ prompt: 'x' });

189 

190console.log(video.id);

191```

192 

193#### Response

194 

195```json

196{

197 "id": "id",

198 "completed_at": 0,

199 "created_at": 0,

200 "error": {

201 "code": "code",

202 "message": "message"

203 },

204 "expires_at": 0,

205 "model": "sora-2",

206 "object": "video",

207 "progress": 0,

208 "prompt": "prompt",

209 "remixed_from_video_id": "remixed_from_video_id",

210 "seconds": "4",

211 "size": "720x1280",

212 "status": "queued"

213}

214```

215 

216### Example

217 

218```typescript

219import OpenAI from 'openai';

220 

221const openai = new OpenAI();

222 

223const video = await openai.videos.create({ prompt: 'A calico cat playing a piano on stage' });

224 

225console.log(video.id);

226```

227 

228#### Response

229 

230```json

231{

232 "id": "video_123",

233 "object": "video",

234 "model": "sora-2",

235 "status": "queued",

236 "progress": 0,

237 "created_at": 1712697600,

238 "size": "1024x1792",

239 "seconds": "8",

240 "quality": "standard"

241}

242```

Details

1## Create a character from an uploaded video.

2 

3`client.videos.createCharacter(VideoCreateCharacterParamsbody, RequestOptionsoptions?): VideoCreateCharacterResponse`

4 

5**post** `/videos/characters`

6 

7Create a character from an uploaded video.

8 

9### Parameters

10 

11- `body: VideoCreateCharacterParams`

12 

13 - `name: string`

14 

15 Display name for this API character.

16 

17 - `video: Uploadable`

18 

19 Video file used to create a character.

20 

21### Returns

22 

23- `VideoCreateCharacterResponse`

24 

25 - `id: string | null`

26 

27 Identifier for the character creation cameo.

28 

29 - `created_at: number`

30 

31 Unix timestamp (in seconds) when the character was created.

32 

33 - `name: string | null`

34 

35 Display name for the character.

36 

37### Example

38 

39```typescript

40import fs from 'fs';

41import OpenAI from 'openai';

42 

43const client = new OpenAI({

44 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

45});

46 

47const response = await client.videos.createCharacter({

48 name: 'x',

49 video: fs.createReadStream('path/to/file'),

50});

51 

52console.log(response.id);

53```

54 

55#### Response

56 

57```json

58{

59 "id": "id",

60 "created_at": 0,

61 "name": "name"

62}

63```

Details

1## Create a new video generation job by editing a source video or existing generated video.

2 

3`client.videos.edit(VideoEditParamsbody, RequestOptionsoptions?): Video`

4 

5**post** `/videos/edits`

6 

7Create a new video generation job by editing a source video or existing generated video.

8 

9### Parameters

10 

11- `body: VideoEditParams`

12 

13 - `prompt: string`

14 

15 Text prompt that describes how to edit the source video.

16 

17 - `video: Uploadable | VideoReferenceInputParam`

18 

19 Reference to the completed video to edit.

20 

21 - `Uploadable`

22 

23 - `VideoReferenceInputParam`

24 

25 Reference to the completed video.

26 

27 - `id: string`

28 

29 The identifier of the completed video.

30 

31### Returns

32 

33- `Video`

34 

35 Structured information describing a generated video job.

36 

37 - `id: string`

38 

39 Unique identifier for the video job.

40 

41 - `completed_at: number | null`

42 

43 Unix timestamp (seconds) for when the job completed, if finished.

44 

45 - `created_at: number`

46 

47 Unix timestamp (seconds) for when the job was created.

48 

49 - `error: VideoCreateError | null`

50 

51 Error payload that explains why generation failed, if applicable.

52 

53 - `code: string`

54 

55 A machine-readable error code that was returned.

56 

57 - `message: string`

58 

59 A human-readable description of the error that was returned.

60 

61 - `expires_at: number | null`

62 

63 Unix timestamp (seconds) for when the downloadable assets expire, if set.

64 

65 - `model: VideoModel`

66 

67 The video generation model that produced the job.

68 

69 - `(string & {})`

70 

71 - `"sora-2" | "sora-2-pro" | "sora-2-2025-10-06" | 2 more`

72 

73 - `"sora-2"`

74 

75 - `"sora-2-pro"`

76 

77 - `"sora-2-2025-10-06"`

78 

79 - `"sora-2-pro-2025-10-06"`

80 

81 - `"sora-2-2025-12-08"`

82 

83 - `object: "video"`

84 

85 The object type, which is always `video`.

86 

87 - `"video"`

88 

89 - `progress: number`

90 

91 Approximate completion percentage for the generation task.

92 

93 - `prompt: string | null`

94 

95 The prompt that was used to generate the video.

96 

97 - `remixed_from_video_id: string | null`

98 

99 Identifier of the source video if this video is a remix.

100 

101 - `seconds: (string & {}) | VideoSeconds`

102 

103 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

104 

105 - `(string & {})`

106 

107 - `VideoSeconds = "4" | "8" | "12"`

108 

109 - `"4"`

110 

111 - `"8"`

112 

113 - `"12"`

114 

115 - `size: VideoSize`

116 

117 The resolution of the generated video.

118 

119 - `"720x1280"`

120 

121 - `"1280x720"`

122 

123 - `"1024x1792"`

124 

125 - `"1792x1024"`

126 

127 - `status: "queued" | "in_progress" | "completed" | "failed"`

128 

129 Current lifecycle status of the video job.

130 

131 - `"queued"`

132 

133 - `"in_progress"`

134 

135 - `"completed"`

136 

137 - `"failed"`

138 

139### Example

140 

141```typescript

142import OpenAI from 'openai';

143 

144const client = new OpenAI({

145 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

146});

147 

148const video = await client.videos.edit({ prompt: 'x', video: fs.createReadStream('path/to/file') });

149 

150console.log(video.id);

151```

152 

153#### Response

154 

155```json

156{

157 "id": "id",

158 "completed_at": 0,

159 "created_at": 0,

160 "error": {

161 "code": "code",

162 "message": "message"

163 },

164 "expires_at": 0,

165 "model": "sora-2",

166 "object": "video",

167 "progress": 0,

168 "prompt": "prompt",

169 "remixed_from_video_id": "remixed_from_video_id",

170 "seconds": "4",

171 "size": "720x1280",

172 "status": "queued"

173}

174```

Details

1## Create an extension of a completed video.

2 

3`client.videos.extend(VideoExtendParamsbody, RequestOptionsoptions?): Video`

4 

5**post** `/videos/extensions`

6 

7Create an extension of a completed video.

8 

9### Parameters

10 

11- `body: VideoExtendParams`

12 

13 - `prompt: string`

14 

15 Updated text prompt that directs the extension generation.

16 

17 - `seconds: VideoSeconds`

18 

19 Length of the newly generated extension segment in seconds (allowed values: 4, 8, 12, 16, 20).

20 

21 - `"4"`

22 

23 - `"8"`

24 

25 - `"12"`

26 

27 - `video: Uploadable | VideoReferenceInputParam`

28 

29 Reference to the completed video to extend.

30 

31 - `Uploadable`

32 

33 - `VideoReferenceInputParam`

34 

35 Reference to the completed video.

36 

37 - `id: string`

38 

39 The identifier of the completed video.

40 

41### Returns

42 

43- `Video`

44 

45 Structured information describing a generated video job.

46 

47 - `id: string`

48 

49 Unique identifier for the video job.

50 

51 - `completed_at: number | null`

52 

53 Unix timestamp (seconds) for when the job completed, if finished.

54 

55 - `created_at: number`

56 

57 Unix timestamp (seconds) for when the job was created.

58 

59 - `error: VideoCreateError | null`

60 

61 Error payload that explains why generation failed, if applicable.

62 

63 - `code: string`

64 

65 A machine-readable error code that was returned.

66 

67 - `message: string`

68 

69 A human-readable description of the error that was returned.

70 

71 - `expires_at: number | null`

72 

73 Unix timestamp (seconds) for when the downloadable assets expire, if set.

74 

75 - `model: VideoModel`

76 

77 The video generation model that produced the job.

78 

79 - `(string & {})`

80 

81 - `"sora-2" | "sora-2-pro" | "sora-2-2025-10-06" | 2 more`

82 

83 - `"sora-2"`

84 

85 - `"sora-2-pro"`

86 

87 - `"sora-2-2025-10-06"`

88 

89 - `"sora-2-pro-2025-10-06"`

90 

91 - `"sora-2-2025-12-08"`

92 

93 - `object: "video"`

94 

95 The object type, which is always `video`.

96 

97 - `"video"`

98 

99 - `progress: number`

100 

101 Approximate completion percentage for the generation task.

102 

103 - `prompt: string | null`

104 

105 The prompt that was used to generate the video.

106 

107 - `remixed_from_video_id: string | null`

108 

109 Identifier of the source video if this video is a remix.

110 

111 - `seconds: (string & {}) | VideoSeconds`

112 

113 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

114 

115 - `(string & {})`

116 

117 - `VideoSeconds = "4" | "8" | "12"`

118 

119 - `"4"`

120 

121 - `"8"`

122 

123 - `"12"`

124 

125 - `size: VideoSize`

126 

127 The resolution of the generated video.

128 

129 - `"720x1280"`

130 

131 - `"1280x720"`

132 

133 - `"1024x1792"`

134 

135 - `"1792x1024"`

136 

137 - `status: "queued" | "in_progress" | "completed" | "failed"`

138 

139 Current lifecycle status of the video job.

140 

141 - `"queued"`

142 

143 - `"in_progress"`

144 

145 - `"completed"`

146 

147 - `"failed"`

148 

149### Example

150 

151```typescript

152import OpenAI from 'openai';

153 

154const client = new OpenAI({

155 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

156});

157 

158const video = await client.videos.extend({

159 prompt: 'x',

160 seconds: '4',

161 video: fs.createReadStream('path/to/file'),

162});

163 

164console.log(video.id);

165```

166 

167#### Response

168 

169```json

170{

171 "id": "id",

172 "completed_at": 0,

173 "created_at": 0,

174 "error": {

175 "code": "code",

176 "message": "message"

177 },

178 "expires_at": 0,

179 "model": "sora-2",

180 "object": "video",

181 "progress": 0,

182 "prompt": "prompt",

183 "remixed_from_video_id": "remixed_from_video_id",

184 "seconds": "4",

185 "size": "720x1280",

186 "status": "queued"

187}

188```

Details

1## List videos

2 

3`client.videos.list(VideoListParamsquery?, RequestOptionsoptions?): ConversationCursorPage<Video>`

4 

5**get** `/videos`

6 

7List recently generated videos for the current project.

8 

9### Parameters

10 

11- `query: VideoListParams`

12 

13 - `after?: string`

14 

15 Identifier for the last item from the previous pagination request

16 

17 - `limit?: number`

18 

19 Number of items to retrieve

20 

21 - `order?: "asc" | "desc"`

22 

23 Sort order of results by timestamp. Use `asc` for ascending order or `desc` for descending order.

24 

25 - `"asc"`

26 

27 - `"desc"`

28 

29### Returns

30 

31- `Video`

32 

33 Structured information describing a generated video job.

34 

35 - `id: string`

36 

37 Unique identifier for the video job.

38 

39 - `completed_at: number | null`

40 

41 Unix timestamp (seconds) for when the job completed, if finished.

42 

43 - `created_at: number`

44 

45 Unix timestamp (seconds) for when the job was created.

46 

47 - `error: VideoCreateError | null`

48 

49 Error payload that explains why generation failed, if applicable.

50 

51 - `code: string`

52 

53 A machine-readable error code that was returned.

54 

55 - `message: string`

56 

57 A human-readable description of the error that was returned.

58 

59 - `expires_at: number | null`

60 

61 Unix timestamp (seconds) for when the downloadable assets expire, if set.

62 

63 - `model: VideoModel`

64 

65 The video generation model that produced the job.

66 

67 - `(string & {})`

68 

69 - `"sora-2" | "sora-2-pro" | "sora-2-2025-10-06" | 2 more`

70 

71 - `"sora-2"`

72 

73 - `"sora-2-pro"`

74 

75 - `"sora-2-2025-10-06"`

76 

77 - `"sora-2-pro-2025-10-06"`

78 

79 - `"sora-2-2025-12-08"`

80 

81 - `object: "video"`

82 

83 The object type, which is always `video`.

84 

85 - `"video"`

86 

87 - `progress: number`

88 

89 Approximate completion percentage for the generation task.

90 

91 - `prompt: string | null`

92 

93 The prompt that was used to generate the video.

94 

95 - `remixed_from_video_id: string | null`

96 

97 Identifier of the source video if this video is a remix.

98 

99 - `seconds: (string & {}) | VideoSeconds`

100 

101 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

102 

103 - `(string & {})`

104 

105 - `VideoSeconds = "4" | "8" | "12"`

106 

107 - `"4"`

108 

109 - `"8"`

110 

111 - `"12"`

112 

113 - `size: VideoSize`

114 

115 The resolution of the generated video.

116 

117 - `"720x1280"`

118 

119 - `"1280x720"`

120 

121 - `"1024x1792"`

122 

123 - `"1792x1024"`

124 

125 - `status: "queued" | "in_progress" | "completed" | "failed"`

126 

127 Current lifecycle status of the video job.

128 

129 - `"queued"`

130 

131 - `"in_progress"`

132 

133 - `"completed"`

134 

135 - `"failed"`

136 

137### Example

138 

139```typescript

140import OpenAI from 'openai';

141 

142const client = new OpenAI({

143 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

144});

145 

146// Automatically fetches more pages as needed.

147for await (const video of client.videos.list()) {

148 console.log(video.id);

149}

150```

151 

152#### Response

153 

154```json

155{

156 "data": [

157 {

158 "id": "id",

159 "completed_at": 0,

160 "created_at": 0,

161 "error": {

162 "code": "code",

163 "message": "message"

164 },

165 "expires_at": 0,

166 "model": "sora-2",

167 "object": "video",

168 "progress": 0,

169 "prompt": "prompt",

170 "remixed_from_video_id": "remixed_from_video_id",

171 "seconds": "4",

172 "size": "720x1280",

173 "status": "queued"

174 }

175 ],

176 "first_id": "first_id",

177 "has_more": true,

178 "last_id": "last_id",

179 "object": "list"

180}

181```

182 

183### Example

184 

185```typescript

186import OpenAI from 'openai';

187 

188const openai = new OpenAI();

189 

190// Automatically fetches more pages as needed.

191for await (const video of openai.videos.list()) {

192 console.log(video.id);

193}

194```

195 

196#### Response

197 

198```json

199{

200 "data": [

201 {

202 "id": "video_123",

203 "object": "video",

204 "model": "sora-2",

205 "status": "completed"

206 }

207 ],

208 "object": "list"

209}

210```

Details

1## Remix video

2 

3`client.videos.remix(stringvideoID, VideoRemixParamsbody, RequestOptionsoptions?): Video`

4 

5**post** `/videos/{video_id}/remix`

6 

7Create a remix of a completed video using a refreshed prompt.

8 

9### Parameters

10 

11- `videoID: string`

12 

13- `body: VideoRemixParams`

14 

15 - `prompt: string`

16 

17 Updated text prompt that directs the remix generation.

18 

19### Returns

20 

21- `Video`

22 

23 Structured information describing a generated video job.

24 

25 - `id: string`

26 

27 Unique identifier for the video job.

28 

29 - `completed_at: number | null`

30 

31 Unix timestamp (seconds) for when the job completed, if finished.

32 

33 - `created_at: number`

34 

35 Unix timestamp (seconds) for when the job was created.

36 

37 - `error: VideoCreateError | null`

38 

39 Error payload that explains why generation failed, if applicable.

40 

41 - `code: string`

42 

43 A machine-readable error code that was returned.

44 

45 - `message: string`

46 

47 A human-readable description of the error that was returned.

48 

49 - `expires_at: number | null`

50 

51 Unix timestamp (seconds) for when the downloadable assets expire, if set.

52 

53 - `model: VideoModel`

54 

55 The video generation model that produced the job.

56 

57 - `(string & {})`

58 

59 - `"sora-2" | "sora-2-pro" | "sora-2-2025-10-06" | 2 more`

60 

61 - `"sora-2"`

62 

63 - `"sora-2-pro"`

64 

65 - `"sora-2-2025-10-06"`

66 

67 - `"sora-2-pro-2025-10-06"`

68 

69 - `"sora-2-2025-12-08"`

70 

71 - `object: "video"`

72 

73 The object type, which is always `video`.

74 

75 - `"video"`

76 

77 - `progress: number`

78 

79 Approximate completion percentage for the generation task.

80 

81 - `prompt: string | null`

82 

83 The prompt that was used to generate the video.

84 

85 - `remixed_from_video_id: string | null`

86 

87 Identifier of the source video if this video is a remix.

88 

89 - `seconds: (string & {}) | VideoSeconds`

90 

91 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

92 

93 - `(string & {})`

94 

95 - `VideoSeconds = "4" | "8" | "12"`

96 

97 - `"4"`

98 

99 - `"8"`

100 

101 - `"12"`

102 

103 - `size: VideoSize`

104 

105 The resolution of the generated video.

106 

107 - `"720x1280"`

108 

109 - `"1280x720"`

110 

111 - `"1024x1792"`

112 

113 - `"1792x1024"`

114 

115 - `status: "queued" | "in_progress" | "completed" | "failed"`

116 

117 Current lifecycle status of the video job.

118 

119 - `"queued"`

120 

121 - `"in_progress"`

122 

123 - `"completed"`

124 

125 - `"failed"`

126 

127### Example

128 

129```typescript

130import OpenAI from 'openai';

131 

132const client = new OpenAI({

133 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

134});

135 

136const video = await client.videos.remix('video_123', { prompt: 'x' });

137 

138console.log(video.id);

139```

140 

141#### Response

142 

143```json

144{

145 "id": "id",

146 "completed_at": 0,

147 "created_at": 0,

148 "error": {

149 "code": "code",

150 "message": "message"

151 },

152 "expires_at": 0,

153 "model": "sora-2",

154 "object": "video",

155 "progress": 0,

156 "prompt": "prompt",

157 "remixed_from_video_id": "remixed_from_video_id",

158 "seconds": "4",

159 "size": "720x1280",

160 "status": "queued"

161}

162```

163 

164### Example

165 

166```typescript

167import OpenAI from 'openai';

168 

169const client = new OpenAI();

170 

171const video = await client.videos.remix('video_123', { prompt: 'Extend the scene with the cat taking a bow to the cheering audience' });

172 

173console.log(video.id);

174```

175 

176#### Response

177 

178```json

179{

180 "id": "video_456",

181 "object": "video",

182 "model": "sora-2",

183 "status": "queued",

184 "progress": 0,

185 "created_at": 1712698600,

186 "size": "720x1280",

187 "seconds": "8",

188 "remixed_from_video_id": "video_123"

189}

190```

Details

1## Retrieve video

2 

3`client.videos.retrieve(stringvideoID, RequestOptionsoptions?): Video`

4 

5**get** `/videos/{video_id}`

6 

7Fetch the latest metadata for a generated video.

8 

9### Parameters

10 

11- `videoID: string`

12 

13### Returns

14 

15- `Video`

16 

17 Structured information describing a generated video job.

18 

19 - `id: string`

20 

21 Unique identifier for the video job.

22 

23 - `completed_at: number | null`

24 

25 Unix timestamp (seconds) for when the job completed, if finished.

26 

27 - `created_at: number`

28 

29 Unix timestamp (seconds) for when the job was created.

30 

31 - `error: VideoCreateError | null`

32 

33 Error payload that explains why generation failed, if applicable.

34 

35 - `code: string`

36 

37 A machine-readable error code that was returned.

38 

39 - `message: string`

40 

41 A human-readable description of the error that was returned.

42 

43 - `expires_at: number | null`

44 

45 Unix timestamp (seconds) for when the downloadable assets expire, if set.

46 

47 - `model: VideoModel`

48 

49 The video generation model that produced the job.

50 

51 - `(string & {})`

52 

53 - `"sora-2" | "sora-2-pro" | "sora-2-2025-10-06" | 2 more`

54 

55 - `"sora-2"`

56 

57 - `"sora-2-pro"`

58 

59 - `"sora-2-2025-10-06"`

60 

61 - `"sora-2-pro-2025-10-06"`

62 

63 - `"sora-2-2025-12-08"`

64 

65 - `object: "video"`

66 

67 The object type, which is always `video`.

68 

69 - `"video"`

70 

71 - `progress: number`

72 

73 Approximate completion percentage for the generation task.

74 

75 - `prompt: string | null`

76 

77 The prompt that was used to generate the video.

78 

79 - `remixed_from_video_id: string | null`

80 

81 Identifier of the source video if this video is a remix.

82 

83 - `seconds: (string & {}) | VideoSeconds`

84 

85 Duration of the generated clip in seconds. For extensions, this is the stitched total duration.

86 

87 - `(string & {})`

88 

89 - `VideoSeconds = "4" | "8" | "12"`

90 

91 - `"4"`

92 

93 - `"8"`

94 

95 - `"12"`

96 

97 - `size: VideoSize`

98 

99 The resolution of the generated video.

100 

101 - `"720x1280"`

102 

103 - `"1280x720"`

104 

105 - `"1024x1792"`

106 

107 - `"1792x1024"`

108 

109 - `status: "queued" | "in_progress" | "completed" | "failed"`

110 

111 Current lifecycle status of the video job.

112 

113 - `"queued"`

114 

115 - `"in_progress"`

116 

117 - `"completed"`

118 

119 - `"failed"`

120 

121### Example

122 

123```typescript

124import OpenAI from 'openai';

125 

126const client = new OpenAI({

127 apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted

128});

129 

130const video = await client.videos.retrieve('video_123');

131 

132console.log(video.id);

133```

134 

135#### Response

136 

137```json

138{

139 "id": "id",

140 "completed_at": 0,

141 "created_at": 0,

142 "error": {

143 "code": "code",

144 "message": "message"

145 },

146 "expires_at": 0,

147 "model": "sora-2",

148 "object": "video",

149 "progress": 0,

150 "prompt": "prompt",

151 "remixed_from_video_id": "remixed_from_video_id",

152 "seconds": "4",

153 "size": "720x1280",

154 "status": "queued"

155}

156```

157 

158### Example

159 

160```typescript

161import OpenAI from 'openai';

162 

163const client = new OpenAI();

164 

165const video = await client.videos.retrieve('video_123');

166 

167console.log(video.id);

168```