developer guide

Two lines. Then ship.

If it speaks OpenAI or Anthropic, it speaks DeFAI Relay. Point an OpenAI client at https://defai.gtio.work/v1 or an Anthropic one (like Claude Code) at https://defai.gtio.work, drop in a relay key, and call any model — streaming, tools, and usage all behave the way you expect.

01 · quickstart

From wallet to first token

  • Open the console and sign in with your wallet — one signature, no gas.
  • Top up your balance in native USDC on Base.
  • Mint a relay key, set your base URL to https://defai.gtio.work/v1, and call any model.
curl https://defai.gtio.work/v1/chat/completions \
  -H "Authorization: Bearer sk-relay-…" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-opus-4.8",
    "messages": [{"role":"user","content":"Settle this."}],
    "stream": true
  }'
02 · authentication

Relay keys

The relay authenticates with a bearer key (sk-relay-…) sent as Authorization: Bearer …. Mint and revoke keys in the console; the plaintext is shown exactly once and only its hash is stored. Your wallet session is for the console only — never send it to the relay.

03 · base urls

One rule: which base URL

The whole integration hinges on the base URL your client points at.

OpenAI clientshttps://defai.gtio.work/v1 — chat/completions, responses, embeddings, images.
Anthropic clientshttps://defai.gtio.work — no /v1; the client appends /v1/messages itself. This is how Claude Code connects.
Google GenAIhttps://defai.gtio.work/vertex-ai — Imagen, Gemini image, and Veo video.

Every surface — with full request/response parameters and a copy-paste example — is in the API Reference; jump straight in:

POST/v1/chat/completionsChat — streaming, tools, vision
POST/v1/messagesAnthropic Messages — powers Claude Code
POST/v1/responsesOpenAI Responses — powers newer Codex
POST/v1/images/generationsText-to-image — returns b64 PNG
POST/v1/images/editsImage-to-image — edit / reference image
POST/v1/completionsLegacy text completion
POST/v1/embeddingsEmbeddings
GET/v1/modelsList callable models
ANY/vertex-ai/*Google GenAI — imagen, gemini-image, veo video
04 · streaming

Real token streaming

Set "stream": true and the response is Server-Sent Events, passed straight through with backpressure — tokens arrive the instant the model emits them, with no buffering at the edge. Omit it for a single JSON response.

05 · models

Addressing a model

Models are addressed as provider/model — e.g. openai/gpt-5.5, anthropic/claude-opus-4.8, google/gemini-3.5-flash. Browse the full catalog with live prices, context windows, and modalities on the pricing page, or fetch GET /v1/models at runtime.

Beyond text, the same key reaches image models (gpt-image on the OpenAI Images API; Imagen and Gemini image on Vertex) and video (Veo, Seedance). Those endpoints live in the API Reference.

06 · billing & metering

Paid per token, settled on-chain

  • Each call is metered by prompt + completion tokens and charged ceil((prompt×in + completion×out) × markup) in integer USDC base units (6 decimals). No floating-point drift, no rounding in anyone's favor.
  • A spend hold is reserved up front from your balance and reconciled to actual usage when the call settles.
  • Prompt caching is priced through. Cached input tokens bill at the model's cache-read rate — far below fresh input — and cache writes at their own rate, so a cached call costs you what it costs us, not full price.
  • A model with no published price is refused, never billed at a guess. Run out of balance and the request is rejected before it reaches the provider.
07 · sdks

Use your existing SDK

Python:

from openai import OpenAI

client = OpenAI(
    base_url="https://defai.gtio.work/v1",
    api_key="sk-relay-…",
)

stream = client.chat.completions.create(
    model="openai/gpt-5.5",
    messages=[{"role": "user", "content": "Hello"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

TypeScript / JavaScript:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://defai.gtio.work/v1",
  apiKey: "sk-relay-…",
});

const res = await client.chat.completions.create({
  model: "google/gemini-3.5-flash",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(res.choices[0].message.content);
08 · where to next

Keep going

  • API Reference — every endpoint's parameters, response shapes, copy-paste examples, the error envelope, and a one-click AI-integration prompt.
  • Integrations — no-code setups for Claude Code, Codex, OpenClaw, Kilo Code, OpenHands, Cursor and more.
  • Pricing — the live, searchable model catalog with per-token, per-image, and per-second rates.
  • FAQ — wallet login, USDC settlement, caching, and privacy.
Mint a key, point your stack.

One endpoint, every model, paid in USDC.