Aller au contenu principal
Operayde
Réserver un briefing dirigeants
/
API reference

Operayde Gateway API

OpenAPI 3.1.0 · v1.1.0

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 URLEnvironment
https://gw.operayde.comProduction central gateway (Apache proxy to :8095)

Inference

Chat completion, Anthropic Messages, and embedding endpoints.

POST/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

ChatCompletionRequest
FieldTypeNotes
model*stringThe friendly model name as configured in tenant routes.
messages*array<Message>
streambooleanIf true, partial message deltas are sent as SSE events.
temperaturenumber (double)
top_pnumber (double)
max_tokensinteger
stoparray<string>
toolsarray<Tool>
tool_choiceanyControls which tool is called by the model.
userstringEnd-user identifier for abuse monitoring.

Responses

200Chat completion response. When stream=false, returns a JSON object. When stream=true, returns an SSE stream of chunks.
ChatCompletionResponse
FieldTypeNotes
idstring
objectstring
createdinteger (int64)
modelstring
choicesarray<object>
usageUsage
400Invalid request (missing or malformed fields).
ErrorResponse
FieldTypeNotes
errorobject
401Authentication required or key invalid/revoked.
ErrorResponse
FieldTypeNotes
errorobject
402Tenant spend cap reached — prepaid wallet depleted or postpaid hard limit hit.
ErrorResponse
FieldTypeNotes
errorobject
403Request denied. Possible reasons: model not allowed by virtual key, scope not granted, OPA policy denied, residency constraint.
ErrorResponse
FieldTypeNotes
errorobject
422Response blocked by egress safety guardrails.
ErrorResponse
FieldTypeNotes
errorobject
429Virtual-key rate limit exceeded (RPM or TPD). Retry-After and X-RateLimit-* headers are set.
ErrorResponse
FieldTypeNotes
errorobject
502Upstream provider is unavailable.
ErrorResponse
FieldTypeNotes
errorobject
503Policy decision service is unavailable.
ErrorResponse
FieldTypeNotes
errorobject
POST/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

AnthropicMessagesRequest
FieldTypeNotes
model*string
max_tokens*integer
systemanySystem prompt — string or array of content blocks.
messages*array<AnthropicMessage>
streamboolean
temperaturenumber (double)
top_pnumber (double)
stop_sequencesarray<string>
toolsarray<AnthropicTool>
tool_choiceanyAnthropic tool_choice object.
metadataobject
thinkinganyExtended-thinking configuration (Anthropic-native).

Responses

200Anthropic-shaped message response, or an SSE stream when stream=true.
AnthropicMessagesResponse
FieldTypeNotes
idstring
typestring
rolestring
modelstring
contentarray<object>
stop_reasonstring
usageobject
400Invalid request (missing or malformed fields).
ErrorResponse
FieldTypeNotes
errorobject
401Authentication required or key invalid/revoked.
ErrorResponse
FieldTypeNotes
errorobject
402Tenant spend cap reached — prepaid wallet depleted or postpaid hard limit hit.
ErrorResponse
FieldTypeNotes
errorobject
403Request denied. Possible reasons: model not allowed by virtual key, scope not granted, OPA policy denied, residency constraint.
ErrorResponse
FieldTypeNotes
errorobject
422Response blocked by egress safety guardrails.
ErrorResponse
FieldTypeNotes
errorobject
429Virtual-key rate limit exceeded (RPM or TPD). Retry-After and X-RateLimit-* headers are set.
ErrorResponse
FieldTypeNotes
errorobject
502Upstream provider is unavailable.
ErrorResponse
FieldTypeNotes
errorobject
503Policy decision service is unavailable.
ErrorResponse
FieldTypeNotes
errorobject
POST/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

CountTokensRequest
FieldTypeNotes
model*string
systemanySystem prompt — string or array of content blocks.
messages*array<AnthropicMessage>
toolsarray<AnthropicTool>

Responses

200Token count.
FieldTypeNotes
input_tokens*integer
400Invalid request (missing or malformed fields).
ErrorResponse
FieldTypeNotes
errorobject
401Authentication required or key invalid/revoked.
ErrorResponse
FieldTypeNotes
errorobject
403Request denied. Possible reasons: model not allowed by virtual key, scope not granted, OPA policy denied, residency constraint.
ErrorResponse
FieldTypeNotes
errorobject
429Virtual-key rate limit exceeded (RPM or TPD). Retry-After and X-RateLimit-* headers are set.
ErrorResponse
FieldTypeNotes
errorobject
POST/v1/embeddingsCreate embeddings

Creates 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

EmbeddingRequest
FieldTypeNotes
model*string
input*array<string>

Responses

