Client onboarding
End-to-end — top up, create an API key, and run inference.
This guide walks through using the gateway as a client: add credit with USDC or USDT (x402), create an API key (SIWE), then call the chat completion API.
What you need
- An Ethereum wallet for signing
- USDC or USDT on Base or Arbitrum (mainnet)
- The gateway base URL —
https://agent-router.gaib.ai
End-to-end flow
| Step | What happens |
|---|---|
| 1. Top up | POST /v1/topup with { "amount": <usd> }. The server responds with 402 and payment instructions. Sign and complete payment per x402, then retry. |
| 2. API key | POST /v1/auth/keys with a SIWE message and signature. Response includes a secret API key (store it safely). |
| 3. Inference | POST /v1/chat/completions with Authorization: Bearer <api_key> and a chat-style JSON body. |
Model IDs are provider-qualified: gemini/..., kimi/..., minimax/..., or bedrock/....
For copy-paste code covering all three steps, see the Quickstart.
SIWE message alignment
The SIWE message must match what the server verifies:
- domain — hostname of the gateway (e.g.
agent-router.gaib.ai) - uri — the auth endpoint (e.g.
https://agent-router.gaib.ai/v1/auth/keys) - chainId — must match the gateway's chain
If key creation fails with a 4xx, confirm you're using the same public HTTPS host the gateway presents.