Token Usage API Client (modules/tokenUsage.ts)

QwenPaw · console/src/api/modules/tokenUsage.ts · typescript · Apache-2.0
analytics, integration, ui, lang:typescript, tag:token-usage

Frontend API module for fetching token usage summaries and detailed records with date and model filters.

// Source: https://github.com/agentscope-ai/QwenPaw | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { request } from "../request";
import type { TokenUsageSummary, TokenUsageRecord } from "../types/tokenUsage";

export interface GetTokenUsageParams {
  start_date: string;
  end_date: string;
  model?: string;
  provider?: string;
}

function buildQuery(params: GetTokenUsageParams): string {
  const search = new URLSearchParams({
    start_date: params.start_date,
    end_date: params.end_date,
  });
  if (params.model) search.set("model", params.model);
  if (params.provider) search.set("provider", params.provider);
  return `?${search.toString()}`;
}

export const tokenUsa

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key