Provider Proxy API
After this page you can send requests through https://api.spmos.ai in your provider's dialect and read the receipts it returns.
Use an endpoint
Send to the Base URL https://api.spmos.ai with Authorization: Bearer spm_live_.... Anthropic clients may put the same key in x-api-key.
| Endpoint | Dialect |
|---|---|
POST /v1/chat/completions |
OpenAI Chat Completions |
POST /v1/responses |
OpenAI Responses |
POST /v1/messages |
Anthropic Messages |
Responses keep the provider's JSON or SSE dialect. Memory and compression may change the outgoing request, so forwarding is not byte-identical.
The hosted API has no model-discovery endpoint. Configure model selection in the provider channel. For Custom channels, the console can run Fetch models. GET /v1/models is for Local Proxy, which uses your own upstream.
Choose memory access
The default follows the scopes on your SPM key:
| Key scopes | Default memory mode |
|---|---|
| read + write | read-write |
| read only | read |
| write only | write |
| neither | off |
Lower the mode for one request with the x-spm-memory-mode header, set to off, read, write or read-write. It cannot grant more access than the key has.
Choose compression
x-spm-compression-mode: passthrough | shadow | deterministic
passthrough: forwards the original request and adds recalled memory when available.shadow: measures compression but forwards the original history.deterministic: may shorten eligible older history after safety and source checks. Recent exchanges, protected instructions, reasoning, and tool state limit removal. Older tool results may also be shortened.
A removed range may be replaced by a short reversible summary, called a fold. The receipt says what was folded.
Memory and compression are independent. Set account defaults in Settings → Proxy for compression mode, input budget, and maximum recalled context. A request header overrides the account setting for that request.
The input budget is when SPM may consider shortening history, not a target it promises to reach. Start with 8K–16K for short latency-sensitive chat, 16K–32K for normal coding or tool use, 32K–64K for tool-heavy tasks, and 64K–128K for very long sessions. Measure forwarded tokens, latency, provider caching, and task success together.
A receipt can show 0% reduction when the request is short, the conversation is new, or protected state dominates. This is expected.
Inspect request receipts
Every hosted request creates a receipt:
GET /v1/spm/requests?limit=50
GET /v1/spm/requests/{receipt_id}
receipt_id identifies one hosted request. Lookups require the receipt:read scope. The response includes metadata and lifecycle state, such as id, request_id, protocol, model, memory_mode, memory_state, compression_mode, request_state, billing_state, bytes_sent, provider_usage_state, error_code, and lifecycle timestamps. memory_state records the memory lookup status.
Usage and savings appear separately in the console. These are not signed deletion receipts, and Local Proxy traffic does not create hosted receipts.
SPM token counts are estimates, not provider billing measurements. A missing provider output counter is not zero. The provider invoice remains authoritative for charges.
Read response headers
x-spm-* headers report request, receipt, memory, and compression state. Successful requests include x-spm-* headers for the request or receipt ID and memory and compression state. When available, x-spm-shadow-original-tokens and x-spm-shadow-forwarded-tokens are input estimates, not billing counts. x-spm-continuity-state reports the history decision:
committed: eligible older exchanges were removed.elided_tool_output: eligible older tool results were shortened.not_needed: nothing needed removal.shadow_only: compression was measured but not applied.bypassed_*: a safety check failed, so the full request was preserved.not_applicable: no continuity decision was needed.
A bypass only describes that check. It does not prove that no other eligible transformation occurred. Keep original artifacts when exact reproduction matters.
Preserve protected history
SPM may compress ordinary chat after source-bound memory coverage is ready. It preserves provider-managed Responses state such as previous_response_id, reasoning blocks, tool-call/tool-result pairs, and other opaque provider state. It can still recall memory without folding or deleting that state.
Memory lookup uses a bounded fast path by default. A failed lookup may continue without injected context and report a degraded memory state. Automatic capture is best-effort; verify important material with memory status and read tools.
Handle errors and check health
| HTTP | Example code | Meaning |
|---|---|---|
| 401 | auth invalid/revoked | Key is missing, malformed, revoked, or stale |
| 403 | scope/access denied | Key or tenant lacks access |
| 409 | stale generation or idempotency conflict | Retry according to returned state |
| 422 | invalid mode | Request violates policy |
| 429 | RATE_LIMIT_EXCEEDED |
Honor Retry-After |
| 503 | RATE_LIMITER_UNAVAILABLE |
Request blocked because rate-limit checking is unavailable |
| 5xx | provider/dependency failure | Inspect the receipt and error code before retrying |
tenant identifies the account boundary. generation identifies the current request state version.
Health probes: GET /health, GET /livez, and GET /readyz.
Verify
curl -fsS -o /dev/null -w '%{http_code}\n' https://api.spmos.ai/health
Expected: 200.