Skip to content

Commit 1623e36

Browse files
chore(internal): codegen related update
1 parent 189af12 commit 1623e36

File tree

20 files changed

+422
-0
lines changed

20 files changed

+422
-0
lines changed

src/resources/audio/speech.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ import { RequestOptions } from '../../internal/request-options';
88
export class Speech extends APIResource {
99
/**
1010
* Generates audio from the input text.
11+
*
12+
* @example
13+
* ```ts
14+
* const speech = await client.audio.speech.create({
15+
* input: 'input',
16+
* model: 'string',
17+
* voice: 'ash',
18+
* });
19+
*
20+
* const content = await speech.blob();
21+
* console.log(content);
22+
* ```
1123
*/
1224
create(body: SpeechCreateParams, options?: RequestOptions): APIPromise<Response> {
1325
return this._client.post('/audio/speech', {

src/resources/audio/transcriptions.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ import { multipartFormRequestOptions } from '../../internal/uploads';
1212
export class Transcriptions extends APIResource {
1313
/**
1414
* Transcribes audio into the input language.
15+
*
16+
* @example
17+
* ```ts
18+
* const transcription =
19+
* await client.audio.transcriptions.create({
20+
* file: fs.createReadStream('speech.mp3'),
21+
* model: 'gpt-4o-transcribe',
22+
* });
23+
* ```
1524
*/
1625
create(
1726
body: TranscriptionCreateParamsNonStreaming,

src/resources/audio/translations.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ import { multipartFormRequestOptions } from '../../internal/uploads';
1111
export class Translations extends APIResource {
1212
/**
1313
* Translates audio into English.
14+
*
15+
* @example
16+
* ```ts
17+
* const translation = await client.audio.translations.create({
18+
* file: fs.createReadStream('speech.mp3'),
19+
* model: 'whisper-1',
20+
* });
21+
* ```
1422
*/
1523
create(body: TranslationCreateParams, options?: RequestOptions): APIPromise<TranslationCreateResponse> {
1624
return this._client.post(

src/resources/beta/assistants.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ import { path } from '../../internal/utils/path';
1515
export class Assistants extends APIResource {
1616
/**
1717
* Create an assistant with a model and instructions.
18+
*
19+
* @example
20+
* ```ts
21+
* const assistant = await client.beta.assistants.create({
22+
* model: 'gpt-4o',
23+
* });
24+
* ```
1825
*/
1926
create(body: AssistantCreateParams, options?: RequestOptions): APIPromise<Assistant> {
2027
return this._client.post('/assistants', {
@@ -26,6 +33,13 @@ export class Assistants extends APIResource {
2633

2734
/**
2835
* Retrieves an assistant.
36+
*
37+
* @example
38+
* ```ts
39+
* const assistant = await client.beta.assistants.retrieve(
40+
* 'assistant_id',
41+
* );
42+
* ```
2943
*/
3044
retrieve(assistantID: string, options?: RequestOptions): APIPromise<Assistant> {
3145
return this._client.get(path`/assistants/${assistantID}`, {
@@ -36,6 +50,13 @@ export class Assistants extends APIResource {
3650

3751
/**
3852
* Modifies an assistant.
53+
*
54+
* @example
55+
* ```ts
56+
* const assistant = await client.beta.assistants.update(
57+
* 'assistant_id',
58+
* );
59+
* ```
3960
*/
4061
update(assistantID: string, body: AssistantUpdateParams, options?: RequestOptions): APIPromise<Assistant> {
4162
return this._client.post(path`/assistants/${assistantID}`, {
@@ -47,6 +68,14 @@ export class Assistants extends APIResource {
4768

4869
/**
4970
* Returns a list of assistants.
71+
*
72+
* @example
73+
* ```ts
74+
* // Automatically fetches more pages as needed.
75+
* for await (const assistant of client.beta.assistants.list()) {
76+
* // ...
77+
* }
78+
* ```
5079
*/
5180
list(
5281
query: AssistantListParams | null | undefined = {},
@@ -61,6 +90,12 @@ export class Assistants extends APIResource {
6190

6291
/**
6392
* Delete an assistant.
93+
*
94+
* @example
95+
* ```ts
96+
* const assistantDeleted =
97+
* await client.beta.assistants.delete('assistant_id');
98+
* ```
6499
*/
65100
delete(assistantID: string, options?: RequestOptions): APIPromise<AssistantDeleted> {
66101
return this._client.delete(path`/assistants/${assistantID}`, {

src/resources/beta/realtime/sessions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ export class Sessions extends APIResource {
1414
* It responds with a session object, plus a `client_secret` key which contains a
1515
* usable ephemeral API token that can be used to authenticate browser clients for
1616
* the Realtime API.
17+
*
18+
* @example
19+
* ```ts
20+
* const session =
21+
* await client.beta.realtime.sessions.create();
22+
* ```
1723
*/
1824
create(body: SessionCreateParams, options?: RequestOptions): APIPromise<SessionCreateResponse> {
1925
return this._client.post('/realtime/sessions', {

src/resources/beta/realtime/transcription-sessions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ export class TranscriptionSessions extends APIResource {
1414
* It responds with a session object, plus a `client_secret` key which contains a
1515
* usable ephemeral API token that can be used to authenticate browser clients for
1616
* the Realtime API.
17+
*
18+
* @example
19+
* ```ts
20+
* const transcriptionSession =
21+
* await client.beta.realtime.transcriptionSessions.create();
22+
* ```
1723
*/
1824
create(body: TranscriptionSessionCreateParams, options?: RequestOptions): APIPromise<TranscriptionSession> {
1925
return this._client.post('/realtime/transcription_sessions', {

src/resources/beta/threads/messages.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ import { path } from '../../../internal/utils/path';
1212
export class Messages extends APIResource {
1313
/**
1414
* Create a message.
15+
*
16+
* @example
17+
* ```ts
18+
* const message = await client.beta.threads.messages.create(
19+
* 'thread_id',
20+
* { content: 'string', role: 'user' },
21+
* );
22+
* ```
1523
*/
1624
create(threadID: string, body: MessageCreateParams, options?: RequestOptions): APIPromise<Message> {
1725
return this._client.post(path`/threads/${threadID}/messages`, {
@@ -23,6 +31,14 @@ export class Messages extends APIResource {
2331

2432
/**
2533
* Retrieve a message.
34+
*
35+
* @example
36+
* ```ts
37+
* const message = await client.beta.threads.messages.retrieve(
38+
* 'message_id',
39+
* { thread_id: 'thread_id' },
40+
* );
41+
* ```
2642
*/
2743
retrieve(messageID: string, params: MessageRetrieveParams, options?: RequestOptions): APIPromise<Message> {
2844
const { thread_id } = params;
@@ -34,6 +50,14 @@ export class Messages extends APIResource {
3450

3551
/**
3652
* Modifies a message.
53+
*
54+
* @example
55+
* ```ts
56+
* const message = await client.beta.threads.messages.update(
57+
* 'message_id',
58+
* { thread_id: 'thread_id' },
59+
* );
60+
* ```
3761
*/
3862
update(messageID: string, params: MessageUpdateParams, options?: RequestOptions): APIPromise<Message> {
3963
const { thread_id, ...body } = params;
@@ -46,6 +70,16 @@ export class Messages extends APIResource {
4670

4771
/**
4872
* Returns a list of messages for a given thread.
73+
*
74+
* @example
75+
* ```ts
76+
* // Automatically fetches more pages as needed.
77+
* for await (const message of client.beta.threads.messages.list(
78+
* 'thread_id',
79+
* )) {
80+
* // ...
81+
* }
82+
* ```
4983
*/
5084
list(
5185
threadID: string,
@@ -61,6 +95,14 @@ export class Messages extends APIResource {
6195

6296
/**
6397
* Deletes a message.
98+
*
99+
* @example
100+
* ```ts
101+
* const messageDeleted =
102+
* await client.beta.threads.messages.delete('message_id', {
103+
* thread_id: 'thread_id',
104+
* });
105+
* ```
64106
*/
65107
delete(
66108
messageID: string,

src/resources/beta/threads/runs/runs.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ export class Runs extends APIResource {
5050

5151
/**
5252
* Create a run.
53+
*
54+
* @example
55+
* ```ts
56+
* const run = await client.beta.threads.runs.create(
57+
* 'thread_id',
58+
* { assistant_id: 'assistant_id' },
59+
* );
60+
* ```
5361
*/
5462
create(threadID: string, params: RunCreateParamsNonStreaming, options?: RequestOptions): APIPromise<Run>;
5563
create(
@@ -79,6 +87,14 @@ export class Runs extends APIResource {
7987

8088
/**
8189
* Retrieves a run.
90+
*
91+
* @example
92+
* ```ts
93+
* const run = await client.beta.threads.runs.retrieve(
94+
* 'run_id',
95+
* { thread_id: 'thread_id' },
96+
* );
97+
* ```
8298
*/
8399
retrieve(runID: string, params: RunRetrieveParams, options?: RequestOptions): APIPromise<Run> {
84100
const { thread_id } = params;
@@ -90,6 +106,14 @@ export class Runs extends APIResource {
90106

91107
/**
92108
* Modifies a run.
109+
*
110+
* @example
111+
* ```ts
112+
* const run = await client.beta.threads.runs.update(
113+
* 'run_id',
114+
* { thread_id: 'thread_id' },
115+
* );
116+
* ```
93117
*/
94118
update(runID: string, params: RunUpdateParams, options?: RequestOptions): APIPromise<Run> {
95119
const { thread_id, ...body } = params;
@@ -102,6 +126,16 @@ export class Runs extends APIResource {
102126

103127
/**
104128
* Returns a list of runs belonging to a thread.
129+
*
130+
* @example
131+
* ```ts
132+
* // Automatically fetches more pages as needed.
133+
* for await (const run of client.beta.threads.runs.list(
134+
* 'thread_id',
135+
* )) {
136+
* // ...
137+
* }
138+
* ```
105139
*/
106140
list(
107141
threadID: string,
@@ -117,6 +151,14 @@ export class Runs extends APIResource {
117151

118152
/**
119153
* Cancels a run that is `in_progress`.
154+
*
155+
* @example
156+
* ```ts
157+
* const run = await client.beta.threads.runs.cancel(
158+
* 'run_id',
159+
* { thread_id: 'thread_id' },
160+
* );
161+
* ```
120162
*/
121163
cancel(runID: string, params: RunCancelParams, options?: RequestOptions): APIPromise<Run> {
122164
const { thread_id } = params;
@@ -210,6 +252,15 @@ export class Runs extends APIResource {
210252
* `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
211253
* tool calls once they're all completed. All outputs must be submitted in a single
212254
* request.
255+
*
256+
* @example
257+
* ```ts
258+
* const run =
259+
* await client.beta.threads.runs.submitToolOutputs(
260+
* 'run_id',
261+
* { thread_id: 'thread_id', tool_outputs: [{}] },
262+
* );
263+
* ```
213264
*/
214265
submitToolOutputs(
215266
runID: string,

src/resources/beta/threads/runs/steps.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ import { path } from '../../../../internal/utils/path';
1212
export class Steps extends APIResource {
1313
/**
1414
* Retrieves a run step.
15+
*
16+
* @example
17+
* ```ts
18+
* const runStep =
19+
* await client.beta.threads.runs.steps.retrieve('step_id', {
20+
* thread_id: 'thread_id',
21+
* run_id: 'run_id',
22+
* });
23+
* ```
1524
*/
1625
retrieve(stepID: string, params: StepRetrieveParams, options?: RequestOptions): APIPromise<RunStep> {
1726
const { thread_id, run_id, ...query } = params;
@@ -24,6 +33,17 @@ export class Steps extends APIResource {
2433

2534
/**
2635
* Returns a list of run steps belonging to a run.
36+
*
37+
* @example
38+
* ```ts
39+
* // Automatically fetches more pages as needed.
40+
* for await (const runStep of client.beta.threads.runs.steps.list(
41+
* 'run_id',
42+
* { thread_id: 'thread_id' },
43+
* )) {
44+
* // ...
45+
* }
46+
* ```
2747
*/
2848
list(runID: string, params: StepListParams, options?: RequestOptions): PagePromise<RunStepsPage, RunStep> {
2949
const { thread_id, ...query } = params;

0 commit comments

Comments
 (0)