Home Marketplace Agent Starter Kit

An agent loop you
can actually read.

Claude and OpenAI behind one interface, in about 100 lines of loop. Real tool calling, streaming, cost tracking from the provider's own usage block, and retries that respect retry-after. One dependency — httpx. No SDK, no LangChain, no framework.

2Providers, one interface
1Dependency
30Offline tests
4Runnable examples

Instant download · Commercial licence, use in software you sell · Free updates for life · 7-day refund

Verified

Every example was run
on the live APIs.

Against Anthropic and OpenAI on 13 August 2026, with the token counts and costs published in the README.

Agent tool-calling run showing get_invoice then days_overdue and a cost of $0.0139
The model picks the tools and the order. Three calls, 3,204 tokens, $0.0139 — printed by the kit itself.
costs.py showing cache multipliers and returning zero for an unknown model
Costs come from the provider's usage block, including the cache rates most trackers ignore entirely.
30 offline tests passing with no API key required
30 tests, no API key needed — so you can verify the kit before spending a cent on tokens.

The problem

Every tutorial stops
before the hard part.

They show you a chat completion, add one fake weather tool, and end. Then you build something real and hit the four things nobody covered: tool calls that come back malformed, streaming, knowing what a run actually cost, and rate limits arriving mid-loop.

The alternative is adopting a framework that hides the wire format — which is precisely the thing you need to see when a tool call comes back wrong.

Handles — tools, streaming, costs, retries
Hides — nothing

What's inside

Five files of library,
four of examples.

01

agent.py — the loop, and that really is all it is

About 100 lines. Tool calling, turn limits, and errors that go back to the model rather than up the stack — a raised exception ends a run, a returned error string lets the model correct its arguments and try again, which it usually does.

Readable in — one sitting
02

providers.py — both APIs, one interface

Raw HTTP via httpx, not the official SDKs. It handles the incompatibility that breaks most multi-provider code: Anthropic wants one message containing all tool results; OpenAI wants one message per result. The result builder returns a dict for one and a list for the other, and the loop appends or extends accordingly.

Every example — takes --provider openai
03

tools.py — JSON Schema from your type hints

Write a normal Python function with annotations and a docstring; the schema is generated from the signature, including per-parameter descriptions taken from the docstring. There is no schema to keep in sync with the function, so the two cannot drift.

Decorator — @tools.tool()
04

costs.py — accounting that is actually right

Costs from the provider's own usage block, never estimated by counting tokens locally, because local counts drift from the bill. Cached tokens are billed differently — 10% for reads, 125% for writes — and are tracked separately. Set budget_usd and a run stops rather than overspending.

Unknown model — reports 0.00, never a guess
05

Retries that respect the server

Honours the provider's retry-after header where present. Where it isn't, exponential backoff with full jitter — without the jitter, every client that hit the same rate limit retries in lockstep and hits it again together.

Backoff — capped at 30s
+

Four examples and 30 offline tests

Hello, tool calling, streaming with time-to-first-token, and the budget guard tripping. The test suite needs no API key and no network, covering the parts that break silently: schema generation, cost arithmetic, and both providers' response parsing.

Verify — before you spend

Who it's for

Developers past their
first chat completion.

Building your first real agent

You've called the API. Now you need tools, and you'd rather understand the loop than import one.

Comparing Claude and GPT

Same code, one flag. Run the identical task on both and read the token counts side by side.

Shipping agents to clients

The licence covers use in software you sell, with no attribution required.

Not a fit if you want batteries-included orchestration — LangChain and LlamaIndex exist and are better at that. This is deliberately small.

Honestly

What this isn't.

!

Not a framework. No plugin system, no chain abstraction, no DSL. Not async — deliberately synchronous so it can be read in one sitting; porting it is an afternoon. Not RAG — no vector store, no embeddings, no retrieval. Not production infrastructure — no queue, no persistence beyond a JSONL cost ledger, no multi-tenancy.

One thing will go stale: the model prices. They live in a single dict in one file with the date they were checked, so updating them takes ten seconds. An unknown model reports 0.00 rather than guessing — a wrong number is worse than a missing one, because wrong numbers get trusted.

The budget guard is a convenience, not a guarantee. Set limits on your provider account as well.

Is — the loop, done properly
Isn't — a platform

Questions

Before you buy.

Q

How do I build an agent loop from scratch?

Send the conversation plus your tool definitions to the model, check the response for tool calls, execute the ones it asked for, append the results to the conversation, and send it back. Repeat until the model replies without requesting tools, or until a turn limit stops it. That is genuinely the whole loop — about 100 lines. Everything else, budgets, retries and cost accounting, exists to make those 100 lines safe to run in front of a paying customer.

Q

What is the difference between Anthropic and OpenAI tool calling?

The formats differ in one way that breaks most multi-provider code: after executing tools, Anthropic expects a single user message containing every tool result, while OpenAI expects one message per result with a tool role. Anthropic returns tool calls as content blocks of type tool_use; OpenAI returns them under message.tool_calls with the arguments as a JSON string that needs parsing, and which can arrive malformed.

Q

How do I track LLM API costs accurately?

Read the usage block the provider returns with each response rather than counting tokens locally. Local estimates drift from the bill because system prompts, tool definitions and cached content all count in ways that are tedious to reproduce and change without notice. Cached tokens are also billed at different rates — roughly 10% for reads and 125% for writes — so tracking them as ordinary input tokens under-reports on any long conversation.

Q

Do I need LangChain to build an agent?

No. A tool-calling loop is about 100 lines of ordinary Python against the HTTP API. Frameworks earn their place when you need their specific abstractions — retrieval pipelines, complex chains, a plugin ecosystem — and cost you when you do not, because they hide the wire format that you need to see when a tool call comes back malformed. Start small, and adopt a framework when something concrete demands it.

Q

Can I use this in software I sell to clients?

Yes. The licence permits commercial use including client work and software you ship for money, with no attribution required. You may modify it, extract parts, and build on it freely. The only restriction is that you may not resell or republish the kit itself as a kit — build with it, do not repackage it.

Q

What happens when model prices change?

They will. Prices live in a single PRICES dict in one file, stamped with the date they were last checked, so updating is a ten-second edit rather than a hunt through the codebase. A model that is not in the dict reports a cost of zero rather than guessing, because a wrong number is worse than a missing one — wrong numbers get trusted and end up in someone's margin calculation.

Two minutes to first run. Thirty tests before you spend.

Instant download. Commercial licence including software you sell. Free updates for life. Seven-day refund if it isn't useful.

Launch price · Going to $79 after the first 20 sales

Read the loop before you buy it

The whole design is explained in how to build an agent loop from scratch — the four things tutorials skip, and why each one matters. If you'd rather have the agent built for you, that's the day job.