Skip to content

Commit 74776c6

Browse files
feat(api): update enum values, comments, and examples (#1280)
1 parent 0fae08b commit 74776c6

File tree

9 files changed

+49
-66
lines changed

9 files changed

+49
-66
lines changed

Diff for: .stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 69
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b5b0e2c794b012919701c3fd43286af10fa25d33ceb8a881bec2636028f446e0.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-3904ef6b29a89c98f93a9b7da19879695f3c440564be6384db7af1b734611ede.yml

Diff for: src/resources/audio/speech.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ export interface SpeechCreateParams {
3333
model: (string & {}) | SpeechModel;
3434

3535
/**
36-
* The voice to use when generating the audio. Supported voices are `alloy`,
37-
* `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are
38-
* available in the
36+
* The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
37+
* `coral`, `echo`, `fable`, `onyx`, `nova`, `sage` and `shimmer`. Previews of the
38+
* voices are available in the
3939
* [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
4040
*/
41-
voice: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
41+
voice: 'alloy' | 'ash' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer';
4242

4343
/**
4444
* The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,

Diff for: src/resources/beta/realtime/realtime.ts

+18-14
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@ export interface ConversationItemCreateEvent {
173173

174174
/**
175175
* The ID of the preceding item after which the new item will be inserted. If not
176-
* set, the new item will be appended to the end of the conversation. If set, it
177-
* allows an item to be inserted mid-conversation. If the ID cannot be found, an
178-
* error will be returned and the item will not be added.
176+
* set, the new item will be appended to the end of the conversation. If set to
177+
* `root`, the new item will be added to the beginning of the conversation. If set
178+
* to an existing ID, it allows an item to be inserted mid-conversation. If the ID
179+
* cannot be found, an error will be returned and the item will not be added.
179180
*/
180181
previous_item_id?: string;
181182
}
@@ -1705,17 +1706,9 @@ export namespace SessionUpdateEvent {
17051706
*/
17061707
export interface Session {
17071708
/**
1708-
* The Realtime model used for this session.
1709-
*/
1710-
model:
1711-
| 'gpt-4o-realtime-preview'
1712-
| 'gpt-4o-realtime-preview-2024-10-01'
1713-
| 'gpt-4o-realtime-preview-2024-12-17'
1714-
| 'gpt-4o-mini-realtime-preview'
1715-
| 'gpt-4o-mini-realtime-preview-2024-12-17';
1716-
1717-
/**
1718-
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
1709+
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
1710+
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
1711+
* (mono), and little-endian byte order.
17191712
*/
17201713
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
17211714

@@ -1756,8 +1749,19 @@ export namespace SessionUpdateEvent {
17561749
*/
17571750
modalities?: Array<'text' | 'audio'>;
17581751

1752+
/**
1753+
* The Realtime model used for this session.
1754+
*/
1755+
model?:
1756+
| 'gpt-4o-realtime-preview'
1757+
| 'gpt-4o-realtime-preview-2024-10-01'
1758+
| 'gpt-4o-realtime-preview-2024-12-17'
1759+
| 'gpt-4o-mini-realtime-preview'
1760+
| 'gpt-4o-mini-realtime-preview-2024-12-17';
1761+
17591762
/**
17601763
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
1764+
* For `pcm16`, output audio is sampled at a rate of 24kHz.
17611765
*/
17621766
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
17631767

Diff for: src/resources/beta/realtime/sessions.ts

+18-12
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ export interface Session {
3232
id?: string;
3333

3434
/**
35-
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
35+
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
36+
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
37+
* (mono), and little-endian byte order.
3638
*/
3739
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
3840

@@ -86,6 +88,7 @@ export interface Session {
8688

8789
/**
8890
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
91+
* For `pcm16`, output audio is sampled at a rate of 24kHz.
8992
*/
9093
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
9194

@@ -372,17 +375,9 @@ export namespace SessionCreateResponse {
372375

373376
export interface SessionCreateParams {
374377
/**
375-
* The Realtime model used for this session.
376-
*/
377-
model:
378-
| 'gpt-4o-realtime-preview'
379-
| 'gpt-4o-realtime-preview-2024-10-01'
380-
| 'gpt-4o-realtime-preview-2024-12-17'
381-
| 'gpt-4o-mini-realtime-preview'
382-
| 'gpt-4o-mini-realtime-preview-2024-12-17';
383-
384-
/**
385-
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
378+
* The format of input audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`. For
379+
* `pcm16`, input audio must be 16-bit PCM at a 24kHz sample rate, single channel
380+
* (mono), and little-endian byte order.
386381
*/
387382
input_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
388383

@@ -423,8 +418,19 @@ export interface SessionCreateParams {
423418
*/
424419
modalities?: Array<'text' | 'audio'>;
425420

421+
/**
422+
* The Realtime model used for this session.
423+
*/
424+
model?:
425+
| 'gpt-4o-realtime-preview'
426+
| 'gpt-4o-realtime-preview-2024-10-01'
427+
| 'gpt-4o-realtime-preview-2024-12-17'
428+
| 'gpt-4o-mini-realtime-preview'
429+
| 'gpt-4o-mini-realtime-preview-2024-12-17';
430+
426431
/**
427432
* The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
433+
* For `pcm16`, output audio is sampled at a rate of 24kHz.
428434
*/
429435
output_audio_format?: 'pcm16' | 'g711_ulaw' | 'g711_alaw';
430436

Diff for: src/resources/chat/completions.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ export interface ChatCompletion {
7676
object: 'chat.completion';
7777

7878
/**
79-
* The service tier used for processing the request. This field is only included if
80-
* the `service_tier` parameter is specified in the request.
79+
* The service tier used for processing the request.
8180
*/
8281
service_tier?: 'scale' | 'default' | null;
8382

@@ -300,8 +299,7 @@ export interface ChatCompletionChunk {
300299
object: 'chat.completion.chunk';
301300

302301
/**
303-
* The service tier used for processing the request. This field is only included if
304-
* the `service_tier` parameter is specified in the request.
302+
* The service tier used for processing the request.
305303
*/
306304
service_tier?: 'scale' | 'default' | null;
307305

@@ -1115,9 +1113,6 @@ export interface ChatCompletionCreateParamsBase {
11151113
* - If set to 'default', the request will be processed using the default service
11161114
* tier with a lower uptime SLA and no latency guarentee.
11171115
* - When not set, the default behavior is 'auto'.
1118-
*
1119-
* When this parameter is set, the response body will include the `service_tier`
1120-
* utilized.
11211116
*/
11221117
service_tier?: 'auto' | 'default' | null;
11231118

Diff for: src/resources/embeddings.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ export interface EmbeddingCreateParams {
8686
* `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048
8787
* dimensions or less.
8888
* [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken)
89-
* for counting tokens.
89+
* for counting tokens. Some models may also impose a limit on total number of
90+
* tokens summed across inputs.
9091
*/
9192
input: string | Array<string> | Array<number> | Array<Array<number>>;
9293

Diff for: tests/api-resources/beta/realtime/sessions.test.ts

+2-25
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const client = new OpenAI({
99
});
1010

1111
describe('resource sessions', () => {
12-
test('create: only required params', async () => {
13-
const responsePromise = client.beta.realtime.sessions.create({ model: 'gpt-4o-realtime-preview' });
12+
test('create', async () => {
13+
const responsePromise = client.beta.realtime.sessions.create({});
1414
const rawResponse = await responsePromise.asResponse();
1515
expect(rawResponse).toBeInstanceOf(Response);
1616
const response = await responsePromise;
@@ -19,27 +19,4 @@ describe('resource sessions', () => {
1919
expect(dataAndResponse.data).toBe(response);
2020
expect(dataAndResponse.response).toBe(rawResponse);
2121
});
22-
23-
test('create: required and optional params', async () => {
24-
const response = await client.beta.realtime.sessions.create({
25-
model: 'gpt-4o-realtime-preview',
26-
input_audio_format: 'pcm16',
27-
input_audio_transcription: { model: 'model' },
28-
instructions: 'instructions',
29-
max_response_output_tokens: 0,
30-
modalities: ['text'],
31-
output_audio_format: 'pcm16',
32-
temperature: 0,
33-
tool_choice: 'tool_choice',
34-
tools: [{ description: 'description', name: 'name', parameters: {}, type: 'function' }],
35-
turn_detection: {
36-
create_response: true,
37-
prefix_padding_ms: 0,
38-
silence_duration_ms: 0,
39-
threshold: 0,
40-
type: 'type',
41-
},
42-
voice: 'alloy',
43-
});
44-
});
4522
});

Diff for: tests/api-resources/chat/completions.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('resource completions', () => {
4343
presence_penalty: -2,
4444
reasoning_effort: 'low',
4545
response_format: { type: 'text' },
46-
seed: -9007199254740991,
46+
seed: 0,
4747
service_tier: 'auto',
4848
stop: 'string',
4949
store: true,

Diff for: tests/api-resources/completions.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('resource completions', () => {
3232
max_tokens: 16,
3333
n: 1,
3434
presence_penalty: -2,
35-
seed: -9007199254740991,
35+
seed: 0,
3636
stop: '\n',
3737
stream: false,
3838
stream_options: { include_usage: true },

0 commit comments

Comments
 (0)