---
name: traktoken-query
description: Query LLM API prices, compare token costs, and calculate local vs API deployment ROI from TrakToken. Use when the user asks about LLM pricing, token costs, or local vs API comparisons.
---

# TrakToken Query Skill

## Instructions

When the user asks about LLM API prices, token costs, or wants to compare local deployment vs API costs, follow these steps:

1. **Fetch Latest Pricing Data**:
   Use the `WebFetch` tool or `Shell` tool (with `curl`) to fetch the latest pricing data from TrakToken's API endpoint:
   ```bash
   curl -s https://token.kuhung.me/api/prices
   ```
   *(Note: If working in a local development environment, use `http://localhost:3000/api/prices` instead)*

2. **Analyze the Data**:
   - Find the requested models in the JSON response (`data` array).
   - Extract `input_price` (per 1M tokens) and `output_price` (per 1M tokens).
   - Note the `context_window` and any special features.

3. **Calculate Costs Based on Scenario**:
   If the user provides a scenario (e.g., "100k messages/day, 500 input tokens, 200 output tokens"):
   - Calculate daily input tokens: `messages * input_tokens`
   - Calculate daily output tokens: `messages * output_tokens`
   - Calculate monthly cost: `(daily_input / 1M * input_price + daily_output / 1M * output_price) * 30`

4. **Compare API vs Local Deployment (If requested)**:
   - Estimate the hardware cost for local deployment (e.g., 1x A100 80G is ~$1500/month on cloud, or ~$15,000 to buy).
   - Compare the monthly API cost with the monthly hardware cost.
   - Calculate the ROI/Breakeven point: `Hardware Cost / Monthly API Cost`.

## Example Usage

**User**: "Compare the cost of using DeepSeek-V3 API vs GPT-4o for a customer service bot doing 10,000 messages a day (avg 1000 input, 500 output tokens)."

**Agent Action**:
1. Fetch pricing for DeepSeek-V3 and GPT-4o.
2. Calculate Monthly Tokens:
   - Input: 10,000 * 1000 * 30 = 300M tokens/month
   - Output: 10,000 * 500 * 30 = 150M tokens/month
3. Calculate Cost:
   - DeepSeek-V3: (300 * $0.14) + (150 * $0.28) = $42 + $42 = $84/month
   - GPT-4o: (300 * $2.50) + (150 * $10.00) = $750 + $1500 = $2250/month
4. Present the comparison clearly to the user.