Skip to main content
This page creates an Agent Gateway instance on the user’s Network, issues a key, and connects an agent to it.

Prerequisites

Create the Agent Gateway

Send POST /v2/agent_gateways with the WireGuard Interface’s id:
The response returns the instance pending, with no gateway_url yet. network_id is the WireGuard Interface’s Network.

Wait for the Gateway

Poll GET /v2/agent_gateways/{id} until status is ready. The instance joins the WireGuard Interface as a peer named agw-32ce035d-3165-4031-b1a7-a7c0c259590a, which puts the interface in provisioning again. The instance is ready once the interface is provisioned and the instance answers through the tunnel. Here that took 172 seconds. gateway_url is its address on the interface:

Issue a Key

The instance refuses a request without a key. Send POST /v2/agent_gateways/{id}/keys with a name for the agent that holds it:
The response carries the key’s value in key, and no later response returns it:

Connect an Agent

An agent on Edge Compute reaches the instance through a network binding to the instance’s WireGuard Interface. In the function’s func.toml, bind the interface and set the instance’s gateway_url:
func.toml
Store the key from Issue a Key as a secret:
Workstation
The function sends a chat completion to gateway_url through the binding, with the key:
index.ts
Generate the binding’s types, and ship the function:
Workstation
Send the function a request:
Workstation
Output
The instance’s spend logs list the request under the key support-agent.

Delete the Agent Gateway

DELETE /v2/agent_gateways/{id} returns the instance deleting. The gateway stops answering at once, and seconds later GET /v2/agent_gateways/{id} returns 404.