How it works
- Submit. The gateway checks that
modelexists in the configured catalog and that your team may use it, then stores the job and returns202. - Run. A worker claims the job and replays it through the normal inference pipeline as the submitting key’s team — policies, rate limits, budgets, firewall, PII redaction, guardrails, cache, metering and audit all apply.
- Collect. Poll the job, or let the gateway POST the result to your
webhook_url.
Configuration structure
Self-hosted installs configure the worker pool and queue ingateway.yaml:
Key fields
async.workers: Number of concurrent job runners on each gateway replica. Unset or0means 2.async.webhook_signing_secret: When set, every webhook carries anX-ManyLayers-Signatureheader.queue.backend: How workers learn about new jobs.dbneeds no extra infrastructure;kafkasuits multi-replica deployments.
Submit a job
Endpoints:POST /v1/async/chat/completions and POST /v1/async/completions. The body is a normal chat or text completion, plus an optional webhook_url.
202 Accepted):
webhook_url must be an absolute http or https URL (otherwise 400 bad_webhook_url); it is removed before the request reaches the provider. stream is forced to false. The body is limited to the server’s maximum request size (413 body_too_large).
Poll for the result
GET /v1/async/jobs/{id} returns the job. You can only read jobs that belong to your team; anything else is 404 job_not_found.
status moves from queued to running to succeeded or failed. response_body is the gateway’s answer as a JSON string — parse it again to get the completion. A job fails when the replayed request returns a non-2xx status — a policy refusal, for example; response_status and response_body hold the gateway’s error — or when its key was disabled or deleted after submission, in which case error says so.
Webhook delivery
When a job finishes, the gateway POSTs this body towebhook_url:
response is the completion (or the gateway’s error) as a JSON object; if a failed job’s body isn’t JSON, an error string is sent instead. Any 2xx reply marks the webhook delivered. Otherwise the gateway retries up to 3 attempts in total, waiting 1 s then 2 s, with a 10 s timeout per attempt.
Verify the signature
Withasync.webhook_signing_secret set, the header is X-ManyLayers-Signature: sha256=<hex>, where <hex> is the HMAC-SHA256 of the raw request body keyed with the secret.
Behaviour notes
Only the body is stored. Request headers such as
X-ManyLayers-Config, X-ManyLayers-Metadata or X-ManyLayers-Guardrails aren’t replayed; your team’s default routing config and your organization’s guardrail rules still apply.The model must exist in
gateway.yaml. Models from console-registered workspace providers and virtual models are refused at submit time with 404 model_not_found.Next steps
Endpoints
Every path the gateway serves.
Policies
Limits and budgets applied when jobs run.
Making Requests
The synchronous equivalent.