go/resources/audio/index.md +0 −1346 deleted
File Deleted View Diff
1# Audio
2
3## Domain Types
4
5### Audio Model
6
7- `type AudioModel string`
8
9 - `const AudioModelWhisper1 AudioModel = "whisper-1"`
10
11 - `const AudioModelGPT4oTranscribe AudioModel = "gpt-4o-transcribe"`
12
13 - `const AudioModelGPT4oMiniTranscribe AudioModel = "gpt-4o-mini-transcribe"`
14
15 - `const AudioModelGPT4oMiniTranscribe2025_12_15 AudioModel = "gpt-4o-mini-transcribe-2025-12-15"`
16
17 - `const AudioModelGPT4oTranscribeDiarize AudioModel = "gpt-4o-transcribe-diarize"`
18
19### Audio Response Format
20
21- `type AudioResponseFormat string`
22
23 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.
24
25 - `const AudioResponseFormatJSON AudioResponseFormat = "json"`
26
27 - `const AudioResponseFormatText AudioResponseFormat = "text"`
28
29 - `const AudioResponseFormatSRT AudioResponseFormat = "srt"`
30
31 - `const AudioResponseFormatVerboseJSON AudioResponseFormat = "verbose_json"`
32
33 - `const AudioResponseFormatVTT AudioResponseFormat = "vtt"`
34
35 - `const AudioResponseFormatDiarizedJSON AudioResponseFormat = "diarized_json"`
36
37# Transcriptions
38
39## Create transcription
40
41`client.Audio.Transcriptions.New(ctx, body) (*AudioTranscriptionNewResponseUnion, error)`
42
43**post** `/audio/transcriptions`
44
45Transcribes audio into the input language.
46
47Returns a transcription object in `json`, `diarized_json`, or `verbose_json`
48format, or a stream of transcript events.
49
50### Parameters
51
52- `body AudioTranscriptionNewParams`
53
54 - `File param.Field[Reader]`
55
56 The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
57
58 - `Model param.Field[AudioModel]`
59
60 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`.
61
62 - `string`
63
64 - `type AudioModel string`
65
66 - `const AudioModelWhisper1 AudioModel = "whisper-1"`
67
68 - `const AudioModelGPT4oTranscribe AudioModel = "gpt-4o-transcribe"`
69
70 - `const AudioModelGPT4oMiniTranscribe AudioModel = "gpt-4o-mini-transcribe"`
71
72 - `const AudioModelGPT4oMiniTranscribe2025_12_15 AudioModel = "gpt-4o-mini-transcribe-2025-12-15"`
73
74 - `const AudioModelGPT4oTranscribeDiarize AudioModel = "gpt-4o-transcribe-diarize"`
75
76 - `ChunkingStrategy param.Field[AudioTranscriptionNewParamsChunkingStrategyUnion]`
77
78 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.
79
80 - `Auto`
81
82 - `const AutoAuto Auto = "auto"`
83
84 - `AudioTranscriptionNewParamsChunkingStrategyVadConfig`
85
86 - `Type string`
87
88 Must be set to `server_vad` to enable manual chunking using server side VAD.
89
90 - `const AudioTranscriptionNewParamsChunkingStrategyVadConfigTypeServerVad AudioTranscriptionNewParamsChunkingStrategyVadConfigType = "server_vad"`
91
92 - `PrefixPaddingMs int64`
93
94 Amount of audio to include before the VAD detected speech (in
95 milliseconds).
96
97 - `SilenceDurationMs int64`
98
99 Duration of silence to detect speech stop (in milliseconds).
100 With shorter values the model will respond more quickly,
101 but may jump in on short pauses from the user.
102
103 - `Threshold float64`
104
105 Sensitivity threshold (0.0 to 1.0) for voice activity detection. A
106 higher threshold will require louder audio to activate the model, and
107 thus might perform better in noisy environments.
108
109 - `Include param.Field[[]TranscriptionInclude]`
110
111 Additional information to include in the transcription response.
112 `logprobs` will return the log probabilities of the tokens in the
113 response to understand the model's confidence in the transcription.
114 `logprobs` only works with response_format set to `json` and only with
115 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`.
116
117 - `const TranscriptionIncludeLogprobs TranscriptionInclude = "logprobs"`
118
119 - `KnownSpeakerNames param.Field[[]string]`
120
121 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.
122
123 - `KnownSpeakerReferences param.Field[[]string]`
124
125 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`.
126
127 - `Language param.Field[string]`
128
129 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.
130
131 - `Prompt param.Field[string]`
132
133 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`.
134
135 - `ResponseFormat param.Field[AudioResponseFormat]`
136
137 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.
138
139 - ``
140
141 - `Temperature param.Field[float64]`
142
143 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.
144
145 - `TimestampGranularities param.Field[[]string]`
146
147 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.
148 This option is not available for `gpt-4o-transcribe-diarize`.
149
150 - `const AudioTranscriptionNewParamsTimestampGranularityWord AudioTranscriptionNewParamsTimestampGranularity = "word"`
151
152 - `const AudioTranscriptionNewParamsTimestampGranularitySegment AudioTranscriptionNewParamsTimestampGranularity = "segment"`
153
154### Returns
155
156- `type AudioTranscriptionNewResponseUnion interface{…}`
157
158 Represents a transcription response returned by model, based on the provided input.
159
160 - `type Transcription struct{…}`
161
162 Represents a transcription response returned by model, based on the provided input.
163
164 - `Text string`
165
166 The transcribed text.
167
168 - `Logprobs []TranscriptionLogprob`
169
170 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.
171
172 - `Token string`
173
174 The token in the transcription.
175
176 - `Bytes []float64`
177
178 The bytes of the token.
179
180 - `Logprob float64`
181
182 The log probability of the token.
183
184 - `Usage TranscriptionUsageUnion`
185
186 Token usage statistics for the request.
187
188 - `type TranscriptionUsageTokens struct{…}`
189
190 Usage statistics for models billed by token usage.
191
192 - `InputTokens int64`
193
194 Number of input tokens billed for this request.
195
196 - `OutputTokens int64`
197
198 Number of output tokens generated.
199
200 - `TotalTokens int64`
201
202 Total number of tokens used (input + output).
203
204 - `Type Tokens`
205
206 The type of the usage object. Always `tokens` for this variant.
207
208 - `const TokensTokens Tokens = "tokens"`
209
210 - `InputTokenDetails TranscriptionUsageTokensInputTokenDetails`
211
212 Details about the input tokens billed for this request.
213
214 - `AudioTokens int64`
215
216 Number of audio tokens billed for this request.
217
218 - `TextTokens int64`
219
220 Number of text tokens billed for this request.
221
222 - `type TranscriptionUsageDuration struct{…}`
223
224 Usage statistics for models billed by audio input duration.
225
226 - `Seconds float64`
227
228 Duration of the input audio in seconds.
229
230 - `Type Duration`
231
232 The type of the usage object. Always `duration` for this variant.
233
234 - `const DurationDuration Duration = "duration"`
235
236 - `type TranscriptionVerbose struct{…}`
237
238 Represents a verbose json transcription response returned by model, based on the provided input.
239
240 - `Duration float64`
241
242 The duration of the input audio.
243
244 - `Language string`
245
246 The language of the input audio.
247
248 - `Text string`
249
250 The transcribed text.
251
252 - `Segments []TranscriptionSegment`
253
254 Segments of the transcribed text and their corresponding details.
255
256 - `ID int64`
257
258 Unique identifier of the segment.
259
260 - `AvgLogprob float64`
261
262 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
263
264 - `CompressionRatio float64`
265
266 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
267
268 - `End float64`
269
270 End time of the segment in seconds.
271
272 - `NoSpeechProb float64`
273
274 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.
275
276 - `Seek int64`
277
278 Seek offset of the segment.
279
280 - `Start float64`
281
282 Start time of the segment in seconds.
283
284 - `Temperature float64`
285
286 Temperature parameter used for generating the segment.
287
288 - `Text string`
289
290 Text content of the segment.
291
292 - `Tokens []int64`
293
294 Array of token IDs for the text content.
295
296 - `Usage TranscriptionVerboseUsage`
297
298 Usage statistics for models billed by audio input duration.
299
300 - `Seconds float64`
301
302 Duration of the input audio in seconds.
303
304 - `Type Duration`
305
306 The type of the usage object. Always `duration` for this variant.
307
308 - `const DurationDuration Duration = "duration"`
309
310 - `Words []TranscriptionWord`
311
312 Extracted words and their corresponding timestamps.
313
314 - `End float64`
315
316 End time of the word in seconds.
317
318 - `Start float64`
319
320 Start time of the word in seconds.
321
322 - `Word string`
323
324 The text content of the word.
325
326### Example
327
328```go
329package main
330
331import (
332 "bytes"
333 "context"
334 "fmt"
335 "io"
336
337 "github.com/openai/openai-go"
338 "github.com/openai/openai-go/option"
339)
340
341func main() {
342 client := openai.NewClient(
343 option.WithAPIKey("My API Key"),
344 )
345 transcription, err := client.Audio.Transcriptions.New(context.TODO(), openai.AudioTranscriptionNewParams{
346 File: io.Reader(bytes.NewBuffer([]byte("Example data"))),
347 Model: openai.AudioModelGPT4oTranscribe,
348 })
349 if err != nil {
350 panic(err.Error())
351 }
352 fmt.Printf("%+v\n", transcription)
353}
354```
355
356#### Response
357
358```json
359{
360 "text": "text",
361 "logprobs": [
362 {
363 "token": "token",
364 "bytes": [
365 0
366 ],
367 "logprob": 0
368 }
369 ],
370 "usage": {
371 "input_tokens": 0,
372 "output_tokens": 0,
373 "total_tokens": 0,
374 "type": "tokens",
375 "input_token_details": {
376 "audio_tokens": 0,
377 "text_tokens": 0
378 }
379 }
380}
381```
382
383## Domain Types
384
385### Transcription
386
387- `type Transcription struct{…}`
388
389 Represents a transcription response returned by model, based on the provided input.
390
391 - `Text string`
392
393 The transcribed text.
394
395 - `Logprobs []TranscriptionLogprob`
396
397 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.
398
399 - `Token string`
400
401 The token in the transcription.
402
403 - `Bytes []float64`
404
405 The bytes of the token.
406
407 - `Logprob float64`
408
409 The log probability of the token.
410
411 - `Usage TranscriptionUsageUnion`
412
413 Token usage statistics for the request.
414
415 - `type TranscriptionUsageTokens struct{…}`
416
417 Usage statistics for models billed by token usage.
418
419 - `InputTokens int64`
420
421 Number of input tokens billed for this request.
422
423 - `OutputTokens int64`
424
425 Number of output tokens generated.
426
427 - `TotalTokens int64`
428
429 Total number of tokens used (input + output).
430
431 - `Type Tokens`
432
433 The type of the usage object. Always `tokens` for this variant.
434
435 - `const TokensTokens Tokens = "tokens"`
436
437 - `InputTokenDetails TranscriptionUsageTokensInputTokenDetails`
438
439 Details about the input tokens billed for this request.
440
441 - `AudioTokens int64`
442
443 Number of audio tokens billed for this request.
444
445 - `TextTokens int64`
446
447 Number of text tokens billed for this request.
448
449 - `type TranscriptionUsageDuration struct{…}`
450
451 Usage statistics for models billed by audio input duration.
452
453 - `Seconds float64`
454
455 Duration of the input audio in seconds.
456
457 - `Type Duration`
458
459 The type of the usage object. Always `duration` for this variant.
460
461 - `const DurationDuration Duration = "duration"`
462
463### Transcription Diarized
464
465- `type TranscriptionDiarized struct{…}`
466
467 Represents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.
468
469 - `Duration float64`
470
471 Duration of the input audio in seconds.
472
473 - `Segments []TranscriptionDiarizedSegment`
474
475 Segments of the transcript annotated with timestamps and speaker labels.
476
477 - `ID string`
478
479 Unique identifier for the segment.
480
481 - `End float64`
482
483 End timestamp of the segment in seconds.
484
485 - `Speaker string`
486
487 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`, ...).
488
489 - `Start float64`
490
491 Start timestamp of the segment in seconds.
492
493 - `Text string`
494
495 Transcript text for this segment.
496
497 - `Type TranscriptTextSegment`
498
499 The type of the segment. Always `transcript.text.segment`.
500
501 - `const TranscriptTextSegmentTranscriptTextSegment TranscriptTextSegment = "transcript.text.segment"`
502
503 - `Task Transcribe`
504
505 The type of task that was run. Always `transcribe`.
506
507 - `const TranscribeTranscribe Transcribe = "transcribe"`
508
509 - `Text string`
510
511 The concatenated transcript text for the entire audio input.
512
513 - `Usage TranscriptionDiarizedUsageUnion`
514
515 Token or duration usage statistics for the request.
516
517 - `TranscriptionDiarizedUsageTokens`
518
519 - `InputTokens int64`
520
521 Number of input tokens billed for this request.
522
523 - `OutputTokens int64`
524
525 Number of output tokens generated.
526
527 - `TotalTokens int64`
528
529 Total number of tokens used (input + output).
530
531 - `Type Tokens`
532
533 The type of the usage object. Always `tokens` for this variant.
534
535 - `const TokensTokens Tokens = "tokens"`
536
537 - `InputTokenDetails TranscriptionDiarizedUsageTokensInputTokenDetails`
538
539 Details about the input tokens billed for this request.
540
541 - `AudioTokens int64`
542
543 Number of audio tokens billed for this request.
544
545 - `TextTokens int64`
546
547 Number of text tokens billed for this request.
548
549 - `TranscriptionDiarizedUsageDuration`
550
551 - `Seconds float64`
552
553 Duration of the input audio in seconds.
554
555 - `Type Duration`
556
557 The type of the usage object. Always `duration` for this variant.
558
559 - `const DurationDuration Duration = "duration"`
560
561### Transcription Diarized Segment
562
563- `type TranscriptionDiarizedSegment struct{…}`
564
565 A segment of diarized transcript text with speaker metadata.
566
567 - `ID string`
568
569 Unique identifier for the segment.
570
571 - `End float64`
572
573 End timestamp of the segment in seconds.
574
575 - `Speaker string`
576
577 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`, ...).
578
579 - `Start float64`
580
581 Start timestamp of the segment in seconds.
582
583 - `Text string`
584
585 Transcript text for this segment.
586
587 - `Type TranscriptTextSegment`
588
589 The type of the segment. Always `transcript.text.segment`.
590
591 - `const TranscriptTextSegmentTranscriptTextSegment TranscriptTextSegment = "transcript.text.segment"`
592
593### Transcription Include
594
595- `type TranscriptionInclude string`
596
597 - `const TranscriptionIncludeLogprobs TranscriptionInclude = "logprobs"`
598
599### Transcription Segment
600
601- `type TranscriptionSegment struct{…}`
602
603 - `ID int64`
604
605 Unique identifier of the segment.
606
607 - `AvgLogprob float64`
608
609 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
610
611 - `CompressionRatio float64`
612
613 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
614
615 - `End float64`
616
617 End time of the segment in seconds.
618
619 - `NoSpeechProb float64`
620
621 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.
622
623 - `Seek int64`
624
625 Seek offset of the segment.
626
627 - `Start float64`
628
629 Start time of the segment in seconds.
630
631 - `Temperature float64`
632
633 Temperature parameter used for generating the segment.
634
635 - `Text string`
636
637 Text content of the segment.
638
639 - `Tokens []int64`
640
641 Array of token IDs for the text content.
642
643### Transcription Stream Event
644
645- `type TranscriptionStreamEventUnion interface{…}`
646
647 Emitted when a diarized transcription returns a completed segment with speaker information. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with `stream` set to `true` and `response_format` set to `diarized_json`.
648
649 - `type TranscriptionTextSegmentEvent struct{…}`
650
651 Emitted when a diarized transcription returns a completed segment with speaker information. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with `stream` set to `true` and `response_format` set to `diarized_json`.
652
653 - `ID string`
654
655 Unique identifier for the segment.
656
657 - `End float64`
658
659 End timestamp of the segment in seconds.
660
661 - `Speaker string`
662
663 Speaker label for this segment.
664
665 - `Start float64`
666
667 Start timestamp of the segment in seconds.
668
669 - `Text string`
670
671 Transcript text for this segment.
672
673 - `Type TranscriptTextSegment`
674
675 The type of the event. Always `transcript.text.segment`.
676
677 - `const TranscriptTextSegmentTranscriptTextSegment TranscriptTextSegment = "transcript.text.segment"`
678
679 - `type TranscriptionTextDeltaEvent struct{…}`
680
681 Emitted when there is an additional text delta. This is also the first event emitted when the transcription starts. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`.
682
683 - `Delta string`
684
685 The text delta that was additionally transcribed.
686
687 - `Type TranscriptTextDelta`
688
689 The type of the event. Always `transcript.text.delta`.
690
691 - `const TranscriptTextDeltaTranscriptTextDelta TranscriptTextDelta = "transcript.text.delta"`
692
693 - `Logprobs []TranscriptionTextDeltaEventLogprob`
694
695 The log probabilities of the delta. Only included if you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `include[]` parameter set to `logprobs`.
696
697 - `Token string`
698
699 The token that was used to generate the log probability.
700
701 - `Bytes []int64`
702
703 The bytes that were used to generate the log probability.
704
705 - `Logprob float64`
706
707 The log probability of the token.
708
709 - `SegmentID string`
710
711 Identifier of the diarized segment that this delta belongs to. Only present when using `gpt-4o-transcribe-diarize`.
712
713 - `type TranscriptionTextDoneEvent struct{…}`
714
715 Emitted when the transcription is complete. Contains the complete transcription text. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`.
716
717 - `Text string`
718
719 The text that was transcribed.
720
721 - `Type TranscriptTextDone`
722
723 The type of the event. Always `transcript.text.done`.
724
725 - `const TranscriptTextDoneTranscriptTextDone TranscriptTextDone = "transcript.text.done"`
726
727 - `Logprobs []TranscriptionTextDoneEventLogprob`
728
729 The log probabilities of the individual tokens in the transcription. Only included if you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `include[]` parameter set to `logprobs`.
730
731 - `Token string`
732
733 The token that was used to generate the log probability.
734
735 - `Bytes []int64`
736
737 The bytes that were used to generate the log probability.
738
739 - `Logprob float64`
740
741 The log probability of the token.
742
743 - `Usage TranscriptionTextDoneEventUsage`
744
745 Usage statistics for models billed by token usage.
746
747 - `InputTokens int64`
748
749 Number of input tokens billed for this request.
750
751 - `OutputTokens int64`
752
753 Number of output tokens generated.
754
755 - `TotalTokens int64`
756
757 Total number of tokens used (input + output).
758
759 - `Type Tokens`
760
761 The type of the usage object. Always `tokens` for this variant.
762
763 - `const TokensTokens Tokens = "tokens"`
764
765 - `InputTokenDetails TranscriptionTextDoneEventUsageInputTokenDetails`
766
767 Details about the input tokens billed for this request.
768
769 - `AudioTokens int64`
770
771 Number of audio tokens billed for this request.
772
773 - `TextTokens int64`
774
775 Number of text tokens billed for this request.
776
777### Transcription Text Delta Event
778
779- `type TranscriptionTextDeltaEvent struct{…}`
780
781 Emitted when there is an additional text delta. This is also the first event emitted when the transcription starts. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`.
782
783 - `Delta string`
784
785 The text delta that was additionally transcribed.
786
787 - `Type TranscriptTextDelta`
788
789 The type of the event. Always `transcript.text.delta`.
790
791 - `const TranscriptTextDeltaTranscriptTextDelta TranscriptTextDelta = "transcript.text.delta"`
792
793 - `Logprobs []TranscriptionTextDeltaEventLogprob`
794
795 The log probabilities of the delta. Only included if you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `include[]` parameter set to `logprobs`.
796
797 - `Token string`
798
799 The token that was used to generate the log probability.
800
801 - `Bytes []int64`
802
803 The bytes that were used to generate the log probability.
804
805 - `Logprob float64`
806
807 The log probability of the token.
808
809 - `SegmentID string`
810
811 Identifier of the diarized segment that this delta belongs to. Only present when using `gpt-4o-transcribe-diarize`.
812
813### Transcription Text Done Event
814
815- `type TranscriptionTextDoneEvent struct{…}`
816
817 Emitted when the transcription is complete. Contains the complete transcription text. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`.
818
819 - `Text string`
820
821 The text that was transcribed.
822
823 - `Type TranscriptTextDone`
824
825 The type of the event. Always `transcript.text.done`.
826
827 - `const TranscriptTextDoneTranscriptTextDone TranscriptTextDone = "transcript.text.done"`
828
829 - `Logprobs []TranscriptionTextDoneEventLogprob`
830
831 The log probabilities of the individual tokens in the transcription. Only included if you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `include[]` parameter set to `logprobs`.
832
833 - `Token string`
834
835 The token that was used to generate the log probability.
836
837 - `Bytes []int64`
838
839 The bytes that were used to generate the log probability.
840
841 - `Logprob float64`
842
843 The log probability of the token.
844
845 - `Usage TranscriptionTextDoneEventUsage`
846
847 Usage statistics for models billed by token usage.
848
849 - `InputTokens int64`
850
851 Number of input tokens billed for this request.
852
853 - `OutputTokens int64`
854
855 Number of output tokens generated.
856
857 - `TotalTokens int64`
858
859 Total number of tokens used (input + output).
860
861 - `Type Tokens`
862
863 The type of the usage object. Always `tokens` for this variant.
864
865 - `const TokensTokens Tokens = "tokens"`
866
867 - `InputTokenDetails TranscriptionTextDoneEventUsageInputTokenDetails`
868
869 Details about the input tokens billed for this request.
870
871 - `AudioTokens int64`
872
873 Number of audio tokens billed for this request.
874
875 - `TextTokens int64`
876
877 Number of text tokens billed for this request.
878
879### Transcription Text Segment Event
880
881- `type TranscriptionTextSegmentEvent struct{…}`
882
883 Emitted when a diarized transcription returns a completed segment with speaker information. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with `stream` set to `true` and `response_format` set to `diarized_json`.
884
885 - `ID string`
886
887 Unique identifier for the segment.
888
889 - `End float64`
890
891 End timestamp of the segment in seconds.
892
893 - `Speaker string`
894
895 Speaker label for this segment.
896
897 - `Start float64`
898
899 Start timestamp of the segment in seconds.
900
901 - `Text string`
902
903 Transcript text for this segment.
904
905 - `Type TranscriptTextSegment`
906
907 The type of the event. Always `transcript.text.segment`.
908
909 - `const TranscriptTextSegmentTranscriptTextSegment TranscriptTextSegment = "transcript.text.segment"`
910
911### Transcription Verbose
912
913- `type TranscriptionVerbose struct{…}`
914
915 Represents a verbose json transcription response returned by model, based on the provided input.
916
917 - `Duration float64`
918
919 The duration of the input audio.
920
921 - `Language string`
922
923 The language of the input audio.
924
925 - `Text string`
926
927 The transcribed text.
928
929 - `Segments []TranscriptionSegment`
930
931 Segments of the transcribed text and their corresponding details.
932
933 - `ID int64`
934
935 Unique identifier of the segment.
936
937 - `AvgLogprob float64`
938
939 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
940
941 - `CompressionRatio float64`
942
943 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
944
945 - `End float64`
946
947 End time of the segment in seconds.
948
949 - `NoSpeechProb float64`
950
951 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.
952
953 - `Seek int64`
954
955 Seek offset of the segment.
956
957 - `Start float64`
958
959 Start time of the segment in seconds.
960
961 - `Temperature float64`
962
963 Temperature parameter used for generating the segment.
964
965 - `Text string`
966
967 Text content of the segment.
968
969 - `Tokens []int64`
970
971 Array of token IDs for the text content.
972
973 - `Usage TranscriptionVerboseUsage`
974
975 Usage statistics for models billed by audio input duration.
976
977 - `Seconds float64`
978
979 Duration of the input audio in seconds.
980
981 - `Type Duration`
982
983 The type of the usage object. Always `duration` for this variant.
984
985 - `const DurationDuration Duration = "duration"`
986
987 - `Words []TranscriptionWord`
988
989 Extracted words and their corresponding timestamps.
990
991 - `End float64`
992
993 End time of the word in seconds.
994
995 - `Start float64`
996
997 Start time of the word in seconds.
998
999 - `Word string`
1000
1001 The text content of the word.
1002
1003### Transcription Word
1004
1005- `type TranscriptionWord struct{…}`
1006
1007 - `End float64`
1008
1009 End time of the word in seconds.
1010
1011 - `Start float64`
1012
1013 Start time of the word in seconds.
1014
1015 - `Word string`
1016
1017 The text content of the word.
1018
1019# Translations
1020
1021## Create translation
1022
1023`client.Audio.Translations.New(ctx, body) (*Translation, error)`
1024
1025**post** `/audio/translations`
1026
1027Translates audio into English.
1028
1029### Parameters
1030
1031- `body AudioTranslationNewParams`
1032
1033 - `File param.Field[Reader]`
1034
1035 The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
1036
1037 - `Model param.Field[AudioModel]`
1038
1039 ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
1040
1041 - `string`
1042
1043 - `type AudioModel string`
1044
1045 - `const AudioModelWhisper1 AudioModel = "whisper-1"`
1046
1047 - `const AudioModelGPT4oTranscribe AudioModel = "gpt-4o-transcribe"`
1048
1049 - `const AudioModelGPT4oMiniTranscribe AudioModel = "gpt-4o-mini-transcribe"`
1050
1051 - `const AudioModelGPT4oMiniTranscribe2025_12_15 AudioModel = "gpt-4o-mini-transcribe-2025-12-15"`
1052
1053 - `const AudioModelGPT4oTranscribeDiarize AudioModel = "gpt-4o-transcribe-diarize"`
1054
1055 - `Prompt param.Field[string]`
1056
1057 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.
1058
1059 - `ResponseFormat param.Field[AudioTranslationNewParamsResponseFormat]`
1060
1061 The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`.
1062
1063 - `const AudioTranslationNewParamsResponseFormatJSON AudioTranslationNewParamsResponseFormat = "json"`
1064
1065 - `const AudioTranslationNewParamsResponseFormatText AudioTranslationNewParamsResponseFormat = "text"`
1066
1067 - `const AudioTranslationNewParamsResponseFormatSRT AudioTranslationNewParamsResponseFormat = "srt"`
1068
1069 - `const AudioTranslationNewParamsResponseFormatVerboseJSON AudioTranslationNewParamsResponseFormat = "verbose_json"`
1070
1071 - `const AudioTranslationNewParamsResponseFormatVTT AudioTranslationNewParamsResponseFormat = "vtt"`
1072
1073 - `Temperature param.Field[float64]`
1074
1075 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.
1076
1077### Returns
1078
1079- `type AudioTranslationNewResponse interface{…}`
1080
1081 - `type Translation struct{…}`
1082
1083 - `Text string`
1084
1085### Example
1086
1087```go
1088package main
1089
1090import (
1091 "bytes"
1092 "context"
1093 "fmt"
1094 "io"
1095
1096 "github.com/openai/openai-go"
1097 "github.com/openai/openai-go/option"
1098)
1099
1100func main() {
1101 client := openai.NewClient(
1102 option.WithAPIKey("My API Key"),
1103 )
1104 translation, err := client.Audio.Translations.New(context.TODO(), openai.AudioTranslationNewParams{
1105 File: io.Reader(bytes.NewBuffer([]byte("Example data"))),
1106 Model: openai.AudioModelWhisper1,
1107 })
1108 if err != nil {
1109 panic(err.Error())
1110 }
1111 fmt.Printf("%+v\n", translation)
1112}
1113```
1114
1115#### Response
1116
1117```json
1118{
1119 "text": "text"
1120}
1121```
1122
1123## Domain Types
1124
1125### Translation
1126
1127- `type Translation struct{…}`
1128
1129 - `Text string`
1130
1131### Translation Verbose
1132
1133- `type TranslationVerbose struct{…}`
1134
1135 - `Duration float64`
1136
1137 The duration of the input audio.
1138
1139 - `Language string`
1140
1141 The language of the output translation (always `english`).
1142
1143 - `Text string`
1144
1145 The translated text.
1146
1147 - `Segments []TranscriptionSegment`
1148
1149 Segments of the translated text and their corresponding details.
1150
1151 - `ID int64`
1152
1153 Unique identifier of the segment.
1154
1155 - `AvgLogprob float64`
1156
1157 Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
1158
1159 - `CompressionRatio float64`
1160
1161 Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
1162
1163 - `End float64`
1164
1165 End time of the segment in seconds.
1166
1167 - `NoSpeechProb float64`
1168
1169 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.
1170
1171 - `Seek int64`
1172
1173 Seek offset of the segment.
1174
1175 - `Start float64`
1176
1177 Start time of the segment in seconds.
1178
1179 - `Temperature float64`
1180
1181 Temperature parameter used for generating the segment.
1182
1183 - `Text string`
1184
1185 Text content of the segment.
1186
1187 - `Tokens []int64`
1188
1189 Array of token IDs for the text content.
1190
1191# Speech
1192
1193## Create speech
1194
1195`client.Audio.Speech.New(ctx, body) (*Response, error)`
1196
1197**post** `/audio/speech`
1198
1199Generates audio from the input text.
1200
1201Returns the audio file content, or a stream of audio events.
1202
1203### Parameters
1204
1205- `body AudioSpeechNewParams`
1206
1207 - `Input param.Field[string]`
1208
1209 The text to generate audio for. The maximum length is 4096 characters.
1210
1211 - `Model param.Field[SpeechModel]`
1212
1213 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`.
1214
1215 - `string`
1216
1217 - `type SpeechModel string`
1218
1219 - `const SpeechModelTTS1 SpeechModel = "tts-1"`
1220
1221 - `const SpeechModelTTS1HD SpeechModel = "tts-1-hd"`
1222
1223 - `const SpeechModelGPT4oMiniTTS SpeechModel = "gpt-4o-mini-tts"`
1224
1225 - `const SpeechModelGPT4oMiniTTS2025_12_15 SpeechModel = "gpt-4o-mini-tts-2025-12-15"`
1226
1227 - `Voice param.Field[AudioSpeechNewParamsVoiceUnion]`
1228
1229 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).
1230
1231 - `string`
1232
1233 - `type AudioSpeechNewParamsVoiceString string`
1234
1235 - `const AudioSpeechNewParamsVoiceStringAlloy AudioSpeechNewParamsVoiceString = "alloy"`
1236
1237 - `const AudioSpeechNewParamsVoiceStringAsh AudioSpeechNewParamsVoiceString = "ash"`
1238
1239 - `const AudioSpeechNewParamsVoiceStringBallad AudioSpeechNewParamsVoiceString = "ballad"`
1240
1241 - `const AudioSpeechNewParamsVoiceStringCoral AudioSpeechNewParamsVoiceString = "coral"`
1242
1243 - `const AudioSpeechNewParamsVoiceStringEcho AudioSpeechNewParamsVoiceString = "echo"`
1244
1245 - `const AudioSpeechNewParamsVoiceStringSage AudioSpeechNewParamsVoiceString = "sage"`
1246
1247 - `const AudioSpeechNewParamsVoiceStringShimmer AudioSpeechNewParamsVoiceString = "shimmer"`
1248
1249 - `const AudioSpeechNewParamsVoiceStringVerse AudioSpeechNewParamsVoiceString = "verse"`
1250
1251 - `const AudioSpeechNewParamsVoiceStringMarin AudioSpeechNewParamsVoiceString = "marin"`
1252
1253 - `const AudioSpeechNewParamsVoiceStringCedar AudioSpeechNewParamsVoiceString = "cedar"`
1254
1255 - `type AudioSpeechNewParamsVoiceID struct{…}`
1256
1257 Custom voice reference.
1258
1259 - `ID string`
1260
1261 The custom voice ID, e.g. `voice_1234`.
1262
1263 - `Instructions param.Field[string]`
1264
1265 Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.
1266
1267 - `ResponseFormat param.Field[AudioSpeechNewParamsResponseFormat]`
1268
1269 The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.
1270
1271 - `const AudioSpeechNewParamsResponseFormatMP3 AudioSpeechNewParamsResponseFormat = "mp3"`
1272
1273 - `const AudioSpeechNewParamsResponseFormatOpus AudioSpeechNewParamsResponseFormat = "opus"`
1274
1275 - `const AudioSpeechNewParamsResponseFormatAAC AudioSpeechNewParamsResponseFormat = "aac"`
1276
1277 - `const AudioSpeechNewParamsResponseFormatFLAC AudioSpeechNewParamsResponseFormat = "flac"`
1278
1279 - `const AudioSpeechNewParamsResponseFormatWAV AudioSpeechNewParamsResponseFormat = "wav"`
1280
1281 - `const AudioSpeechNewParamsResponseFormatPCM AudioSpeechNewParamsResponseFormat = "pcm"`
1282
1283 - `Speed param.Field[float64]`
1284
1285 The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.
1286
1287 - `StreamFormat param.Field[AudioSpeechNewParamsStreamFormat]`
1288
1289 The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.
1290
1291 - `const AudioSpeechNewParamsStreamFormatSSE AudioSpeechNewParamsStreamFormat = "sse"`
1292
1293 - `const AudioSpeechNewParamsStreamFormatAudio AudioSpeechNewParamsStreamFormat = "audio"`
1294
1295### Returns
1296
1297- `type AudioSpeechNewResponse interface{…}`
1298
1299### Example
1300
1301```go
1302package main
1303
1304import (
1305 "context"
1306 "fmt"
1307
1308 "github.com/openai/openai-go"
1309 "github.com/openai/openai-go/option"
1310)
1311
1312func main() {
1313 client := openai.NewClient(
1314 option.WithAPIKey("My API Key"),
1315 )
1316 speech, err := client.Audio.Speech.New(context.TODO(), openai.AudioSpeechNewParams{
1317 Input: "input",
1318 Model: openai.SpeechModelTTS1,
1319 Voice: openai.AudioSpeechNewParamsVoiceUnion{
1320 OfString: openai.String("string"),
1321 },
1322 })
1323 if err != nil {
1324 panic(err.Error())
1325 }
1326 fmt.Printf("%+v\n", speech)
1327}
1328```
1329
1330## Domain Types
1331
1332### Speech Model
1333
1334- `type SpeechModel string`
1335
1336 - `const SpeechModelTTS1 SpeechModel = "tts-1"`
1337
1338 - `const SpeechModelTTS1HD SpeechModel = "tts-1-hd"`
1339
1340 - `const SpeechModelGPT4oMiniTTS SpeechModel = "gpt-4o-mini-tts"`
1341
1342 - `const SpeechModelGPT4oMiniTTS2025_12_15 SpeechModel = "gpt-4o-mini-tts-2025-12-15"`
1343
1344# Voices
1345
1346# Voice Consents