Skip to main content

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​

AddressUse it for
The published agent URL, copied from the ConsoleRequests from any machine, through Verdictan to the connected gateway
http://127.0.0.1:41002Requests 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.

  1. In the Console, open Agents, open your agent, and select the hostname button to copy its published hostname.

  2. 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 /v1 off the agent URL.

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

Connection requirements​

The relay starts on its own when the connected gateway has:

VariableMeaning
VERDICTAN_API_URLThe control-plane endpoint
VERDICTAN_API_TOKENThis gateway token
VERDICTAN_RUNTIME_REGISTRATION_IDIts 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:

  1. VERDICTAN_RELAY_URL, when you set it.
  2. The relay_url value that the API sends in the startup configuration pull. The API sends the public relay origin of its region, for example https://relay.eu.verdictan.com.
  3. A host that the gateway makes from VERDICTAN_API_URL. A leading api. changes to relay.. A host without api. 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 URLRelay URL from step 3
https://api.eu.verdictan.comwss://relay.eu.verdictan.com/v1/gateway/relay
https://api.us.verdictan.comwss://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://.

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-Cookie lines, 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.
CodeMeaning
relay_local_gateway_errorThe local gateway request failed.
relay_local_gateway_timeoutThe local gateway did not reply in 30 seconds.
relay_local_gateway_stream_errorThe local streamed response failed after it started.
relay_gateway_capacity_exceededThe session has the maximum number of relayed requests in flight.
relay_request_body_too_largeThe 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:

VariableDefaultMeaning
VERDICTAN_RELAY_MAX_PROTOCOL_VERSION2The highest protocol version that the gateway offers. Set 1 to stay on protocol v1.
VERDICTAN_RELAY_MAX_CONCURRENT_REQUESTS128The 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​

CheckWhat it tells you
The gateway's heartbeat in the ConsoleThe runtime recently reached the control plane
relay client: registered, listening for requests in the gateway logThe relay registered at that moment
A request through the published URLThe 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​

SymptomWhat to check
No published hostnameLink a gateway to the agent and deploy its configuration.
The relay keeps failing to connectVERDICTAN_API_URL (or VERDICTAN_RELAY_URL), the relay URL sequence, DNS, and outbound HTTPS and WSS access to the relay host
Registration failsThe runtime registration ID, and the gateway token's permissions, expiry, and revocation
Local requests work, public ones failThe agent's published binding, and relay registration lines in the gateway log
Public requests are slow or time outProvider response time, network timing, and the 30-second relay request timeout
Public requests return 503 with relay.gateway_capacity_exceeded or relay.capacity_exceededToo 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.detailsThe gateway sent a protocol v2 terminal error. Examine the code and the relay client: lines in the gateway log.

Next steps​