Defines data structures for tracking AI model token usage across different providers. Use this for billing, rate limiting, or monitoring LLM API consumption.
// Source: https://github.com/shiwenwen/hope-agent | License: MIT | Copyright 2026 shiwenwen
// Provided via justclaw.it.com; keep this notice with the code.
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ProviderFamily {
Anthropic,
OpenAiChat,
OpenAiResponses,
Codex,
Unknown,
}
impl ProviderFamily {
pub const fn as_str(self) -> &'static str {
match self {
Self::Anthropic => "anthropic",
Self::OpenAiChat => "openai_chat",
Self::OpenAiResponses => "openai_responses",
Self::Codex => "codex",
Self::Unknown => "unknown",
}
}
}
#[derive(Debug, C
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key