• Calculates basic usage statistics from the given model inputs and outputs.

    Parameters

    • input: {
          content: (
              | {
                  custom?: Record<string, unknown>;
                  data?: unknown;
                  media?: undefined;
                  metadata?: Record<string, unknown>;
                  text: string;
                  toolRequest?: undefined;
                  toolResponse?: undefined;
              }
              | {
                  custom?: Record<string, unknown>;
                  data?: unknown;
                  media: { contentType?: string; url: string };
                  metadata?: Record<string, unknown>;
                  text?: undefined;
                  toolRequest?: undefined;
                  toolResponse?: undefined;
              }
              | {
                  custom?: Record<string, unknown>;
                  data?: unknown;
                  media?: undefined;
                  metadata?: Record<string, unknown>;
                  text?: undefined;
                  toolRequest: { input?: unknown; name: string; ref?: string };
                  toolResponse?: undefined;
              }
              | {
                  custom?: Record<string, unknown>;
                  data?: unknown;
                  media?: undefined;
                  metadata?: Record<string, unknown>;
                  text?: undefined;
                  toolRequest?: undefined;
                  toolResponse: { name: string; output?: unknown; ref?: string };
              }
              | {
                  custom?: Record<string, unknown>;
                  data?: unknown;
                  media?: undefined;
                  metadata?: Record<string, unknown>;
                  text?: undefined;
                  toolRequest?: undefined;
                  toolResponse?: undefined;
              }
              | {
                  custom: Record<string, any>;
                  data?: unknown;
                  media?: undefined;
                  metadata?: Record<string, unknown>;
                  text?: undefined;
                  toolRequest?: undefined;
                  toolResponse?: undefined;
              }
          )[];
          metadata?: Record<string, unknown>;
          role: "user" | "model" | "tool" | "system";
      }[]
    • response:
          | {
              content: (
                  | {
                      custom?: Record<string, unknown>;
                      data?: unknown;
                      media?: undefined;
                      metadata?: Record<string, unknown>;
                      text: string;
                      toolRequest?: undefined;
                      toolResponse?: undefined;
                  }
                  | {
                      custom?: Record<string, unknown>;
                      data?: unknown;
                      media: { contentType?: string; url: string };
                      metadata?: Record<string, unknown>;
                      text?: undefined;
                      toolRequest?: undefined;
                      toolResponse?: undefined;
                  }
                  | {
                      custom?: Record<string, unknown>;
                      data?: unknown;
                      media?: undefined;
                      metadata?: Record<string, unknown>;
                      text?: undefined;
                      toolRequest: { input?: unknown; name: string; ref?: string };
                      toolResponse?: undefined;
                  }
                  | {
                      custom?: Record<string, unknown>;
                      data?: unknown;
                      media?: undefined;
                      metadata?: Record<string, unknown>;
                      text?: undefined;
                      toolRequest?: undefined;
                      toolResponse: { name: string; output?: unknown; ref?: string };
                  }
                  | {
                      custom?: Record<string, unknown>;
                      data?: unknown;
                      media?: undefined;
                      metadata?: Record<string, unknown>;
                      text?: undefined;
                      toolRequest?: undefined;
                      toolResponse?: undefined;
                  }
                  | {
                      custom: Record<string, any>;
                      data?: unknown;
                      media?: undefined;
                      metadata?: Record<string, unknown>;
                      text?: undefined;
                      toolRequest?: undefined;
                      toolResponse?: undefined;
                  }
              )[];
              metadata?: Record<string, unknown>;
              role: "user" | "model" | "tool" | "system";
          }
          | {
              custom?: unknown;
              finishMessage?: string;
              finishReason: | "length"
              | "stop"
              | "interrupted"
              | "blocked"
              | "unknown"
              | "other";
              index: number;
              message: {
                  content: (
                      | {
                          custom?: Record<string, unknown>;
                          data?: unknown;
                          media?: undefined;
                          metadata?: Record<string, unknown>;
                          text: string;
                          toolRequest?: undefined;
                          toolResponse?: undefined;
                      }
                      | {
                          custom?: Record<string, unknown>;
                          data?: unknown;
                          media: { contentType?: string; url: string };
                          metadata?: Record<string, unknown>;
                          text?: undefined;
                          toolRequest?: undefined;
                          toolResponse?: undefined;
                      }
                      | {
                          custom?: Record<string, unknown>;
                          data?: unknown;
                          media?: undefined;
                          metadata?: Record<string, unknown>;
                          text?: undefined;
                          toolRequest: { input?: unknown; name: string; ref?: string };
                          toolResponse?: undefined;
                      }
                      | {
                          custom?: Record<string, unknown>;
                          data?: unknown;
                          media?: undefined;
                          metadata?: Record<string, unknown>;
                          text?: undefined;
                          toolRequest?: undefined;
                          toolResponse: { name: string; output?: unknown; ref?: string };
                      }
                      | {
                          custom?: Record<string, unknown>;
                          data?: unknown;
                          media?: undefined;
                          metadata?: Record<string, unknown>;
                          text?: undefined;
                          toolRequest?: undefined;
                          toolResponse?: undefined;
                      }
                      | {
                          custom: Record<string, any>;
                          data?: unknown;
                          media?: undefined;
                          metadata?: Record<string, unknown>;
                          text?: undefined;
                          toolRequest?: undefined;
                          toolResponse?: undefined;
                      }
                  )[];
                  metadata?: Record<string, unknown>;
                  role: "user" | "model" | "tool" | "system";
              };
              usage?: {
                  custom?: Record<string, number>;
                  inputAudioFiles?: number;
                  inputCharacters?: number;
                  inputImages?: number;
                  inputTokens?: number;
                  inputVideos?: number;
                  outputAudioFiles?: number;
                  outputCharacters?: number;
                  outputImages?: number;
                  outputTokens?: number;
                  outputVideos?: number;
                  totalTokens?: number;
              };
          }[]

    Returns GenerationUsage