Operayde Gateway API
Operayde inference gateway. Exposes an OpenAI-compatible chat/embeddings surface, an Anthropic-compatible Messages surface, a tenant-scoped bulk knowledge-ingest surface, and a token-protected control-plane admin surface. This spec is Class 1 (see contracts/README.md): its path set is authoritative and CI-enforced against the gateway router (services/gateway/internal/server/server.go) via `make openapi-routediff`. **Authentication** — client routes (/v1/*) accept a virtual key (`vk_live_...` / `vk_test_...`) in either `Authorization: Bearer vk_...` or `x-api-key: vk_...` (the latter is how the Anthropic SDK and Claude Code send credentials; when both headers are present, x-api-key wins), or an OIDC JWT bearer token. Admin routes (/control/v1/*) require a separate shared bearer token and are disabled (401) when that token is not configured. **Error envelope** — all /v1 errors use the pkg/httperr envelope: `{"error": {"code": "...", "message": "...", "request_id": "..."}}`. The /control/v1 surface uses a flat shape: `{"error": "...", "message": "..."}`.
| Base URL | Environment |
|---|---|
| https://gw.operayde.com | Production central gateway (Apache proxy to :8095) |
Inference
Chat completion, Anthropic Messages, and embedding endpoints.
/v1/chat/completionsCreate a chat completion (OpenAI-compatible)Generates a model response for the given chat conversation. Supports streaming (SSE) and non-streaming modes, tool/function calling, and per-tenant model routing. Requests pass through OPA policy evaluation, ingress/egress guardrails, PII redaction, spend-cap checks, and rate limiting before reaching the upstream provider.
Request body (required) · application/json
| Field | Type | Notes |
|---|---|---|
| model* | string | The friendly model name as configured in tenant routes. |
| messages* | array<Message> | |
| stream | boolean | If true, partial message deltas are sent as SSE events. |
| temperature | number (double) | |
| top_p | number (double) | |
| max_tokens | integer | |
| stop | array<string> | |
| tools | array<Tool> | |
| tool_choice | any | Controls which tool is called by the model. |
| user | string | End-user identifier for abuse monitoring. |
Responses
| Field | Type | Notes |
|---|---|---|
| id | string | |
| object | string | |
| created | integer (int64) | |
| model | string | |
| choices | array<object> | |
| usage | Usage |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
/v1/messagesCreate a message (Anthropic-compatible)Anthropic Messages API surface. The gateway translates the request into its internal chat format, applies the same policy/guardrail/ routing pipeline as /v1/chat/completions, and translates the response back to the Anthropic shape. Used by the Anthropic SDKs and Claude Code (which send the virtual key in x-api-key).
Request body (required) · application/json
| Field | Type | Notes |
|---|---|---|
| model* | string | |
| max_tokens* | integer | |
| system | any | System prompt — string or array of content blocks. |
| messages* | array<AnthropicMessage> | |
| stream | boolean | |
| temperature | number (double) | |
| top_p | number (double) | |
| stop_sequences | array<string> | |
| tools | array<AnthropicTool> | |
| tool_choice | any | Anthropic tool_choice object. |
| metadata | object | |
| thinking | any | Extended-thinking configuration (Anthropic-native). |
Responses
| Field | Type | Notes |
|---|---|---|
| id | string | |
| type | string | |
| role | string | |
| model | string | |
| content | array<object> | |
| stop_reason | string | |
| usage | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
/v1/messages/count_tokensCount tokens for a message (Anthropic-compatible)Mirrors Anthropic's messages/count_tokens endpoint — the same body shape as /v1/messages but without max_tokens. For routes that resolve to a native Anthropic provider the request is proxied upstream (their tokenizer is authoritative); for every other provider the gateway's internal estimator is used, consistent with pre-dispatch budget checks and billing.
Request body (required) · application/json
| Field | Type | Notes |
|---|---|---|
| model* | string | |
| system | any | System prompt — string or array of content blocks. |
| messages* | array<AnthropicMessage> | |
| tools | array<AnthropicTool> |
Responses
| Field | Type | Notes |
|---|---|---|
| input_tokens* | integer |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
/v1/embeddingsCreate embeddingsCreates an embedding vector representing the input text. Routes to the configured provider for the requested model. Subject to OPA policy evaluation and virtual-key scope enforcement (embed:invoke).
Request body (required) · application/json
| Field | Type | Notes |
|---|---|---|
| model* | string | |
| input* | array<string> |
Responses
| Field | Type | Notes |
|---|---|---|
| object | string | |
| data | array<EmbeddingItem> | |
| model | string | |
| usage | Usage |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
Models
Model discovery.
/v1/modelsList available modelsReturns the models available to the authenticated caller. Results are scoped to the tenant's configured model routes and further filtered by the virtual key's models_allow list. Requires the models:list scope.
Responses
| Field | Type | Notes |
|---|---|---|
| object | string | |
| data | array<Model> |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
Knowledge
Tenant-scoped bulk knowledge-ingest API. Requires a tenant-realm principal; requests are proxied to the tenant's resolved workspace-runtime (appliance or central).
/v1/knowledge/structureGet the tenant's knowledge scoping structureReturns the tenant's knowledge scoping catalog (companies / functions / projects) plus the caller's own memberships, assembled from the config workspace tables. Strictly tenant-scoped — staff and customer-realm principals are rejected with 403.
Responses
| Field | Type | Notes |
|---|---|---|
| companies | array<KnowledgeNamed> | |
| functions | array<KnowledgeNamed> | |
| projects | array<KnowledgeNamed> | |
| me | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
/v1/knowledge/bulk/sessionOpen a bulk knowledge-ingest sessionOpens (or resumes, by idempotent session_key) a bulk ingest session on the tenant's resolved workspace-runtime. The gateway reverse-proxies the request to the appliance or central runtime — the same routing decision the memory enricher makes.
Request body (required) · application/json
| Field | Type | Notes |
|---|---|---|
| session_key* | string | Caller-chosen idempotency key — reopening with the same key resumes the session. |
| source_name | string | |
| scope | string | Knowledge scope (personal / function / project / company). |
| scope_targets | array<string> | |
| tags | array<string> | |
| embed_model | string | |
| embed_dim | integer | |
| file_count | integer | |
| total_bytes | integer |
Responses
| Field | Type | Notes |
|---|---|---|
| session_id | string | |
| source_id | string | |
| accepted_batches | integer | |
| next_seq | integer | |
| status | string |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
/v1/knowledge/bulk/pointsUpload a batch of pre-embedded pointsUploads one batch of pre-embedded vector points into an open session. Batches carry a monotonically increasing batch_seq for resumability; point batches can be a few MB (forwarding timeout ~120s).
Request body (required) · application/json
| Field | Type | Notes |
|---|---|---|
| session_id* | string | |
| batch_seq* | integer | |
| points* | array<BulkPoint> |
Responses
| Field | Type | Notes |
|---|---|---|
| accepted | integer | |
| next_seq | integer |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
/v1/knowledge/bulk/commitCommit a bulk knowledge-ingest sessionFinalises an open session, making its points visible to retrieval.
Request body (required) · application/json
| Field | Type | Notes |
|---|---|---|
| session_id* | string | |
| total_chunks | integer | |
| total_files | integer |
Responses
| Field | Type | Notes |
|---|---|---|
| source_id | string | |
| status | string | |
| chunks | integer | |
| files | integer |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
/v1/knowledge/bulk/session/{session_id}Get bulk session statusReturns the status of an ingest session — used to resume an interrupted upload (next_seq) or confirm a commit.
Parameters
| Name | In | Type | Required |
|---|---|---|---|
| session_id | path | string | yes |
Responses
| Field | Type | Notes |
|---|---|---|
| status | string | |
| next_seq | integer | |
| accepted_chunks | integer |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
| Field | Type | Notes |
|---|---|---|
| error | object |
Health
Liveness and readiness probes (unauthenticated).
/v1/healthLiveness probeReturns 200 if the gateway process is running.
Responses
| Field | Type | Notes |
|---|---|---|
| status* | string |
/v1/healthLiveness probe (HEAD)HEAD variant of the liveness probe for load balancers.
Responses
/v1/readyzReadiness probeChecks downstream dependencies (Postgres, OPA). Returns 200 when all are healthy, 503 when any are degraded. Component names are omitted from the response to avoid leaking infrastructure topology.
Responses
| Field | Type | Notes |
|---|---|---|
| status* | string | · one of: ok |
| Field | Type | Notes |
|---|---|---|
| status* | string | · one of: degraded |
Control
Admin control surface. Authenticated by a shared bearer token (not a virtual key). Config-service proxies these routes at /v1/platform/gateway/* for portal access.
/control/v1/keys/invalidateInvalidate a cached virtual keyFlushes a virtual key from the gateway's in-memory VK cache, by raw bearer or by key hash. Called by config-service after a key is revoked or updated so the change takes effect immediately.
Request body (required) · application/json
| Field | Type | Notes |
|---|---|---|
| bearer | string | The raw vk_... bearer to invalidate. |
| key_hash | string | SHA-256 key hash to invalidate. |
Responses
| Field | Type | Notes |
|---|---|---|
| status | string | · one of: invalidated |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
/control/v1/routes/reloadReload the model routing tableRe-reads the model routing table from the database. Returns status "noop" when the gateway loaded static routes at boot and has nothing to reload.
Responses
| Field | Type | Notes |
|---|---|---|
| status | string | · one of: reloaded, noop |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
/control/v1/breakersCircuit breaker snapshotReturns the current state of all provider circuit breakers.
Responses
| Field | Type | Notes |
|---|---|---|
| breakers | array<object> |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
/control/v1/breakers/resetReset circuit breakersResets a single provider's breaker (body {"provider": "..."}) or all breakers (empty body).
Request body (optional) · application/json
| Field | Type | Notes |
|---|---|---|
| provider | string | Provider whose breaker to reset. Omit to reset all. |
Responses
| Field | Type | Notes |
|---|---|---|
| status | string | · one of: reset |
| provider | string | |
| count | integer |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
/control/v1/statsLifetime cache/breaker statsProcess-lifetime snapshot assembled only from in-process state: breaker states, cache hit/miss counters, and optimization counters. Request/error totals live in Prometheus, not here.
Responses
| Field | Type | Notes |
|---|---|---|
| window | string | · one of: lifetime |
| providers | array<object> | |
| breakers | array<object> | |
| cache | object | |
| totals | object | |
| optimization | object |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
/control/v1/configSanitized runtime configReturns a sanitized snapshot of the gateway boot configuration — enabled providers and endpoints, live hot-sync flag values. API keys, DB credentials, and other secrets are stripped.
Responses
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
/control/v1/memory/statsMemory enricher statusReturns the memory subsystem mode (disabled / local / remote / per_tenant) and per-layer status (working / semantic / episodic).
Responses
| Field | Type | Notes |
|---|---|---|
| mode | string | |
| endpoint | string | |
| layers | object |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
/control/v1/routing/statsMulti-deployment routing statsPer-deployment in-flight counts, latency EWMA, totals, and deployment breaker states for multi-deployment routing.
Responses
| Field | Type | Notes |
|---|---|---|
| deployments | array<object> | |
| breakers | array<object> |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
/control/v1/models/probeProbe an upstream model endpointRuns the wire-format + capability auto-detect flow against an upstream endpoint and returns what the operator should store in config.model_routes. 30s timeout.
Request body (required) · application/json
| Field | Type | Notes |
|---|---|---|
| endpoint* | string | |
| api_key | string | |
| api_key_header | string | |
| candidate_model* | string | |
| api_version | string |
Responses
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |
| Field | Type | Notes |
|---|---|---|
| error | string | Machine-readable error code. |
| message | string |