diff --git a/src/resources/beta/threads/runs/runs.ts b/src/resources/beta/threads/runs/runs.ts index 8709ebabe..749d2c7f6 100644 --- a/src/resources/beta/threads/runs/runs.ts +++ b/src/resources/beta/threads/runs/runs.ts @@ -264,6 +264,12 @@ export interface Run { * this run. */ tools: Array; + + /** + * Usage statistics related to the run. This value will be `null` if the run is not + * in a terminal state (i.e. `in_progress`, `queued`, etc.). + */ + usage: Run.Usage | null; } export namespace Run { @@ -332,6 +338,27 @@ export namespace Run { */ type: 'function'; } + + /** + * Usage statistics related to the run. This value will be `null` if the run is not + * in a terminal state (i.e. `in_progress`, `queued`, etc.). + */ + export interface Usage { + /** + * Number of completion tokens used over the course of the run. + */ + completion_tokens: number; + + /** + * Number of prompt tokens used over the course of the run. + */ + prompt_tokens: number; + + /** + * Total number of tokens used (prompt + completion). + */ + total_tokens: number; + } } export interface RunCreateParams { diff --git a/src/resources/beta/threads/runs/steps.ts b/src/resources/beta/threads/runs/steps.ts index 618237c74..c574c94d1 100644 --- a/src/resources/beta/threads/runs/steps.ts +++ b/src/resources/beta/threads/runs/steps.ts @@ -300,6 +300,12 @@ export interface RunStep { * The type of run step, which can be either `message_creation` or `tool_calls`. */ type: 'message_creation' | 'tool_calls'; + + /** + * Usage statistics related to the run step. This value will be `null` while the + * run step's status is `in_progress`. + */ + usage: RunStep.Usage | null; } export namespace RunStep { @@ -318,6 +324,27 @@ export namespace RunStep { */ message: string; } + + /** + * Usage statistics related to the run step. This value will be `null` while the + * run step's status is `in_progress`. + */ + export interface Usage { + /** + * Number of completion tokens used over the course of the run step. + */ + completion_tokens: number; + + /** + * Number of prompt tokens used over the course of the run step. + */ + prompt_tokens: number; + + /** + * Total number of tokens used (prompt + completion). + */ + total_tokens: number; + } } /**