# Overview (/docs/api)

> For AI agents, the [documentation index](https://bitrouter.ai/llms.txt) lists all pages. Append .md to a documentation URL to read its Markdown.

Spare Inference speaks the APIs your code already uses. Point an OpenAI or Anthropic SDK at us and change
the model id; requests, responses, streaming and tool calls work as they do there.

## Endpoints \[#endpoints]

**Inference.** Any API key can call these.

| Endpoint                                                                      | Compatible with         | Use it from                                                      |
| ----------------------------------------------------------------------------- | ----------------------- | ---------------------------------------------------------------- |
| [`POST /v1/chat/completions`](https://bitrouter.ai/docs/api/chat-completions) | OpenAI Chat Completions | OpenAI SDKs, LangChain, LiteLLM, most frameworks                 |
| [`POST /v1/responses`](https://bitrouter.ai/docs/api/responses)               | OpenAI Responses        | OpenAI SDKs and the Agents SDK                                   |
| [`POST /v1/messages`](https://bitrouter.ai/docs/api/messages)                 | Anthropic Messages      | Anthropic SDKs and the agents built on them                      |
| [`GET /v1/models`](https://bitrouter.ai/docs/api/models)                      | OpenAI Models           | Any client that lists models. Returns live prices; no key needed |

**Usage and billing.** Read-only, for scripts and agents that track their own spend. For history and
totals, use the console's **Activity** and **Billing** pages.

| Endpoint                                                                               | Returns                        | Scope              |
| -------------------------------------------------------------------------------------- | ------------------------------ | ------------------ |
| [`GET /v1/requests/{request_id}/settlement`](https://bitrouter.ai/docs/api/settlement) | What one request used and cost | `inference:invoke` |
| [`GET /v1/billing/balance`](https://bitrouter.ai/docs/api/balance)                     | Credit available now           | `billing:read`     |

**Configuration.** Manage from code what you would otherwise set in the console.

| Endpoints                                                                            | Manage                                                                         | Scopes                                        |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | --------------------------------------------- |
| [`/v1/namespaces/me/routing-presets`](https://bitrouter.ai/docs/api/routing-presets) | [Routing presets](https://bitrouter.ai/docs/fleet/provider-selection)          | `routing_preset:read`, `routing_preset:write` |
| [`/v1/byok/connections`](https://bitrouter.ai/docs/api/provider-keys)                | [Provider keys](https://bitrouter.ai/docs/fleet/byok) you saved in the console | `byok:read`, `byok:write`                     |

[`GET /health`](https://bitrouter.ai/docs/api/health) tells you whether the API is reachable.

## Base URLs \[#base-urls]

|            | OpenAI SDKs                                | Anthropic SDKs                          |
| ---------- | ------------------------------------------ | --------------------------------------- |
| Production | `https://api.spareinference.ai/v1`         | `https://api.spareinference.ai`         |
| Sandbox    | `https://spareinference.ai/api/sandbox/v1` | `https://spareinference.ai/api/sandbox` |

Anthropic SDKs add `/v1` themselves. The sandbox covers the inference endpoints only: any key is accepted and
every request gets a canned reply. Pick it in the server menu of an endpoint page to send requests from the
browser.

## Authentication \[#authentication]

Send your API key as `Authorization: Bearer $SPARE_API_KEY` or `x-api-key: $SPARE_API_KEY`. See
[Authentication](https://bitrouter.ai/docs/api/authentication) for scopes.

## Models \[#models]

|            |                                        |
| ---------- | -------------------------------------- |
| Model id   | `deepseek-v4.1-flash`                  |
| Snapshot   | `deepseek-ai/DeepSeek-V4.1-Flash-1017` |
| Context    | 1M tokens                              |
| Max output | 384K tokens                            |

More open models are coming. [`GET /v1/models`](https://bitrouter.ai/docs/api/models) always has the current list and prices; see
also [Models](https://bitrouter.ai/models).

## Request ids \[#request-ids]

Every inference response carries an `x-bitrouter-request-id` header. Keep it: it is how you look up what the
request cost with [settlement](https://bitrouter.ai/docs/api/settlement), and what to send us if something went wrong.

## Errors \[#errors]

Errors follow the shape of the API each endpoint is compatible with. See [Errors](https://bitrouter.ai/docs/api/errors) for
status codes and what to do about them.

## The spec \[#the-spec]

The OpenAPI document for these endpoints is at [`/openapi.json`](https://bitrouter.ai/openapi.json), for generating clients or
handing to an agent. Every page here also has a Markdown version: add `.md` to its URL.