Open-source LLM inference for AI agents: the complete guide
Open-source LLM inference means running open-weight models such as Kimi K3, GLM-5.3 or DeepSeek V4 behind an API your agent calls. For AI agents it can cut the cost of a task by 93% against Claude Opus 5.5: a typical coding-agent task costs $0.13 on DeepSeek V4 Pro and $1.96 on Claude Opus 5.5. What decides the bill is how the serving handles the agent loop, above all how much context it can reuse between turns.
What is open-source LLM inference?
Inference is running a trained model to produce output. Open-source, or open-weight, models publish their weights, so anyone can serve them: a hosted provider, a dedicated cluster rented for one customer, or your own GPUs. The model is the same everywhere. What changes is the price, the speed, and who controls the hardware and the data.
Most open models now speak the same API as the closed ones. A provider that serves the OpenAI Chat Completions or Anthropic Messages API lets an existing agent switch by changing its base URL and model name.
How is agent traffic different from chat?
A chat request is one question and one answer. An agent runs a loop: it calls the model, runs a tool, adds the result to the conversation, and calls the model again. A coding agent can do this dozens of times per task. Three things follow:
- Most input is repeated. Each call resends the whole conversation so far. On a long task, the large majority of input tokens are ones the model has already seen.
- The gaps matter. Between calls the agent is running tests or reading files. If the serving stack evicts the session's context during that gap, the next call pays to rebuild it.
- Some calls block a task, others don't. A call carrying a tool result is holding up work in progress. A call that writes a chat title can wait.
Serving built for chat optimises tokens per second on single requests. Serving built for agents optimises what a finished task costs. See prompt caching and the KV cache for the mechanics.
What does it cost?
On list prices, here is what one typical coding-agent task costs on the leading open models and on two frontier models.
| Model | Input | Cached input | Output | Per task |
|---|---|---|---|---|
| Kimi K3 | $3.00 | $0.30 | $15.00 | $1.74 |
| GLM-5.3 | $1.40 | $0.26 | $4.40 | $0.92 |
| DeepSeek V4 Pro | $0.44 | $0.003625 | $0.87 | $0.13 |
| DeepSeek V4.1 Flash | $0.30 | $0.006 | $1.20 | $0.12 |
| Qwen3.8-Max | $2.00 | $0.25 | $6.00 | $1.09 |
| MiniMax M3 | $0.30 | $0.30 | $1.20 | $0.65 |
| Claude Opus 5.5 | $4.00 | $0.20 | $20.00 | $1.96 |
| GPT-6 Astra | $10.00 | $1.00 | $50.00 | $5.80 |
Prices are USD per million tokens. A task here is a coding-agent loop with 2M input tokens, 1.8M of them read from the cache, and 40K output tokens.
Per-token prices are only the start. A model that needs more turns or fails more often can cost more per working result even with cheaper tokens, which is why we measure cost per successful task.
Hosted, dedicated or on-prem?
- Hosted API. Pay per token, no hardware, start in minutes. Best while you find the right model and volume.
- Dedicated capacity. GPUs reserved for your traffic. Predictable latency and, at steady volume, a lower cost per token.
- On-prem or private cloud. The model runs in your data centre or cloud account, so prompts and code never leave your network.
The trade-offs, and when each one pays, are in self-hosted vs inference API vs on-prem.
Which open model should an agent use?
For coding agents, DeepSeek V4 Pro, GLM-5.3 and Kimi K3 lead the open models, within a few points of the best closed model on fixing real GitHub issues, and DeepSeek V4 Pro is the cheapest of the three. The full comparison is in the best open-source models for coding agents. When no off-the-shelf model is good enough at your tasks, fine-tuning on your agent's own sessions usually closes the gap.
How do I switch an agent to an open model?
Point the agent at an OpenAI- or Anthropic-compatible endpoint and set the model name:
# Any OpenAI client
client = OpenAI(base_url="https://api.theinferencecompany.si/v1", api_key=TIC_API_KEY)
client.chat.completions.create(model="deepseek-v4-pro", messages=messages)
Claude Code works the same way through the Anthropic API: see how to run Claude Code on open-source models.
Common questions
Are open-source models good enough for AI agents?
For most agent work, yes. On SWE-bench Verified, which measures fixing real GitHub issues, DeepSeek V4 Pro solves 96.4%, GLM-5.3 95.4% and Kimi K3 93.4%, against Claude Opus 5 at 97.0% for the best closed model. The way to be sure for your agent is to run your own tasks on both and compare cost per successful task.
How much cheaper is open-source inference than frontier models?
On a typical coding-agent task, 93% cheaper than Claude Opus 5.5 on DeepSeek V4 Pro: $0.13 per task where Claude Opus 5.5 costs $1.96 and GPT-6 Astra costs $5.80.
How is The Inference Company different from other inference providers?
We run the models on our own GPUs, with an engine tuned for long agent sessions rather than single requests: context is kept through tool calls, calls that block a running task go first, and every account shows what each finished task costs.
How do I get access to The Inference Company?
We're onboarding a small group of teams first. Book a call and we'll set up your team in the console.
Do I need my own GPUs to use open-source models?
No. A hosted provider serves the model behind an API and charges per token. Dedicated or on-prem GPUs make sense later, for steady volume, strict latency or data that must stay in your network.
More guides
- The best open-source models for coding agents in 2026
- How to fine-tune an open-source LLM for your AI agent
- Self-hosted LLMs vs an inference API vs on-prem: how to choose
- Prompt caching and the KV cache: why cached tokens decide an agent's bill
- How to run Claude Code on open-source models
- Cost per successful task, explained