Authentication
Gateway requests authenticate with a Spendra scoped key:OpenAI SDK setup
OpenAI integrations keep the OpenAI SDK and change the API key and base URL:Provider-specific chat
Spendra supports provider-specific Chat Completions routing at:openai, openrouter, google, vertexai, azure, and anthropic.
Example:
gpt-4.1-mini; non-OpenAI chat keys must grant {provider}/{model}, such as openrouter/openai/gpt-4.1-mini, azure/gpt-4.1-mini, or vertexai/google/gemini-2.0-flash.
Idempotency
Send an idempotency key with gateway requests when your client can retry:409 with idempotency_in_progress. If the original request already settled, Spendra returns HTTP 409 with settlement metadata and idempotency_replay_unavailable because prompt and response bodies are not retained for replay. Failed reservations are not replayed.
Responses API
Image input
Base64 PDF input
Files API
Upload a file through Spendra when your client uses OpenAI file IDs:Chat Completions API
/v1/chat/completions route proxies to OpenAI. Use /v1/providers/{provider}/chat/completions when routing chat requests to OpenRouter, Google Gemini API, Vertex AI, Azure OpenAI, or Anthropic.
Tool calls
Spendra also exposes governed tool-call routing:Blocking behavior
Spendra blocks before the upstream provider call when:- The key is invalid, inactive, expired, or revoked.
- The key scope does not allow the requested provider, model, tool, project, or actor.
- No explicit hard-cap policy permits the spend.
- An applicable hard cap cannot reserve enough budget.