Use your central agent URL
A connected gateway can take requests from anywhere through your agent's published HTTPS URL, even on a laptop behind a router. The gateway keeps an outbound connection open to Verdictan, called the relay, and requests to the agent URL arrive over it. You do not open or forward an inbound port. The gateway must continue to run.
Before you start
- Finish the quickstart, so that you have an agent, a connected gateway, and a configured model.
- Keep the gateway running with its gateway token in
VERDICTAN_API_TOKEN. - Have the API token that your application sends. It is different from the gateway token.
Select the correct address
| Address | Use it for |
|---|---|
| The published agent URL, copied from the Console | Requests from any machine, through Verdictan to the connected gateway |
http://127.0.0.1:41002 | Requests from the gateway's own machine, straight to its local listener |
127.0.0.1 always means the machine sending the request, so it never reaches your laptop from another computer.
Send a request through the relay
Use the same agent, gateway, model, and API token as your finished quickstart.
-
In the Console, open Agents, open your agent, and select the hostname button to copy its published hostname.
-
In a second terminal, set:
export VERDICTAN_AGENT_URL='https://YOUR_PUBLISHED_HOSTNAME' export VERDICTAN_CLIENT_TOKEN='YOUR_APPLICATION_TOKEN' export VERDICTAN_MODEL='YOUR_CONFIGURED_MODEL'Leave
/v1off the agent URL. -
Send a request:
curl --fail-with-body -sS "$VERDICTAN_AGENT_URL/v1/chat/completions" \ -H "Authorization: Bearer $VERDICTAN_CLIENT_TOKEN" \ -H 'Content-Type: application/json' \ -d @- <<JSON { "model": "$VERDICTAN_MODEL", "messages": [{"role": "user", "content": "Say hello in one sentence."}], "stream": false } JSON
The reply is in choices[0].message.content, and its decision and usage appear in the Console. Relay requests get the same policies and application-token checks as local ones. A recent gateway heartbeat does not prove that public requests operate. This request proves it.
Add -N to curl and set "stream": true. Chat Completions streaming sends data: events and ends with data: [DONE]. Output policies can hold the full response before the first event. A passthrough-compatible chain sends tokens when they arrive. See Streaming and SSE.
Connection requirements
The relay starts on its own when the connected gateway has:
| Variable | Meaning |
|---|---|
VERDICTAN_API_URL | The control-plane endpoint |
VERDICTAN_API_TOKEN | This gateway token |
VERDICTAN_RUNTIME_REGISTRATION_ID | Its runtime registration ID |
The Console's setup command provides all three. The registration ID can also come from --runtime-registration-id, or from a registration restored at startup.
Allow outbound HTTPS and secure WebSocket traffic on port 443 to the API and relay hosts. The relay forwards each request to the gateway's local port, usually 41002.
Relay URL
The gateway selects the relay origin in this sequence:
VERDICTAN_RELAY_URL, when you set it.- The
relay_urlvalue that the API sends in the startup configuration pull. The API sends the public relay origin of its region, for examplehttps://relay.eu.verdictan.com. - A host that the gateway makes from
VERDICTAN_API_URL. A leadingapi.changes torelay.. A host withoutapi.stays the same.
The gateway changes https:// to wss:// and http:// to ws://. Then it adds /v1/gateway/relay. If the API does not send relay_url, or if the startup pull fails, the gateway uses the URL from step 3.
| API URL | Relay URL from step 3 |
|---|---|
https://api.eu.verdictan.com | wss://relay.eu.verdictan.com/v1/gateway/relay |
https://api.us.verdictan.com | wss://relay.us.verdictan.com/v1/gateway/relay |
Usually, you do not set VERDICTAN_RELAY_URL. If you set it, include the scheme, for example https://relay.internal:9443. A value without a scheme connects over unencrypted ws://.
The gateway authenticates with its gateway token and registers its runtime ID. After the API acknowledges the registration, the gateway sends incoming requests to its local listener. It sends the responses back over the same connection.
| Behavior | Timing |
|---|---|
| Reconnect after a registered connection closes | 1 second |
| Retry before registration completes | Increasing, up to 30 seconds |
| Ping | Every 20 seconds |
| Reconnect with no WebSocket message | After 45 seconds |
| Timeout for each relayed local request | 30 seconds |
Relay protocol versions
The gateway offers relay protocol v1 and v2 when it registers. It uses v2 when the API selects v2. An older API keeps the session on v1, and v1 operates as before.
On protocol v2:
- Repeated response headers, for example two
Set-Cookielines, go to the caller. - Request and response bodies are byte-exact. The bodies stream within a credit window.
- When a caller disconnects or times out, the gateway cancels the local request. This also stops the upstream provider call.
- When the relay connection closes, the gateway stops all local requests that are in flight.
- A failed request ends with a terminal error that has one of these codes.
| Code | Meaning |
|---|---|
relay_local_gateway_error | The local gateway request failed. |
relay_local_gateway_timeout | The local gateway did not reply in 30 seconds. |
relay_local_gateway_stream_error | The local streamed response failed after it started. |
relay_gateway_capacity_exceeded | The session has the maximum number of relayed requests in flight. |
relay_request_body_too_large | The request body is larger than 16 MiB. |
If a terminal error arrives before the response starts, the API returns the code in error.details.gateway_error_code. The API returns 503 for relay_gateway_capacity_exceeded, 504 for relay_local_gateway_timeout, and 502 for the other codes.
Use these variables to change the relay settings:
| Variable | Default | Meaning |
|---|---|---|
VERDICTAN_RELAY_MAX_PROTOCOL_VERSION | 2 | The highest protocol version that the gateway offers. Set 1 to stay on protocol v1. |
VERDICTAN_RELAY_MAX_CONCURRENT_REQUESTS | 128 | The maximum number of relayed requests in flight for each v2 session. |
If a value is not valid, the gateway logs relay client: ignoring invalid relay setting, using the default and uses the default.
Management over the relay
The control plane can inspect, reload, revert, and deploy to the gateway over the relay session. It uses the management credential of the gateway. If a relayed request has the x-verdictan-management-credential header with an incorrect value, the gateway returns 401.
Check the connection
| Check | What it tells you |
|---|---|
| The gateway's heartbeat in the Console | The runtime recently reached the control plane |
relay client: registered, listening for requests in the gateway log | The relay registered at that moment |
| A request through the published URL | The public route reaches the gateway and returns a result |
The Console has no relay status field, and verdictan gateway status reports only the local service, not the public route.
If the request fails
| Symptom | What to check |
|---|---|
| No published hostname | Link a gateway to the agent and deploy its configuration. |
| The relay keeps failing to connect | VERDICTAN_API_URL (or VERDICTAN_RELAY_URL), the relay URL sequence, DNS, and outbound HTTPS and WSS access to the relay host |
| Registration fails | The runtime registration ID, and the gateway token's permissions, expiry, and revocation |
| Local requests work, public ones fail | The agent's published binding, and relay registration lines in the gateway log |
| Public requests are slow or time out | Provider response time, network timing, and the 30-second relay request timeout |
Public requests return 503 with relay.gateway_capacity_exceeded or relay.capacity_exceeded | Too many requests are in flight for this gateway (limit 128) or for the regional relay (limit 2048). Retry after the Retry-After delay. |
Public requests return relay.gateway_error with gateway_error_code in error.details | The gateway sent a protocol v2 terminal error. Examine the code and the relay client: lines in the gateway log. |
Next steps
- verdictan gateway run: configure the connected runtime.
- verdictan gateway: run the gateway as a service.
- Investigate a blocked request: read a policy decision once requests get through.