Skip to content

Commit 890595e

Browse files
feat(api): Add audio.voices.list sdk
1 parent 5062932 commit 890595e

File tree

6 files changed

+89
-2
lines changed

6 files changed

+89
-2
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 44
1+
configured_endpoints: 45
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-e63ffcd87a8f3f9a97e523c95927843e7e4ce8e2788aec58a16313759eb4cee8.yml
33
openapi_spec_hash: 2772702ed4747586ac0776fcd227e41f
4-
config_hash: acbe45d94a426c68447621ec5213405e
4+
config_hash: 5e9563faf41fd9a91bea97783683bdb2

api.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ Methods:
164164

165165
- <code title="post /audio/speech">client.audio.<a href="./src/resources/audio/audio.ts">create</a>({ ...params }) -> Response</code>
166166

167+
## Voices
168+
169+
Types:
170+
171+
- <code><a href="./src/resources/audio/voices.ts">VoiceListResponse</a></code>
172+
173+
Methods:
174+
175+
- <code title="get /voices">client.audio.voices.<a href="./src/resources/audio/voices.ts">list</a>() -> VoiceListResponse</code>
176+
167177
## Transcriptions
168178

169179
Types:

src/resources/audio/audio.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ import * as TranscriptionsAPI from './transcriptions';
66
import { TranscriptionCreateParams, TranscriptionCreateResponse, Transcriptions } from './transcriptions';
77
import * as TranslationsAPI from './translations';
88
import { TranslationCreateParams, TranslationCreateResponse, Translations } from './translations';
9+
import * as VoicesAPI from './voices';
10+
import { VoiceListResponse, Voices } from './voices';
911
import { APIPromise } from '../../core/api-promise';
1012
import { Stream } from '../../core/streaming';
1113
import { buildHeaders } from '../../internal/headers';
1214
import { RequestOptions } from '../../internal/request-options';
1315

1416
export class Audio extends APIResource {
17+
voices: VoicesAPI.Voices = new VoicesAPI.Voices(this._client);
1518
transcriptions: TranscriptionsAPI.Transcriptions = new TranscriptionsAPI.Transcriptions(this._client);
1619
translations: TranslationsAPI.Translations = new TranslationsAPI.Translations(this._client);
1720

@@ -175,6 +178,7 @@ export interface AudioCreateParamsStreaming extends AudioCreateParamsBase {
175178
stream: true;
176179
}
177180

181+
Audio.Voices = Voices;
178182
Audio.Transcriptions = Transcriptions;
179183
Audio.Translations = Translations;
180184

@@ -187,6 +191,8 @@ export declare namespace Audio {
187191
type AudioCreateParamsStreaming as AudioCreateParamsStreaming,
188192
};
189193

194+
export { Voices as Voices, type VoiceListResponse as VoiceListResponse };
195+
190196
export {
191197
Transcriptions as Transcriptions,
192198
type TranscriptionCreateResponse as TranscriptionCreateResponse,

src/resources/audio/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ export {
1414
type TranscriptionCreateParams,
1515
} from './transcriptions';
1616
export { Translations, type TranslationCreateResponse, type TranslationCreateParams } from './translations';
17+
export { Voices, type VoiceListResponse } from './voices';

src/resources/audio/voices.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../../core/resource';
4+
import { APIPromise } from '../../core/api-promise';
5+
import { RequestOptions } from '../../internal/request-options';
6+
7+
export class Voices extends APIResource {
8+
/**
9+
* Fetch available voices for each model
10+
*
11+
* @example
12+
* ```ts
13+
* const voices = await client.audio.voices.list();
14+
* ```
15+
*/
16+
list(options?: RequestOptions): APIPromise<VoiceListResponse> {
17+
return this._client.get('/voices', options);
18+
}
19+
}
20+
21+
/**
22+
* Response containing a list of models and their available voices.
23+
*/
24+
export interface VoiceListResponse {
25+
data: Array<VoiceListResponse.Data>;
26+
}
27+
28+
export namespace VoiceListResponse {
29+
/**
30+
* Represents a model with its available voices.
31+
*/
32+
export interface Data {
33+
model: string;
34+
35+
voices: Array<Data.Voice>;
36+
}
37+
38+
export namespace Data {
39+
export interface Voice {
40+
id: string;
41+
42+
name: string;
43+
}
44+
}
45+
}
46+
47+
export declare namespace Voices {
48+
export { type VoiceListResponse as VoiceListResponse };
49+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import Together from 'together-ai';
4+
5+
const client = new Together({
6+
apiKey: 'My API Key',
7+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
8+
});
9+
10+
describe('resource voices', () => {
11+
test('list', async () => {
12+
const responsePromise = client.audio.voices.list();
13+
const rawResponse = await responsePromise.asResponse();
14+
expect(rawResponse).toBeInstanceOf(Response);
15+
const response = await responsePromise;
16+
expect(response).not.toBeInstanceOf(Response);
17+
const dataAndResponse = await responsePromise.withResponse();
18+
expect(dataAndResponse.data).toBe(response);
19+
expect(dataAndResponse.response).toBe(rawResponse);
20+
});
21+
});

0 commit comments

Comments
 (0)