The model-gateway is an internal HTTP service on the private Docker network — no external access. It abstracts provider selection, enforces theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/joseluis-dev/harness-ai/llms.txt
Use this file to discover all available pages before exploring further.
allow_cloud policy gate, and emits a model.call audit event for every successful inference call. The BFF and runtime workers reach this service at model-gateway:8000 over the Docker-internal network. Swagger UI, ReDoc, and the OpenAPI schema endpoint are intentionally disabled.
Pydantic Schemas
All request and response bodies use Pydantic v2 models withextra="forbid". Unknown fields are rejected at the boundary.
ProviderKind is one of "local" | "self" | "cloud" | "mock".
Provider Registry
The gateway maintains an in-memory registry of providers populated at startup. The registry is exposed onapp.state.registry so health checks and tests can inspect it without going through request handlers.
| Provider name | Kind | Always available | Requirement |
|---|---|---|---|
mock | mock | Yes | None — always registered. Returns deterministic responses. |
vllm_local | local | Only when configured | VLLM_BASE_URL environment variable must be set. Forwards requests to a locally-hosted vLLM instance. |
provider is omitted from a request body, the gateway falls back to mock. The fallback is explicit — the audit row records provider="mock" so the routing decision is always traceable.
allow_cloud Policy
The allow_cloud flag is resolved from the ALLOW_CLOUD environment variable at startup and stored on app.state.settings. It is not configurable per-request. The effective value is visible on GET /healthz.
GET /healthz
Liveness probe. No authentication or actor headers required.
Response — 200 OK
Always
"ok" when the process is alive.Always
"model-gateway".Service version string.
Sorted list of provider names currently installed in the registry (e.g.
["mock", "vllm_local"]).The effective
allow_cloud setting. Reflects the resolved policy so operators can verify configuration without reading container environment variables.Whether
VLLM_BASE_URL is configured. The URL itself is not echoed — it may carry credentials in future phases.POST /v1/chat
Runs a chat completion through the selected provider. Validates actor headers, enforces the allow_cloud policy gate, calls the provider, and emits a model.call audit event.
Required Headers
Institutional ID of the caller. Trimmed of leading/trailing whitespace; must be 1–128 characters after trimming. Missing or oversized values return
400 invalid_actor.Type of the calling principal. Must be one of
user | service | system. Missing or unrecognized values return 400 invalid_actor.Request Body
Name of the model to use. 1–128 characters. The interpretation depends on the provider (e.g.
"gpt-4o" for a cloud provider, or a locally-registered model name for vllm_local).Conversation history. At least one message is required. Each message has a
role ("system" | "user" | "assistant") and a content string (0–32,000 characters). Tool messages are not yet supported.Sampling temperature. Range
0.0–2.0. Omit to use the provider default.Maximum tokens to generate. Range
1–4096. Omit to use the provider default.Name of the provider to use (e.g.
"mock", "vllm_local"). When omitted, defaults to "mock". An unrecognized name returns 501 provider_not_registered.Example Request
Response — 200 OK
UUID4 generated per request. Correlates with the
model.call audit event’s correlation_id.Model name as reported by the provider.
The model’s text output. Up to 65,536 characters.
Input token count reported by the provider.
Output token count reported by the provider.
Wall-clock latency of the provider call in milliseconds, measured in-process.
The kind of the provider that served the request:
"local" | "self" | "cloud" | "mock".The name of the provider that served the request (e.g.
"mock", "vllm_local").Error Responses
Audit Emission
After every successful call, the gateway emits amodel.call event forwarded to POST /internal/audit/ingest on the runtime. After a failed call (non-HTTP exception), it emits model.call.failed. Both events carry actor_id, actor_type, provider_kind, provider, model, tokens_in, tokens_out, latency_ms, and correlation_id.
POST /v1/embed
Runs an embedding request through the selected provider. Uses the same actor header validation, policy gate, and audit flow as /v1/chat.
Required Headers
Same as/v1/chat: X-Harness-Actor-Id and X-Harness-Actor-Type are both required.
Request Body
Texts to embed. At least one string required, up to 128 strings per request. Batch size cap keeps the mock provider’s memory allocation bounded.
Name of the embedding model to use. 1–128 characters.
Provider name. Defaults to
"mock" when omitted.Example Request
Response — 200 OK
One float vector per input string. Vector dimension is provider-defined:
8 for mock (MOCK_EMBED_DIM=8); the upstream data[0].embedding length for vllm_local.Model name as reported by the provider.
Input token count reported by the provider.
Kind of the provider that served the request.
Name of the provider that served the request.
/v1/chat (invalid_actor, POLICY_DENIED, provider_not_registered, vllm_unavailable). The model.call audit event for embed calls records tokens_out=0 — the response is the vectors themselves, not generated text.