For AI agents, the documentation index lists all pages. Append .md to a documentation URL for Markdown, or request text/markdown.

Skip to Content
spare inference

Overview

Set up Claude Code, Codex, OpenCode and the OpenAI and Anthropic SDKs to use Spare Inference.

2 min readEdit this page

Spare speaks the OpenAI Chat Completions, OpenAI Responses and Anthropic Messages APIs, so most tools only need a new base URL, your Spare key and a model id. These guides give the exact setup for each one.

Coding agents

Each agent guide has a Copy setup prompt button: paste the prompt into the agent and it does the setup itself, following the guide.

SDKs

Two ways to connect

Every guide offers both:

Run on DeepSeek V4.1 FlashKeep your model, add the Router
Model iddeepseek-v4.1-flashspare/auto
Talks toThe Spare APIThe CLI's Cost routing on your machine
What you needA Spare keyA Spare key, the CLI, and your provider key or subscription
What changesEvery request goes to SpareOnly the turns your routing policy sends to the economy model
Billed bySpare, at the live priceSpare for routed turns; your provider for the rest
Best forLowest cost, new projectsCutting the bill without changing models

Provider failures are handled for you either way: a request moves to the next provider serving the model. To fall back to a different model, see Model fallbacks.

Not listed?

Anything that lets you set a base URL works:

Your tool speaksBase URLKey header
OpenAI Chat Completions or Responseshttps://api.spareinference.ai/v1Authorization: Bearer
Anthropic Messageshttps://api.spareinference.aix-api-key or Authorization: Bearer

Use the model id deepseek-v4.1-flash. If the tool asks for limits, the context window is 1M tokens and the maximum output 384K.

How is this guide?