Skip to main content
API reference

Use the OpenAI-compatible ModelSpend gateway.

The proxy endpoint is designed for fast adoption: existing OpenAI-compatible clients can point at ModelSpend with a base URL change and a ModelSpend API key.

Base URL

Base URL: https://api.modelspend.best
Proxy URL: https://api.modelspend.best/proxy/v1

Authentication

Every proxy request must include a server-side ModelSpend API key.

Authorization: Bearer YOUR_MODELSPEND_API_KEY

Endpoints

POST /proxy/v1/chat/completions

OpenAI-compatible chat completion endpoint. Use model auto for ModelSpend routing, or pass an explicit model where supported.

POST /proxy/v1/embeddings

OpenAI-compatible embeddings endpoint for routed embedding workloads.

GET /health

Lightweight public API health check.

GET /readyz

Readiness check used by production monitoring and deployment validation.

Chat completion example

curl -X POST https://api.modelspend.best/proxy/v1/chat/completions
  -H "Authorization: Bearer YOUR_MODELSPEND_API_KEY"
  -H "Content-Type: application/json"
  -d '{
    "model": "auto",
    "messages": [{"role": "user", "content": "Summarise this support ticket."}]
  }'

Standard error shape

API errors should use a consistent structured format so applications can handle authentication, validation, policy and upstream provider failures cleanly.

{
  "error": "Human-readable message",
  "code": "PROVIDER_UPSTREAM_ERROR",
  "details": {}
}