200Embedding response.
EmbeddingResponse
FieldTypeNotes
objectstring
dataarray<EmbeddingItem>
modelstring
usageUsage
400Invalid request (missing or malformed fields).
ErrorResponse
FieldTypeNotes
errorobject
401Authentication required or key invalid/revoked.
ErrorResponse
FieldTypeNotes
errorobject
402Tenant spend cap reached — prepaid wallet depleted or postpaid hard limit hit.
ErrorResponse
FieldTypeNotes
errorobject
403Request denied. Possible reasons: model not allowed by virtual key, scope not granted, OPA policy denied, residency constraint.
ErrorResponse
FieldTypeNotes
errorobject
429Virtual-key rate limit exceeded (RPM or TPD). Retry-After and X-RateLimit-* headers are set.
ErrorResponse
FieldTypeNotes
errorobject
502Upstream provider is unavailable.
ErrorResponse
FieldTypeNotes
errorobject

Models

Model discovery.

GET/v1/modelsList available models

Returns 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

200List of available models.
ModelList
FieldTypeNotes
objectstring
dataarray<Model>
401Authentication required or key invalid/revoked.
ErrorResponse
FieldTypeNotes
errorobject
403Request denied. Possible reasons: model not allowed by virtual key, scope not granted, OPA policy denied, residency constraint.
ErrorResponse
FieldTypeNotes
errorobject
500Internal server error.
ErrorResponse
FieldTypeNotes
errorobject

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).

GET/v1/knowledge/structureGet the tenant's knowledge scoping structure

Returns 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

200Scoping structure and caller memberships.
KnowledgeStructure
FieldTypeNotes
companiesarray<KnowledgeNamed>
functionsarray<KnowledgeNamed>
projectsarray<KnowledgeNamed>
meobject
401Authentication required or key invalid/revoked.
ErrorResponse
FieldTypeNotes
errorobject
403Request denied. Possible reasons: model not allowed by virtual key, scope not granted, OPA policy denied, residency constraint.
ErrorResponse
FieldTypeNotes
errorobject
502Config workspace tables could not be read.
ErrorResponse
FieldTypeNotes
errorobject
POST/v1/knowledge/bulk/sessionOpen a bulk knowledge-ingest session

