Skip to main content
Glama
README.md
<p align="center">
  <span style="font-size:64px">๐Ÿช™</span>
</p>

<h1 align="center">OhMyToken</h1>

<p align="center">
  <strong>AI Token Price Intelligence for Agents & Developers</strong>
</p>

<p align="center">
  <a href="https://www.ohmytoken.com">Website</a> ยท
  <a href="https://www.ohmytoken.com/agents.txt">agents.txt</a> ยท
  <a href="#mcp-server">MCP Server</a> ยท
  <a href="#rest-api">REST API</a> ยท
  <a href="#token-tracker">Token Tracker</a>
</p>

<p align="center">
  <img src="https://img.shields.io/badge/models-23+-6366F1" alt="Models" />
  <img src="https://img.shields.io/badge/providers-8-3B82F6" alt="Providers" />
  <img src="https://img.shields.io/badge/MCP_tools-10-10B981" alt="MCP Tools" />
  <img src="https://img.shields.io/badge/i18n-zh%20%7C%20en-F59E0B" alt="i18n" />
  <img src="https://img.shields.io/badge/license-MIT-gray" alt="License" />
</p>

---

Real-time token pricing for **23 AI models** across **8 providers** (Anthropic, OpenAI, Google, DeepSeek, Zhipu, MiniMax, Moonshot, Alibaba). Built for **agents** โ€” not just humans.

## Features

**Price Intelligence**
- Real-time pricing table with sorting, filtering by provider/category/open-source
- Token cost calculator โ€” input your usage, see daily/monthly costs across all models
- Price evolution timeline โ€” from GPT-4 ($30/MTok) to DeepSeek V3 ($0.3/MTok)

**Agent-First Design**
- **MCP Server** โ€” 5 tools for price queries, model comparison, smart recommendations
- **Token Tracker** โ€” 5 tools for consumption logging, budget management, efficiency analysis
- **REST API** โ€” 12 endpoints for programmatic access
- **agents.txt** โ€” Machine-readable service description at `/agents.txt`

**Bilingual** โ€” Chinese / English with automatic RMB / USD currency conversion

## Quick Start

```bash
git clone https://github.com/LangGPT/ohmytoken.git
cd ohmytoken
npm install
npm run build
npm run dev        # โ†’ http://localhost:18090
```

## MCP Server

Add to your Claude Code `settings.json`:

```json
{
  "mcpServers": {
    "ohmytoken": {
      "command": "npx",
      "args": ["tsx", "src/mcp/index.ts"]
    }
  }
}
```

**Tools:**

| Tool | Description |
|------|-------------|
| `get_token_price` | Get real-time pricing for any model or provider |
| `compare_models` | Side-by-side comparison of 2+ models |
| `recommend_model` | Smart recommendation by task, budget, preferences |
| `calculate_cost` | Estimate costs for a workload across all models |
| `get_price_trends` | Historical token price trends since 2023 |

## Token Tracker

Every agent deserves a financial dashboard. Track your token spending like wandb tracks experiments.

```json
{
  "mcpServers": {
    "ohmytoken-tracker": {
      "command": "npx",
      "args": ["tsx", "src/mcp/tracker.ts"]
    }
  }
}
```

**Tools:**

| Tool | Description |
|------|-------------|
| `token_log` | Record token consumption (cost auto-calculated) |
| `token_usage` | Query spending by period, model, or task |
| `token_budget` | Set daily/monthly limits with auto-warnings |
| `token_analyze` | Spending patterns and optimization suggestions |
| `token_leaderboard` | Multi-agent ranking โ€” who's most efficient? |

Data stored in `~/.ohmytoken/ledger.jsonl` (append-only, portable).

## REST API

Base URL: `https://www.ohmytoken.com/api` (or `http://localhost:18090/api`)

```bash
# All models
curl /api/models?provider=anthropic

# Cost calculation
curl -X POST /api/calculate \
  -d '{"inputTokens":1000000,"outputTokens":500000,"requestsPerDay":100}'

# Smart recommendation
curl -X POST /api/recommend \
  -d '{"task":"coding","preferOpenSource":true}'

# Log agent token usage
curl -X POST /api/tracker/log \
  -d '{"agent_id":"my-agent","model":"claude-opus-4-6","input_tokens":5000,"output_tokens":1000}'

# Agent leaderboard
curl /api/tracker/leaderboard
```

## Models Covered

| Provider | Models | Price Range (Input $/MTok) |
|----------|--------|---------------------------|
| Anthropic | Opus 4.6, Sonnet 4.5, Haiku 4.5 | $1 โ€” $5 |
| OpenAI | GPT-5.2, GPT-4.1, o3, o4-mini | $0.1 โ€” $2 |
| Google | Gemini 2.5 Pro, 2.5 Flash, 2.0 Flash | $0.1 โ€” $1.25 |
| DeepSeek | V3, R1 | $0.3 โ€” $0.7 |
| Zhipu | GLM-5, GLM-5 Code, GLM-4.7 | $0.07 โ€” $1.2 |
| MiniMax | M2.1 | $0.3 |
| Moonshot | Kimi K2, Kimi K2.5 | $0.6 |
| Alibaba | Qwen3-Max, QwQ-Plus | $0.8 โ€” $1.2 |

## Project Structure

```
ohmytoken/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ client/          # React SPA (bilingual, light theme)
โ”‚   โ”‚   โ”œโ”€โ”€ components/  # PriceTable, Calculator, Timeline, AgentDashboard, ...
โ”‚   โ”‚   โ”œโ”€โ”€ i18n.ts      # zh/en translations, RMB/USD conversion
โ”‚   โ”‚   โ””โ”€โ”€ styles.css   # Light theme with glass morphism
โ”‚   โ”œโ”€โ”€ server/          # Express API server (port 18090)
โ”‚   โ”œโ”€โ”€ mcp/
โ”‚   โ”‚   โ”œโ”€โ”€ index.ts     # Price intelligence MCP server
โ”‚   โ”‚   โ””โ”€โ”€ tracker.ts   # Token consumption tracker MCP server
โ”‚   โ””โ”€โ”€ shared/          # Types, data, tracker storage
โ”œโ”€โ”€ docs/                # GitHub Pages static build
โ”œโ”€โ”€ public/              # Static assets (index.html, agents.txt)
โ””โ”€โ”€ build.js             # esbuild bundler
```

## License

MIT