Type Alias UsageMetadata

UsageMetadata: {
    input_tokens: number;
    output_tokens: number;
    total_tokens: number;
    input_cost?: number;
    input_cost_details?: Record<string, unknown>;
    input_token_details?: InputTokenDetails;
    output_cost?: number;
    output_cost_details?: Record<string, unknown>;
    output_token_details?: OutputTokenDetails;
    total_cost?: number;
}

Usage metadata for a message, such as token counts.

Type declaration

  • input_tokens: number

    Count of input (or prompt) tokens. Sum of all input token types.

  • output_tokens: number

    Count of output (or completion) tokens. Sum of all output token types.

  • total_tokens: number

    Total token count. Sum of input_tokens + output_tokens.

  • Optionalinput_cost?: number

    The cost of the input tokens.

  • Optionalinput_cost_details?: Record<string, unknown>

    The cost details of the input tokens.

  • Optionalinput_token_details?: InputTokenDetails

    Breakdown of input token counts.

    Does not need to sum to full input token count. Does not need to have all keys.

  • Optionaloutput_cost?: number

    The cost of the output tokens.

  • Optionaloutput_cost_details?: Record<string, unknown>

    The cost details of the output tokens.

  • Optionaloutput_token_details?: OutputTokenDetails

    Breakdown of output token counts.

    Does not need to sum to full output token count. Does not need to have all keys.

  • Optionaltotal_cost?: number

    The total cost of the tokens.