resources/audio/subresources/speech/index.md +0 −154 deleted
File Deleted View Diff
1# Speech
2
3## Create speech
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### Body 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](/docs/models#tts): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.
20
21 - `string`
22
23 - `SpeechModel = "tts-1" or "tts-1-hd" or "gpt-4o-mini-tts" or "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 or "alloy" or "ash" or "ballad" or 7 more or object { 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](/docs/guides/text-to-speech#voice-options).
36
37 - `string`
38
39 - `"alloy" or "ash" or "ballad" or 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 - `ID object { id }`
62
63 Custom voice reference.
64
65 - `id: string`
66
67 The custom voice ID, e.g. `voice_1234`.
68
69- `instructions: optional 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: optional "mp3" or "opus" or "aac" or 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 number`
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 "sse" or "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### Example
102
103```http
104curl https://api.openai.com/v1/audio/speech \
105 -H 'Content-Type: application/json' \
106 -H "Authorization: Bearer $OPENAI_API_KEY" \
107 -d '{
108 "input": "input",
109 "model": "string",
110 "voice": "string"
111 }'
112```
113
114### Example
115
116```http
117curl https://api.openai.com/v1/audio/speech \
118 -H "Authorization: Bearer $OPENAI_API_KEY" \
119 -H "Content-Type: application/json" \
120 -d '{
121 "model": "gpt-4o-mini-tts",
122 "input": "The quick brown fox jumped over the lazy dog.",
123 "voice": "alloy"
124 }' \
125 --output speech.mp3
126```
127
128### SSE Stream Format
129
130```http
131curl https://api.openai.com/v1/audio/speech \
132 -H "Authorization: Bearer $OPENAI_API_KEY" \
133 -H "Content-Type: application/json" \
134 -d '{
135 "model": "gpt-4o-mini-tts",
136 "input": "The quick brown fox jumped over the lazy dog.",
137 "voice": "alloy",
138 "stream_format": "sse"
139 }'
140```
141
142## Domain Types
143
144### Speech Model
145
146- `SpeechModel = "tts-1" or "tts-1-hd" or "gpt-4o-mini-tts" or "gpt-4o-mini-tts-2025-12-15"`
147
148 - `"tts-1"`
149
150 - `"tts-1-hd"`
151
152 - `"gpt-4o-mini-tts"`
153
154 - `"gpt-4o-mini-tts-2025-12-15"`