ClawPulse
English··OpenAI API cost per token

OpenAI API Cost Per Token Explained: Real Pricing Math for Production Agents

Most teams shipping AI agents discover the same uncomfortable truth in their second month: the OpenAI bill scales faster than the user base. Understanding cost per token is not just accounting hygiene — it is the difference between a viable product and a margin-negative experiment. This guide breaks down current OpenAI pricing, shows real math from production workloads, and explains where the hidden costs hide.

How OpenAI Token Pricing Actually Works

OpenAI charges per token, not per request. A token is roughly 4 characters of English text or ¾ of a word. The phrase "monitoring AI agents" is 4 tokens. A 500-word email is around 650 tokens. You can verify counts with tiktoken, the official tokenizer.

Pricing splits into two buckets that matter enormously for your bill:

  • Input tokens — everything you send: system prompt, conversation history, tool definitions, RAG context
  • Output tokens — what the model generates back

Output tokens cost 3-4x more than input tokens across every OpenAI model. This single fact drives most cost optimization decisions.

Current OpenAI Pricing (per 1M tokens)

| Model | Input | Output | Cached Input |

|-------|-------|--------|--------------|

| GPT-4o | $2.50 | $10.00 | $1.25 |

| GPT-4o mini | $0.15 | $0.60 | $0.075 |

| o1 | $15.00 | $60.00 | $7.50 |

| o1-mini | $3.00 | $12.00 | $1.50 |

| o3-mini | $1.10 | $4.40 | $0.55 |

The full price list lives at platform.openai.com/docs/pricing. Numbers shift quarterly, so always confirm before committing to a budget.

Real Cost Math From Production Agents

Theoretical pricing is meaningless until you map it onto actual workloads. Here is what a typical production agent looks like.

Example 1: Customer Support Agent (GPT-4o)

A support agent with a 2,000-token system prompt, 3,000 tokens of retrieved context, and 4 turns of conversation history (~1,500 tokens) generating a 400-token answer:

```python

input_tokens = 2000 + 3000 + 1500 # 6,500

output_tokens = 400

cost = (6500 / 1_000_000) 2.50 + (400 / 1_000_000) 10.00

# = $0.01625 + $0.004 = $0.02025 per request

```

At 10,000 conversations per day that is $202/day or roughly $6,075/month. This is before you factor in retries, evals, or background jobs.

Example 2: Coding Agent (o1)

Reasoning models hide a nasty surprise: they generate huge volumes of internal "reasoning tokens" that you pay for but never see. A typical o1 call for a coding task:

```python

input_tokens = 4000 # prompt + code context

reasoning_tokens = 8000 # invisible, billed as output

visible_output = 1200 # the actual response

total_output = reasoning_tokens + visible_output

cost = (4000 / 1_000_000) 15.00 + (9200 / 1_000_000) 60.00

# = $0.06 + $0.552 = $0.612 per request

```

A single o1 reasoning call can cost 30x more than a GPT-4o call. Most teams underestimate this until the invoice arrives. The OpenAI reasoning models guide explains why.

Example 3: Batch Classification (GPT-4o mini)

For high-volume, low-complexity workloads, GPT-4o mini changes the economics:

```python

input_tokens = 800

output_tokens = 50

cost = (800 / 1_000_000) 0.15 + (50 / 1_000_000) 0.60

# = $0.00012 + $0.00003 = $0.00015 per request

```

That is roughly 0.015 cents per classification. For 1M classifications per month, you pay $150 instead of $20,000+ on GPT-4o.

The Four Hidden Cost Multipliers

Sticker pricing is just the floor. Production agents pay multipliers that double or triple expected costs.

1. Conversation History Compounds Quadratically

Each new turn re-sends the entire prior conversation. A 10-turn dialogue does not cost 10x a single turn — it costs roughly 55x because turn 10 includes turns 1-9 in its input. This is why context window management is the single highest-ROI optimization for chat agents.

2. Tool Calling Adds Phantom Tokens

Every tool definition you pass counts as input tokens on every call. A toolset with 8 functions and detailed JSON schemas can add 1,500-2,500 tokens to every single request, even when no tool is invoked. Audit your tool definitions ruthlessly.

3. Retries and Failures

Production agents retry on rate limits, timeouts, and malformed JSON. A 3% retry rate on a $0.02 request adds 3% to your bill — but a 15% retry rate during peak hours can quietly add 15%.

4. Eval and Observability Traffic

Running golden-dataset evals on every deploy can add 20-40% to your monthly OpenAI spend if the eval suite is large. This is why a real agent monitoring platform like ClawPulse separates eval traffic from production traffic in cost reports.

Start monitoring your OpenClaw agents in 2 minutes

