taskq.xyz / docs / relay

Synchronous AI calls. Policy first. Proof always.

Relay is TaskQ's low-latency execution plane for API-shaped work: messages, chat completions, streaming, model listing, and token counting. It keeps the provider wire shape familiar while the Gateway handles auth, policy, placement, custody, metering, and HashIQ proof.

01 · send a request

Send a Messages request.

Use Relay when the customer expects a synchronous response: chat UX, API completions, model listing, token counting, and streaming. The request still carries TaskQ auth, credential handle, and optional placement policy.

terminal — relay messagesPOST /v1/messages
curl https://api.taskq.xyz/v1/messages \
  -H "authorization: Bearer $TASKQ_API_KEY" \
  -H "x-taskq-credential: cred_prod_anthropic_ca" \
  -H "x-taskq-policy: must_run_in=CA;key_custody=pinned,enclave" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4-5",
    "max_tokens": 800,
    "messages": [{"role":"user","content":"Summarize this report."}]
  }' 
02 · proof headers

Read proof headers from every response.

Relay preserves the expected response shape, but TaskQ adds proof headers so the customer can retrieve the signed chain record for that call.

response headersproof surface
HTTP/2 200
x-taskq-request-id: req_01J...
x-taskq-chain-key: sha256:...
x-taskq-placement-proof: proof_...
x-taskq-worker-ref: worker_blind:...
TASKQ RELAY RECEIPTVERIFIED
planerelay
credentialsha256:...
custodypinned
policyCA / no US
fallbacknone
✓ synchronous call closed with proof
03 · endpoints

Relay endpoints.

Relay supports provider-compatible API surfaces while keeping provider-specific behavior behind adapters.

MethodEndpointPurpose
POST/v1/messagesAnthropic-shaped synchronous messages, including streaming when enabled.
POST/v1/chat/completionsOpenAI-compatible chat surface for tools and clients expecting that shape.
GET/v1/modelsModel listing filtered by provider, credential, policy, and available adapters.
POST/v1/messages/count_tokensToken counting before execution for supported providers.
SSEstreamingPreserves upstream stream semantics while TaskQ closes accounting at completion.
GET/v1/chain/{request_id}Retrieve the signed proof record for a completed Relay call.
04 · streaming

Streaming rules.

Streaming responses keep provider-compatible byte flow. TaskQ opens the chain entry before the first upstream byte and closes it after the terminal usage event. Relay may retry only before provider side effect or before the first upstream byte. Once bytes flow, there is no blind retry.

stream request — SSE
curl https://api.taskq.xyz/v1/messages \
  -H "authorization: Bearer $TASKQ_API_KEY" \
  -H "x-taskq-credential: cred_prod_anthropic_ca" \
  -d '{"model":"claude-sonnet-4-5","stream":true,"messages":[{"role":"user","content":"Draft the patch notes."}]}' 
05 · custody rule

Relay custody is restricted by default.

Synchronous Relay traffic does not decrypt customer credentials on plain leased BYOW workers by default. Relay is eligible for pinned, enclave, and customer-owned custody classes.

Eligible — pinned / enclave / customer-owned

Credential unwrap happens only on custody classes approved by customer and credential policy.

Excluded by default — plain leased workers

Leased BYOW capacity is queue-eligible unless confidential custody or explicit customer policy allows otherwise.

06 · failure semantics

Relay failures happen before execution when possible.

Policy, credential, custody, and placement failures create clear errors and may create proof entries showing prevention.

401
AUTH_INVALID

Bad or expired TaskQ bearer. No request executes.

412
CREDENTIAL_MISSING

No usable customer credential handle was provided.

409
NO_COMPLIANT_CAPACITY

No pinned, enclave, or customer-owned Relay worker satisfies policy.

503
CAPACITY_CONTENTION

A compliant worker existed but lease acquisition failed after retries.

Relay versus Queue

Use Relay when the response is the product.

Relay is for synchronous API work. Queue is for jobs that produce artifacts, patches, reports, or long-running deliverables. Both share Gateway auth, policy, placement, HashIQ proof, and settlement.

Next doc
Queue — long-running agentic jobs with sealed artifacts
→