Spendline Proxy API
The request path. Route AI traffic through these.
The request path. Route AI traffic through these.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/spendline-ai:spendline-ai-proxy-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Spendline Proxy API
version: 1.0.0
summary: Spendline is a financial control layer for production AI spend. It routes supported AI requests, records attributed costs and applies configured controls, and covers only traffic actually routed through it. Your application supplies the customer, agent, workflow and team labels; configured budgets and policies are checked before a supported request is forwarded.
description: 'Spendline is a financial control layer for production AI spend. It routes supported AI requests, records attributed costs and applies configured controls, and covers only traffic actually routed through it. Your application supplies the customer, agent, workflow and team labels; configured budgets and policies are checked before a supported request is forwarded.
**Mechanism.** Request-path proxy. Applications change their provider base URL to Spendline and keep their own provider API keys. Attribution travels as HTTP headers.
**Differentiator.** Financial control, not engineering observability. Strict budgets refuse a supported request whose estimated cost would exceed a limit (HTTP 402) before it reaches the provider; actual response cost can differ from the estimate. Costs are kept in an append-only ledger with an owner-run month close.
## Base URL rules (the most common integration mistake)
- OpenAI SDK and every OpenAI-compatible client: `https://www.spendline.ai/v1`: **with** `/v1`.
- Anthropic SDK: `https://www.spendline.ai`: **without** `/v1`. The SDK appends `/v1/messages` itself.
That asymmetry is real. Do not "fix" one to match the other.
## Two credentials, two headers
- The application''s own provider key travels in `Authorization: Bearer` (OpenAI-compatible)
or `x-api-key` (Anthropic). Spendline forwards it upstream unchanged.
- The Spendline key travels in `x-spendline-key` and is consumed by Spendline.
## Not proxied
Embeddings, image generation, audio, vector search and Google''s native generateContent
shape are not in the request path. Leave those calls pointed directly at the provider;
they are outside Spendline''s controls and records.
## Human authorization
Billing, payment methods, provider-key storage, budget raises/deletes and month
close/reopen are deliberately absent from this spec: they require a human. See
https://www.spendline.ai/agents/onboarding.md for what an agent may do alone.
## Getting access
A human with no account starts free at https://www.spendline.ai/?signup=1 ("Start free":
self-serve sign-up, free for 30 days, no card) or books a guided 30-day free pilot on
a call at https://www.spendline.ai/book/. The human opens the link and creates the account; an agent
never signs up on their behalf. There is no public Spendline price; pricing is discussed
with each customer on a call. People invited to an existing account sign in and issue a key in
the dashboard.'
contact:
name: Spendline
email: fida@spendline.ai
url: https://www.spendline.ai
servers:
- url: https://www.spendline.ai
description: Spendline production
security:
- SpendlineKey: []
tags:
- name: Proxy
description: The request path. Route AI traffic through these.
paths:
/v1/chat/completions:
post:
tags:
- Proxy
operationId: proxyChatCompletions
summary: OpenAI-compatible chat completions, governed and recorded
description: 'Set the OpenAI SDK baseURL/base_url to https://www.spendline.ai/v1. WITH /v1. The SDK appends /chat/completions itself.
Providers reachable on this shape: openai, google, xai, mistral, deepseek, qwen, together, fireworks, groq.
The model name selects the provider (gpt-* → OpenAI, gemini-* → Google, grok-* → xAI, mistral-* → Mistral, …).
Streaming is supported. Request/response bodies are the provider''s own. Spendline
does not reshape them.'
parameters:
- name: Authorization
in: header
required: true
description: The application's OWN provider key, as `Bearer <key>`. Forwarded upstream.
schema:
type: string
- name: x-agent-id
in: header
required: false
description: Stable name of the bot/agent/feature making the call, e.g. support-bot. One per agent. Not per request. Required unless an owner or admin has turned attribution enforcement off. New accounts have it on.
schema:
type: string
- name: x-customer-id
in: header
required: false
description: The end customer this request is billable to. PER REQUEST. A hardcoded value makes per-customer cost attribution useless, thread it from request context. Required unless an owner or admin has turned attribution enforcement off. New accounts have it on.
schema:
type: string
- name: x-spendline-tags
in: header
required: false
description: 'JSON object that must include a cost-centre key: one of cost_center, costCenter, department, or team. Example: {"team":"support","env":"prod"} Per call site or per request. Required unless an owner or admin has turned attribution enforcement off. New accounts have it on.'
schema:
type: string
- name: x-workflow-id
in: header
required: false
description: Groups a multi-step run.
schema:
type: string
- name: x-step-name
in: header
required: false
description: Labels a step within a workflow.
schema:
type: string
- name: x-source-route
in: header
required: false
description: The application route that triggered the call.
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- model
- messages
properties:
model:
type: string
description: Selects the provider. See /agents/providers.md.
messages:
type: array
items:
type: object
stream:
type: boolean
max_tokens:
type: integer
description: Also used to project pre-call cost for budget enforcement. A realistic value makes enforcement more accurate.
additionalProperties: true
responses:
'200':
description: Provider response, passed through unchanged. The call is recorded in the ledger.
'400':
description: missing_required_attribution, a required attribution header is absent. Attribution enforcement is on by default for new accounts.
content:
application/json:
schema:
type: object
properties:
error_type:
type: string
example: missing_required_attribution
missing_fields:
type: array
items:
type: string
'401':
description: The Spendline key is missing or invalid. Do NOT fall back to the provider.
'402':
description: A budget blocked this call BEFORE any spend occurred. Intended behaviour. Surface it; never retry against the provider directly.
'403':
description: A policy or governance rule blocked the call. Never route around it.
'429':
description: Rate limited. Back off and retry.
'502':
description: 'provider_outcome_uncertain: the request reached the provider and the reply was lost or was a server error, so the provider may have charged. Surface it. Never fall back to the provider and never resend under a new key: either could buy the same work twice. The SDK''s own retry then shows 409 requires_reconciliation.'
'503':
description: 'Spendline refused and nothing was sent to the provider: budget_admission_unavailable, execution_journal_unavailable or correction_state_unavailable. Retry later through Spendline with the same Idempotency-Key. Never fall back to the provider: that skips the check this refusal protects. provider_unavailable: repeated failures made Spendline pause sending to that provider for about 30 seconds. Nothing was sent. Retry through Spendline with the same key. Do not retry directly unless the account owner has chosen that for this workflow; a direct call is outside budgets and cost records. Any other JSON answer from Spendline is never a fallback case. The only other case for retrying directly against the provider is when Spendline cannot be reached: a network error, a timeout, or a 5xx that is not a JSON answer from Spendline. A timeout, dropped connection or load balancer error can also happen after the request reached the provider, so a direct retry can buy the work twice: decide per workflow whether that is acceptable. A request sent directly to the provider is outside Spendline''s budget checks and cost records.'
/v1/messages:
post:
tags:
- Proxy
operationId: proxyAnthropicMessages
summary: Anthropic messages, governed and recorded
description: 'Set the Anthropic SDK baseURL to https://www.spendline.ai. WITHOUT /v1. The Anthropic SDK appends /v1/messages itself. This asymmetry with the OpenAI SDK is real; do not "fix" it.
Streaming is supported.'
parameters:
- name: x-api-key
in: header
required: true
description: The application's OWN Anthropic key. Forwarded upstream. The SPENDLINE key must NOT go here, put it in x-spendline-key.
schema:
type: string
- name: anthropic-version
in: header
required: true
schema:
type: string
example: '2023-06-01'
- name: x-agent-id
in: header
required: false
description: Stable name of the bot/agent/feature making the call, e.g. support-bot. One per agent. Not per request. Required unless an owner or admin has turned attribution enforcement off. New accounts have it on.
schema:
type: string
- name: x-customer-id
in: header
required: false
description: The end customer this request is billable to. PER REQUEST. A hardcoded value makes per-customer cost attribution useless, thread it from request context. Required unless an owner or admin has turned attribution enforcement off. New accounts have it on.
schema:
type: string
- name: x-spendline-tags
in: header
required: false
description: 'JSON object that must include a cost-centre key: one of cost_center, costCenter, department, or team. Example: {"team":"support","env":"prod"} Per call site or per request. Required unless an owner or admin has turned attribution enforcement off. New accounts have it on.'
schema:
type: string
- name: x-workflow-id
in: header
required: false
description: Groups a multi-step run.
schema:
type: string
- name: x-step-name
in: header
required: false
description: Labels a step within a workflow.
schema:
type: string
- name: x-source-route
in: header
required: false
description: The application route that triggered the call.
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- model
- max_tokens
- messages
properties:
model:
type: string
example: claude-sonnet-5
max_tokens:
type: integer
messages:
type: array
items:
type: object
stream:
type: boolean
additionalProperties: true
responses:
'200':
description: Anthropic response, passed through unchanged. The call is recorded.
'400':
description: missing_required_attribution, a required attribution header is absent. Attribution enforcement is on by default for new accounts.
content:
application/json:
schema:
type: object
properties:
error_type:
type: string
example: missing_required_attribution
missing_fields:
type: array
items:
type: string
'401':
description: The Spendline key is missing or invalid. Do NOT fall back to the provider.
'402':
description: A budget blocked this call BEFORE any spend occurred. Intended behaviour. Surface it; never retry against the provider directly.
'403':
description: A policy or governance rule blocked the call. Never route around it.
'429':
description: Rate limited. Back off and retry.
'502':
description: 'provider_outcome_uncertain: the request reached the provider and the reply was lost or was a server error, so the provider may have charged. Surface it. Never fall back to the provider and never resend under a new key: either could buy the same work twice. The SDK''s own retry then shows 409 requires_reconciliation.'
'503':
description: 'Spendline refused and nothing was sent to the provider: budget_admission_unavailable, execution_journal_unavailable or correction_state_unavailable. Retry later through Spendline with the same Idempotency-Key. Never fall back to the provider: that skips the check this refusal protects. provider_unavailable: repeated failures made Spendline pause sending to that provider for about 30 seconds. Nothing was sent. Retry through Spendline with the same key. Do not retry directly unless the account owner has chosen that for this workflow; a direct call is outside budgets and cost records. Any other JSON answer from Spendline is never a fallback case. The only other case for retrying directly against the provider is when Spendline cannot be reached: a network error, a timeout, or a 5xx that is not a JSON answer from Spendline. A timeout, dropped connection or load balancer error can also happen after the request reached the provider, so a direct retry can buy the work twice: decide per workflow whether that is acceptable. A request sent directly to the provider is outside Spendline''s budget checks and cost records.'
/v1/responses:
post:
tags:
- Proxy
operationId: proxyOpenAiResponses
summary: OpenAI Responses API, governed and recorded (non-streaming only)
description: 'Same base URL as chat-completions.
**stream: true is rejected with a clear error. Non-streaming only.**
OpenAI models only. Built-in tools such as web_search work and their cost is included in recorded spend.'
parameters:
- name: Authorization
in: header
required: true
description: The application's OWN OpenAI key, as `Bearer <key>`.
schema:
type: string
- name: x-agent-id
in: header
required: false
description: Stable name of the bot/agent/feature making the call, e.g. support-bot. One per agent. Not per request. Required unless an owner or admin has turned attribution enforcement off. New accounts have it on.
schema:
type: string
- name: x-customer-id
in: header
required: false
description: The end customer this request is billable to. PER REQUEST. A hardcoded value makes per-customer cost attribution useless, thread it from request context. Required unless an owner or admin has turned attribution enforcement off. New accounts have it on.
schema:
type: string
- name: x-spendline-tags
in: header
required: false
description: 'JSON object that must include a cost-centre key: one of cost_center, costCenter, department, or team. Example: {"team":"support","env":"prod"} Per call site or per request. Required unless an owner or admin has turned attribution enforcement off. New accounts have it on.'
schema:
type: string
- name: x-workflow-id
in: header
required: false
description: Groups a multi-step run.
schema:
type: string
- name: x-step-name
in: header
required: false
description: Labels a step within a workflow.
schema:
type: string
- name: x-source-route
in: header
required: false
description: The application route that triggered the call.
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- model
properties:
model:
type: string
input: {}
tools:
type: array
items:
type: object
description: Built-in tools such as web_search work; their cost is included in recorded spend.
stream:
type: boolean
description: Must be false or omitted. true is rejected.
additionalProperties: true
responses:
'200':
description: OpenAI Responses payload, passed through unchanged.
'400':
description: missing_required_attribution, a required attribution header is absent. Attribution enforcement is on by default for new accounts.
content:
application/json:
schema:
type: object
properties:
error_type:
type: string
example: missing_required_attribution
missing_fields:
type: array
items:
type: string
'401':
description: The Spendline key is missing or invalid. Do NOT fall back to the provider.
'402':
description: A budget blocked this call BEFORE any spend occurred. Intended behaviour. Surface it; never retry against the provider directly.
'403':
description: A policy or governance rule blocked the call. Never route around it.
'429':
description: Rate limited. Back off and retry.
'502':
description: 'provider_outcome_uncertain: the request reached the provider and the reply was lost or was a server error, so the provider may have charged. Surface it. Never fall back to the provider and never resend under a new key: either could buy the same work twice. The SDK''s own retry then shows 409 requires_reconciliation.'
'503':
description: 'Spendline refused and nothing was sent to the provider: budget_admission_unavailable, execution_journal_unavailable or correction_state_unavailable. Retry later through Spendline with the same Idempotency-Key. Never fall back to the provider: that skips the check this refusal protects. provider_unavailable: repeated failures made Spendline pause sending to that provider for about 30 seconds. Nothing was sent. Retry through Spendline with the same key. Do not retry directly unless the account owner has chosen that for this workflow; a direct call is outside budgets and cost records. Any other JSON answer from Spendline is never a fallback case. The only other case for retrying directly against the provider is when Spendline cannot be reached: a network error, a timeout, or a 5xx that is not a JSON answer from Spendline. A timeout, dropped connection or load balancer error can also happen after the request reached the provider, so a direct retry can buy the work twice: decide per workflow whether that is acceptable. A request sent directly to the provider is outside Spendline''s budget checks and cost records.'
components:
securitySchemes:
SpendlineKey:
type: apiKey
in: header
name: x-spendline-key
description: The Spendline API key. NEVER send this as x-api-key. Anthropic uses that header for the Claude provider key, so the Spendline key would be forwarded upstream and rejected.
externalDocs:
description: Agent-facing documentation index
url: https://www.spendline.ai/agents/index.md
x-spendline:
positioning: Financial control, not engineering observability. Strict budgets refuse a supported request whose estimated cost would exceed a limit (HTTP 402) before it reaches the provider; actual response cost can differ from the estimate. Costs are kept in an append-only ledger with an owner-run month close.
providers:
- openai
- anthropic
- google
- xai
- mistral
- deepseek
- qwen
- together
- fireworks
- groq
response_contract:
- status: 200
meaning: Forwarded and recorded.
agent_action: Done.
- status: 400
error_type: missing_required_attribution
meaning: Attribution enforcement is on and a required header is missing.
agent_action: Add x-agent-id, x-customer-id and x-spendline-tags (with a cost-centre key).
- status: 401
meaning: The Spendline key is missing or invalid.
agent_action: Check SPENDLINE_API_KEY. Do NOT fall back to the provider.
- status: 402
meaning: A budget blocked this call before any spend occurred.
agent_action: This is correct, intended behaviour. Surface it as an error. NEVER retry against the provider directly, that defeats the entire product.
- status: 403
meaning: A policy or governance rule blocked the call.
agent_action: Surface it. NEVER route around it.
- status: 403
error_type: email_not_verified
meaning: The key is real, but the account owner has not confirmed their email yet. A new account stays off until they click the link Spendline emailed them. Nothing was sent.
agent_action: Ask your human to click the confirmation link in their email (or resend it from the dashboard), then retry. Do NOT fall back to the provider.
- status: 429
meaning: Rate limited.
agent_action: Back off and retry.
- status: 502
error_type: provider_outcome_uncertain
meaning: The request reached the provider and the reply was lost or was a server error, so the provider may have charged.
agent_action: 'Surface it. NEVER fall back to the provider and NEVER resend under a new key: either could buy the same work twice. The SDK''s own retry then shows 409 requires_reconciliation.'
- status: 409
error_type: requires_reconciliation
meaning: An earlier attempt under this Idempotency-Key may have reached the provider.
agent_action: Do not retry under a new key. A finance operator resolves it in the dashboard.
- status: 503
error_type: budget_admission_unavailable
meaning: Spendline could not verify the remaining budget, so it refused.
agent_action: 'Nothing was sent. Retry later through Spendline with the same Idempotency-Key. NEVER fall back to the provider: that skips the budget check this refusal protects.'
- status: 503
error_type: execution_journal_unavailable
meaning: Spendline could not safely reserve this request, so it refused.
agent_action: 'Nothing was sent. Retry later through Spendline with the same Idempotency-Key. NEVER fall back to the provider: that skips the budget check this refusal protects.'
- status: 503
error_type: correction_state_unavailable
meaning: Spendline could not confirm which corrections were written off, so it refused.
agent_action: 'Nothing was sent. Retry later through Spendline with the same Idempotency-Key. NEVER fall back to the provider: that skips the budget check this refusal protects.'
- status: 503
error_type: provider_unavailable
meaning: Repeated failures made Spendline pause sending to this provider for about 30 seconds. This request was not sent.
agent_action: Nothing was sent. Retry through Spendline with the same key. Do not retry directly unless the account owner has chosen that for this workflow; a direct call is outside budgets and cost records.
- status: Any other 5xx JSON answer from Spendline
meaning: Spendline answered. This is a decision, not an outage.
agent_action: Surface it. NEVER fall back to the provider.
- status: Network error / timeout / 5xx that is not a JSON answer from Spendline
meaning: Spendline cannot be reached.
agent_action: 'Retry once directly against the provider so the application stays up, reusing the same Idempotency-Key. Apart from 503 provider_unavailable where the account owner has chosen it, this is the ONLY case where bypassing Spendline is correct. A timeout, dropped connection or load balancer error can also happen after the request reached the provider, so a direct retry can buy the work twice: decide per workflow whether that is acceptable. A request sent directly to the provider is outside Spendline''s budget checks and cost records.'
human_authorization_required:
- billing and payment methods
- storing provider API keys
- raising or deleting a budget
- approving a budget override
- closing, reopening or reconciling a month
- creating an account
- issuing an API key to an agent
documentation_index: https://www.spendline.ai/agents/index.md