Free 14-day trial. No credit card. Just drop in one curl command.

Prefer a walkthrough? Book a 15-min demo.

Five Tactics That Actually Cut the Bill

These are the optimizations that move the needle in real deployments, in priority order.

1. Enable Prompt Caching

OpenAI automatically caches static prefixes longer than 1,024 tokens. Cached input costs 50% less. Structure your prompts so the static parts (system prompt, tool definitions, retrieved docs) come first and the dynamic parts (user query) come last. A well-structured agent can cut input costs by 40-60%.

2. Pick the Right Model Per Task

Stop using GPT-4o for everything. Route classification and extraction to GPT-4o mini, route reasoning-heavy work to o3-mini, and only escalate to o1 when the task genuinely requires deep reasoning. A simple router can cut blended costs by 70%.

```python

def route_model(task_type):

if task_type in ("classify", "extract", "summarize"):

return "gpt-4o-mini"

if task_type == "reasoning":

return "o3-mini"

if task_type == "complex_reasoning":

return "o1"

return "gpt-4o"

```

3. Use the Batch API for Async Work

OpenAI's Batch API gives you 50% off list price in exchange for a 24-hour SLA. For overnight evals, content generation, and bulk data enrichment, this is free money.

4. Truncate Conversation History Aggressively

Most chat agents do not need 10 turns of history. Sliding windows of 3-4 turns plus a running summary preserve quality while cutting input tokens by 50-70%. Frameworks like LangChain memory ship this out of the box.

5. Stream and Cap max_tokens

Setting `max_tokens=500` when you expect a 200-token answer is leaving money on the table. Cap output strictly. Stream responses so you can stop early on hallucination patterns.

How to Track Cost Per Token in Production

Knowing the unit price is useless without per-request, per-user, and per-feature attribution. The tooling landscape splits roughly three ways:

  • Langfuse — open-source tracing, strong on dev workflows, weaker on production alerting
  • Helicone — proxy-based, easy to drop in, limited evals
  • ClawPulse — focused specifically on agent workloads with cost breakdowns by tool call, reasoning step, and user cohort

The right choice depends on whether you optimize for traces (Langfuse), latency proxying (Helicone), or production agent economics (ClawPulse). See our agent monitoring comparison for honest tradeoffs and our pricing page for ClawPulse plans.

The minimum you should track per request:

  • Model used
  • Input tokens (split: prompt, history, tools, RAG)
  • Output tokens (split: visible, reasoning)
  • Cache hit rate
  • Cost in dollars
  • User and feature attribution

Without these dimensions, you cannot tell whether your bill grew because users grew, because prompts bloated, or because someone shipped a regression that broke caching.

When OpenAI Stops Being the Cheapest Option

At sufficient scale, the math shifts. Anthropic's Claude Haiku often beats GPT-4o mini on cost-per-quality for specific tasks. Open models running on dedicated infrastructure (Llama 3.3, DeepSeek) cross OpenAI's cost line somewhere between $30K and $80K of monthly spend, depending on workload shape.

If your monthly OpenAI bill exceeds $50K and your traffic pattern is predictable, run the numbers on dedicated inference. If your bill is under $10K, optimization tactics above will get you further than infrastructure changes.

FAQ

How do I count tokens before sending a request?

Use tiktoken for OpenAI models. For a quick estimate, divide character count by 4 for English or by 2 for code-heavy content.

Are reasoning tokens from o1 always billed?

Yes. Every reasoning token o1 generates internally counts as output tokens at the full output rate, even though you never see them. This is why o1 is 30-50x more expensive than GPT-4o on equivalent tasks.

Does prompt caching work automatically?

Yes for OpenAI — caching activates automatically on prefixes ≥1,024 tokens that match exactly. You do not need a special API call, but you do need to structure prompts so the static content comes first.

What is a reasonable cost per request for a production agent?

For chat agents on GPT-4o expect $0.01-$0.05 per request. For GPT-4o mini classification expect $0.0001-$0.001. For o1 reasoning agents budget $0.30-$1.00 per request. Anything significantly higher means there is room to optimize.

---

Ready to see exactly where every token of your OpenAI bill goes? Book a ClawPulse demo and we will plug into your agent in under 10 minutes.

See ClawPulse in action

Get a personalized walkthrough for your OpenClaw setup — takes 15 minutes.

Or start a free trial — no credit card required.

Back to all posts
C

Claudio

Assistant IA ClawPulse

Salut 👋 Je suis Claudio. En 30 secondes je peux te montrer comment ClawPulse remplace tes 12 onglets de monitoring par un seul dashboard. Tu veux voir une demo live, connaitre les tarifs, ou connecter tes agents OpenClaw maintenant ?

Propulse par ClawPulse AI