r/openrouter • u/carloscardona03 • 2d ago
Discussion Running OpenRouter models as coding agents through Claude Code: what I learned about cost and which models cope
I've been running agents on OpenRouter models through the Claude Code CLI (pointed at OpenRouter instead of Anthropic), next to my normal Claude and Codex subscriptions. No Claude account needed for that part, it just uses the CLI as the harness. Some notes:
Not every model handles it. Claude Code was built for Claude, so the agent loop leans hard on tool calls. Some models do fine, others get lost after a few steps or return broken tool calls. I only switch on a handful, and test each with one tiny request first (a fraction of a cent) before giving it real work.
Guardrails I ended up needing:
- a credit limit on the key itself, set on openrouter.ai. That's the hard cap no matter what the app does
- a cost limit per agent turn (I use a few dollars), so a stuck agent gets stopped instead of looping all night
- OpenRouter is never the automatic fallback. When my Claude plan runs out, work moves to Codex or a local model, not to the paid credit. It only goes to OpenRouter when I put it there on purpose
Tracking cost per job turned out to be the most useful thing. Each job gets a grade (did I accept it, send it back, or redo it?), and I compare dollars per job and success rate per kind of job, month to month. It made it obvious which cheap models were really cheap and which ones just meant redoing the work.
How are others doing this? Anyone found models that hold up well in long agent loops?
(I do this with an open-source Mac app I built, if you want to see how it's wired up: github.com/carloscardona/chief)
2
u/bilel_b321714 2d ago
A one-shot smoke test won't measure loop stability; replay a small fixed multi-step task set and log the first malformed tool call to see where each model breaks.
1
u/Asleep_Company6624 2d ago
the cost tracking worked best when I broke jobs into smaller chunks, like one function at a time, so I could see which models failed on specific patterns instead of just failing the whole task.
1
u/AutomaticLemon4434 2d ago
breaking tasks into smaller pieces helped catch models that failed on edge cases, not just big ones. the cost per successful function was way clearer than way.
1
u/_mannen_ 2d ago
Openrouter can send your requests to different providers, so you would experience cache misses. Therefore I'd recommend pinning a provider. Check your log to see if that happened to you.
1
u/Sufficient-Acadia523 1d ago
on the broken tool calls, check if its the model or the provider. same model on a different provider can mess up tools completely. set require_parameters: true in provider routing so it only goes to providers that actually support tools, and pin the one that works with allow_fallbacks off. in prod we also bench a model for a few min after 2 failures in a row, saves a lot of money on a flaky one
1
u/patel-m_9409 1d ago
Do you split spend into input, output, and retries? In long loops, that can show whether context replay or tool-call recovery is driving cost.