Opens (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

BulkSessionRequest
FieldTypeNotes
session_key*stringCaller-chosen idempotency key — reopening with the same key resumes the session.
source_namestring
scopestringKnowledge scope (personal / function / project / company).
scope_targetsarray<string>
tagsarray<string>
embed_modelstring
embed_diminteger
file_countinteger
total_bytesinteger

Responses

200Session opened or resumed.
BulkSessionResponse
FieldTypeNotes
session_idstring
source_idstring
accepted_batchesinteger
next_seqinteger
statusstring
400Invalid request (missing or malformed fields).
ErrorResponse
FieldTypeNotes
errorobject
401Authentication required or key invalid/revoked.
ErrorResponse
FieldTypeNotes
errorobject
403Request denied. Possible reasons: model not allowed by virtual key, scope not granted, OPA policy denied, residency constraint.
ErrorResponse
FieldTypeNotes
errorobject
502The tenant's workspace-runtime could not be reached.
ErrorResponse
FieldTypeNotes
errorobject
POST/v1/knowledge/bulk/pointsUpload a batch of pre-embedded points

Uploads 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

BulkPointsRequest
FieldTypeNotes
session_id*string
batch_seq*integer
points*array<BulkPoint>

Responses

200Batch accepted.
BulkPointsResponse
FieldTypeNotes
acceptedinteger
next_seqinteger
400Invalid request (missing or malformed fields).
ErrorResponse
FieldTypeNotes
errorobject
401Authentication required or key invalid/revoked.
ErrorResponse
FieldTypeNotes
errorobject
403Request denied. Possible reasons: model not allowed by virtual key, scope not granted, OPA policy denied, residency constraint.
ErrorResponse
FieldTypeNotes
errorobject
502The tenant's workspace-runtime could not be reached.
ErrorResponse
FieldTypeNotes
errorobject
POST/v1/knowledge/bulk/commitCommit a bulk knowledge-ingest session

Finalises an open session, making its points visible to retrieval.

Request body (required) · application/json

BulkCommitRequest
FieldTypeNotes
session_id*string
total_chunksinteger
total_filesinteger

Responses

200Session committed.
BulkCommitResponse
FieldTypeNotes
source_idstring
statusstring
chunksinteger
filesinteger
400Invalid request (missing or malformed fields).
ErrorResponse
FieldTypeNotes
errorobject
401Authentication required or key invalid/revoked.
ErrorResponse
FieldTypeNotes
errorobject
403Request denied. Possible reasons: model not allowed by virtual key, scope not granted, OPA policy denied, residency constraint.
ErrorResponse
FieldTypeNotes
errorobject
502The tenant's workspace-runtime could not be reached.
ErrorResponse
FieldTypeNotes
errorobject
GET/v1/knowledge/bulk/session/{session_id}Get bulk session status

Returns the status of an ingest session — used to resume an interrupted upload (next_seq) or confirm a commit.

Parameters

NameInTypeRequired
session_idpathstringyes

Responses

200Session status.
BulkSessionStatus
FieldTypeNotes
statusstring
next_seqinteger
accepted_chunksinteger
401Authentication required or key invalid/revoked.
ErrorResponse
FieldTypeNotes
errorobject
403Request denied. Possible reasons: model not allowed by virtual key, scope not granted, OPA policy denied, residency constraint.
ErrorResponse
FieldTypeNotes
errorobject
404Unknown session.
ErrorResponse
FieldTypeNotes
errorobject
502The tenant's workspace-runtime could not be reached.
ErrorResponse
FieldTypeNotes
errorobject

Health

Liveness and readiness probes (unauthenticated).

GET/v1/healthLiveness probe

Returns 200 if the gateway process is running.

Responses

200Process is alive.
FieldTypeNotes
status*string
HEAD/v1/healthLiveness probe (HEAD)

HEAD variant of the liveness probe for load balancers.

Responses

200Process is alive (no body).
GET/v1/readyzReadiness probe

Checks 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

200All dependencies are healthy.
FieldTypeNotes
status*string · one of: ok
503One or more dependencies are degraded.
FieldTypeNotes
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.

POST/control/v1/keys/invalidateInvalidate a cached virtual key

Flushes 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

FieldTypeNotes
bearerstringThe raw vk_... bearer to invalidate.
key_hashstringSHA-256 key hash to invalidate.

Responses

200Key invalidated.
FieldTypeNotes
statusstring · one of: invalidated
400Invalid control request.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
401Missing or wrong admin token — or the control surface is disabled because no token is configured.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
503The required subsystem is not configured on this gateway.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
POST/control/v1/routes/reloadReload the model routing table

Re-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

200Routes reloaded (or noop).
FieldTypeNotes
statusstring · one of: reloaded, noop
401Missing or wrong admin token — or the control surface is disabled because no token is configured.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
500Reload failed.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
GET/control/v1/breakersCircuit breaker snapshot

Returns the current state of all provider circuit breakers.

Responses

200Breaker snapshot.
FieldTypeNotes
breakersarray<object>
401Missing or wrong admin token — or the control surface is disabled because no token is configured.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
POST/control/v1/breakers/resetReset circuit breakers

Resets a single provider's breaker (body {"provider": "..."}) or all breakers (empty body).

Request body (optional) · application/json

FieldTypeNotes
providerstringProvider whose breaker to reset. Omit to reset all.

Responses

200Breakers reset.
FieldTypeNotes
statusstring · one of: reset
providerstring
countinteger
401Missing or wrong admin token — or the control surface is disabled because no token is configured.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
404Provider has no breaker state.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
503The required subsystem is not configured on this gateway.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
GET/control/v1/statsLifetime cache/breaker stats

Process-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

200Stats snapshot.
FieldTypeNotes
windowstring · one of: lifetime
providersarray<object>
breakersarray<object>
cacheobject
totalsobject
optimizationobject
401Missing or wrong admin token — or the control surface is disabled because no token is configured.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
GET/control/v1/configSanitized runtime config

Returns 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

200Sanitized config snapshot.
401Missing or wrong admin token — or the control surface is disabled because no token is configured.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
503The required subsystem is not configured on this gateway.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
GET/control/v1/memory/statsMemory enricher status

Returns the memory subsystem mode (disabled / local / remote / per_tenant) and per-layer status (working / semantic / episodic).

Responses

200Memory status.
FieldTypeNotes
modestring
endpointstring
layersobject
401Missing or wrong admin token — or the control surface is disabled because no token is configured.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
500Memory stats query failed.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
GET/control/v1/routing/statsMulti-deployment routing stats

Per-deployment in-flight counts, latency EWMA, totals, and deployment breaker states for multi-deployment routing.

Responses

200Routing stats.
FieldTypeNotes
deploymentsarray<object>
breakersarray<object>
401Missing or wrong admin token — or the control surface is disabled because no token is configured.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
POST/control/v1/models/probeProbe an upstream model endpoint

Runs 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

FieldTypeNotes
endpoint*string
api_keystring
api_key_headerstring
candidate_model*string
api_versionstring

Responses

200Probe result.
400Invalid control request.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
401Missing or wrong admin token — or the control surface is disabled because no token is configured.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
502Probe failed against the upstream endpoint.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring
503The required subsystem is not configured on this gateway.
ControlError
FieldTypeNotes
errorstringMachine-readable error code.
messagestring