cd /news/ai-agents/open-sourcing-ante-llm-what-it-takes… · home › topics › ai-agents › article
[ARTICLE · art-181295] src=antigma.ai ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Open-Sourcing ante-llm: What It Takes to Stream Four LLM APIs Reliably

Antigma released ante-llm, an Apache-2.0 Rust crate on crates.io, as the model layer behind every call its Ante agent makes, streaming four wire formats — Anthropic Messages, OpenAI Responses (HTTP or WebSocket), OpenAI Chat Completions and compatible servers, and Gemini — through one request type and one event stream. The crate adds per-provider profiles for DeepSeek, GLM, Kimi, MiniMax, Qwen, OpenRouter and llama.cpp, and handles failure modes the company says an agent loop hits over hours: a single idle timeout covering stream opening and every gap between reads, an LlmErrorKind classification by remedy (rate limited, overloaded, context window exceeded, authentication error, quota exceeded, blocked by policy), reasoning content that must be sent back unchanged, and tool calls with invalid JSON surfaced on malformed_args rather than failing the stream. Antigma says the code is the same one Ante runs in its released binary and Terminal-Bench runs, where it claims Ante is the #1 same-model agent.

key takeaway

ante-llm replaces whole-request timeouts with one idle timeout covering stream opening and every read gap, classifies failures into LlmErrorKind remedies (rate limited, overloaded, context window exceeded, authentication error, quota exceeded, blocked by policy), and returns invalid tool-call JSON o

by read5 min views1 publishedDec 3, 2026
Open-Sourcing ante-llm: What It Takes to Stream Four LLM APIs Reliably
Image: Antigma (auto-discovered)

Happy holidays! Closing out the year by open-sourcing something we use every day has become a tradition at Antigma. In 2024 it was mcp-sdk, a minimal Rust implementation of the Model Context Protocol. In 2025 it was nanochat-rs, a tiny cognitive core in native Rust inspired by Karpathy's nanochat.

This year it's ante-llm, the model layer behind every call Ante makes.

A lot of what lets Ante beat other harnesses running the same model has nothing to do with prompts. It's the plumbing underneath: an agent that makes call after call on a long task has to survive every way a provider can fail, on every provider. That plumbing is now Apache-2.0, for anyone to use.

cargo add ante-llm

Not a library extracted for the occasion #

There are good multi-provider Rust clients already, such as genai and rig, and async-openai for OpenAI. The difference with ante-llm is where it comes from. It is the code Ante runs for every model call, in the released binary and in our Terminal-Bench runs, including the ones where Ante is the #1 same-model agent. It is not a second implementation kept up for the crate. A fix that lands for Ante lands in the crate, in the same release.

It speaks four wire formats through one request type and one stream of events:

Wire format Client
Anthropic Messages anthropic::Anthropic
OpenAI Responses, over HTTP streaming or a WebSocket openai::OpenAi
OpenAI Chat Completions and compatible servers openai_compatible::OpenAiCompatible
Gemini gemini::Gemini

The Chat Completions client carries per-provider profiles for DeepSeek, GLM, Kimi, MiniMax, Qwen, OpenRouter and llama.cpp, because "OpenAI-compatible" servers disagree on exactly the parameters that matter, starting with how to ask for reasoning.

What it takes #

Sending a request and printing the reply is the easy part. Here is what an agent loop hits once it runs for hours.

A provider that never answers

Most failures are loud: a status code, an error body. The expensive one is quiet. The provider accepts the request and then sends nothing, and a client that only times out whole requests either waits forever or kills long, healthy generations.

ante-llm uses one idle timeout that covers opening the stream and every gap between reads. A reply can stream for as long as it keeps streaming. Silence fails.

Errors that say what to do

Each provider reports failures differently. An agent doesn't care whether it got a 429, a 529 or an error event in the middle of a stream. It needs to know what to do next.

LlmErrorKind classifies every failure by remedy, in the same terms for every provider: rate limited, overloaded, context window exceeded, authentication error, quota exceeded, blocked by policy. The provider's own status, code and message stay on the error for logs. Two quick retries absorb connection blips inside the crate. A longer wait the provider asks for goes back to the caller on the error, so the caller decides whether to wait it out or cancel.

Reasoning you have to send back

Reasoning models return more than text. Some providers sign their reasoning, or return it encrypted, and expect it back unchanged on the next call. Drop it and the next turn fails or loses its reasoning.

The model's message comes back with that content attached, and sending the message back as you got it is enough. One effort setting maps onto each provider's own reasoning levels.

Tool calls that break

Models sometimes send tool arguments that aren't valid JSON. If that fails the stream, the agent loses the whole turn. In ante-llm the call arrives anyway, with the raw text on malformed_args, so the agent can tell the model what went wrong and let it try again.

Tool schemas have the opposite problem: each provider accepts a different subset of JSON Schema. normalize_tool_schema rewrites one schema into the subset all of them accept.

Big requests, every turn

An agent resends the whole conversation on every call, so requests get large. Requests of 16 KiB or more go gzip-compressed to Anthropic Messages and zstd-compressed to OpenAI Responses. Every other endpoint gets plain JSON.

Credentials that expire

OAuth tokens expire mid-session. A TokenSource supplies the token and gets one chance to recover when the server rejects it, such as by refreshing it. The request is then sent once more, and the agent never sees the failure.

An agent in one file #

Here is the whole loop: call the model, run the tools it asks for, send the results back, and repeat until it stops asking.

for _ in 0..MAX_STEPS {    let stream = client.stream_chat(request.clone()).await?;    let response = streaming::collect(stream, |event| {        if let StreamEvent::TextDelta(text) = event {            print!("{text}");        }    })    .await    .into_result()?;    let calls: Vec<ToolUse> = response.message.content.tool_uses().cloned().collect();    request = request.with_message(response.message);    if calls.is_empty() {        return Ok(());    }    let mut results = Vec::new();    for call in &calls {        results.push(ContentPart::ToolResult(run_tool(call).await));    }    request = request.with_message(Message::user(Content::Parts(results)));}

The full program is mini-ante, a coding agent in about 200 lines that runs on Anthropic, OpenAI, Gemini, or a local llama.cpp server. The walkthrough goes through it step by step.

Build on any layer #

ante-llm is the bottom layer of a stack we're opening up piece by piece:

  • Profiles and skills shape the whole agent without writing code.
  • ante-sdk drives Ante's runtime from your own interface: a TUI, a bot, an editor.
  • ante-llm gives you the model layer and leaves the loop to you.

Pick the layer that fits and leave the rest to us. If you build something, show us in Show and tell. Issues and PRs against crates/llm are welcome: a maintainer ports them, and they ship in the next release of both the crate and Ante.

Happy holidays, and happy hacking.

── more in #ai-agents 4 stories · sorted by recency
── more on @antigma 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/open-sourcing-ante-l…] indexed:0 read:5min 2026-12-03 · —