api reference

Every endpoint, spelled out.

The developer reference for wiring the relay into your own code: request and response parameters, response shapes, and a copy-paste example for every surface. One relay key authenticates them all — and since the relay is a transparent proxy, every upstream parameter passes through untouched (the tables cover the load-bearing ones).

conventions · true everywhere
Base URLhttps://defai.gtio.work/v1 (OpenAI surfaces) · https://defai.gtio.work (Anthropic Messages) · https://defai.gtio.work/vertex-ai (Google Vertex)
AuthAuthorization: Bearer sk-relay-… on every request — one key spends one balance across all surfaces.
ModelsAddressed as provider/model (e.g. openai/gpt-5.5). Pull the live catalog from GET /v1/models.
ErrorsJSON envelope { error: { message, type, request_id } }; branch on status — 401 key · 402 balance · 404 model · 429 rate · 502 upstream.
POST/v1/chat/completionsOpenAI

Chat Completions

The OpenAI Chat Completions API — the default surface for text, vision, and tool use. Address any model as provider/model.

requesttypedescription
model
required
stringe.g. openai/gpt-5.5, anthropic/claude-opus-4.8.
messages
required
arrayConversation as [{role, content}]; role is system | user | assistant | tool. content may be a string or content parts (text/image).
stream
optional
booleanStream Server-Sent Events with token deltas. Default false.
max_completion_tokens
optional
integerCap on generated tokens (legacy alias: max_tokens).
temperature
optional
number0–2. Sampling temperature.
top_p
optional
number0–1. Nucleus sampling.
reasoning_effort
optional
stringnone | minimal | low | medium | high | xhigh — thinking depth (the supported set is model-dependent).
tools / tool_choice
optional
array / stringFunction/tool definitions and selection.
response_format
optional
object{ "type": "json_object" | "json_schema", … } for structured output.
stop, n, seed, frequency_penalty, presence_penalty
optional
mixedStandard OpenAI sampling controls.
responsetypedescription
id
optional
stringCompletion id.
choices[].message.content
optional
stringThe assistant's reply.
choices[].finish_reason
optional
stringstop | length | tool_calls | …
usage
optional
objectprompt_tokens, completion_tokens, total_tokens; prompt_tokens_details.cached_tokens and completion_tokens_details.reasoning_tokens when present.
request
curl https://defai.gtio.work/v1/chat/completions \
  -H "Authorization: Bearer sk-relay-…" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.5",
    "messages": [{"role": "user", "content": "Settle this."}],
    "stream": false
  }'
response
{
  "id": "chatcmpl-…",
  "choices": [{"index": 0, "message": {"role": "assistant", "content": ""}, "finish_reason": "stop"}],
  "usage": {"prompt_tokens": 7, "completion_tokens": 42, "total_tokens": 49,
            "prompt_tokens_details": {"cached_tokens": 0}}
}
POST/v1/messagesAnthropic

Anthropic Messages

The Anthropic Messages API — what Claude Code speaks. The relay injects anthropic-version (forward your own to override) and passes anthropic-beta opt-ins through.

headertypedescription
anthropic-version
optional
header2023-06-01 (defaulted by the relay if omitted)
anthropic-beta
optional
headeroptional opt-ins, e.g. extended prompt caching
requesttypedescription
model
required
stringe.g. anthropic/claude-opus-4.8.
max_tokens
required
integerRequired by Anthropic — max tokens to generate.
messages
required
array[{role, content}]; role is user | assistant. content is a string or content blocks (text/image).
system
optional
string | arraySystem prompt. Add cache_control on a block to cache it.
temperature, top_p, top_k
optional
numberSampling controls.
stream
optional
booleanStream SSE (message_start / content_block_delta / message_delta).
stop_sequences, tools
optional
arrayStop strings and tool definitions.
responsetypedescription
content[].text
optional
stringGenerated text blocks.
stop_reason
optional
stringend_turn | max_tokens | stop_sequence | tool_use.
usage
optional
objectinput_tokens, output_tokens, cache_read_input_tokens, cache_creation_input_tokens (5-min / 1-h).
request
curl https://defai.gtio.work/v1/messages \
  -H "Authorization: Bearer sk-relay-…" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-opus-4.8",
    "max_tokens": 256,
    "messages": [{"role": "user", "content": "Settle this."}]
  }'
response
{
  "type": "message", "role": "assistant",
  "content": [{"type": "text", "text": ""}],
  "stop_reason": "end_turn",
  "usage": {"input_tokens": 9, "output_tokens": 42,
            "cache_read_input_tokens": 0, "cache_creation_input_tokens": 0}
}
POST/v1/responsesOpenAI

Responses API

The OpenAI Responses API — the surface newer Codex uses. When streaming, usage arrives in the terminal response.completed frame.

requesttypedescription
model
required
stringe.g. openai/gpt-5.5.
input
required
string | arrayA prompt string, or structured input items.
max_output_tokens
optional
integerCap on output tokens.
instructions
optional
stringSystem-level instructions.
reasoning
optional
object{ "effort": "low" | "medium" | "high" }.
temperature, top_p, stream, tools
optional
mixedSampling, streaming, and tools.
responsetypedescription
output[].content[].text
optional
stringOutput text items.
status
optional
stringcompleted | incomplete | …
usage
optional
objectinput_tokens, output_tokens, total_tokens; output_tokens_details.reasoning_tokens.
request
curl https://defai.gtio.work/v1/responses \
  -H "Authorization: Bearer sk-relay-…" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-5.5", "input": "Settle this.", "max_output_tokens": 256}'
response
{
  "object": "response", "status": "completed",
  "output": [{"type": "message", "content": [{"type": "output_text", "text": ""}]}],
  "usage": {"input_tokens": 8, "output_tokens": 24, "total_tokens": 32}
}
POST/v1/embeddingsOpenAI

Embeddings

Vector embeddings for text. Returns a float array per input.

requesttypedescription
model
required
stringe.g. openai/text-embedding-3-small.
input
required
string | arrayOne string or an array of strings to embed.
dimensions
optional
integerOptional output dimension (model-dependent).
encoding_format
optional
stringfloat (default) | base64.
responsetypedescription
data[].embedding
optional
number[]The embedding vector.
usage
optional
objectprompt_tokens, total_tokens.
request
curl https://defai.gtio.work/v1/embeddings \
  -H "Authorization: Bearer sk-relay-…" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/text-embedding-3-small", "input": "hello world"}'
response
{
  "data": [{"index": 0, "embedding": [0.0021, -0.013, ]}],
  "usage": {"prompt_tokens": 2, "total_tokens": 2}
}
POST/v1/images/generationsOpenAI

Image Generation

OpenAI-compatible text-to-image for gpt-image models. Returns base64 PNGs. (Imagen / Gemini image models use the Vertex surface below.)

requesttypedescription
model
required
stringAn OpenAI image model, e.g. openai/gpt-image-2.
prompt
required
stringWhat to draw.
n
optional
integerNumber of images (default 1).
size
optional
string1024x1024 | 1536x1024 | 1024x1536 | auto.
quality
optional
stringlow | medium | high | auto.
responsetypedescription
data[].b64_json
optional
stringBase64-encoded PNG.
usage
optional
objectinput_tokens / output_tokens with image/text token details.
request
curl https://defai.gtio.work/v1/images/generations \
  -H "Authorization: Bearer sk-relay-…" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-image-2", "prompt": "an isometric neon terminal", "size": "1024x1024"}'
response
{ "data": [{"b64_json": "iVBORw0KG…"}],
  "usage": {"input_tokens": 13, "output_tokens": 196,
            "output_tokens_details": {"image_tokens": 196}} }
POST/v1/images/editsOpenAI

Image Editing (image-to-image)

Edit or extend an image from a reference (and optional mask). multipart/form-data, not JSON.

headertypedescription
Content-Type
optional
headermultipart/form-data
requesttypedescription
model
required
form fieldAn OpenAI image model, e.g. openai/gpt-image-2.
image
required
fileThe source image (PNG).
prompt
required
form fieldHow to edit it.
mask
optional
fileOptional transparency mask for local edits.
n, size
optional
form fieldCount and output size.
responsetypedescription
data[].b64_json
optional
stringBase64 PNG of the edited image.
request
curl https://defai.gtio.work/v1/images/edits \
  -H "Authorization: Bearer sk-relay-…" \
  -F model="openai/gpt-image-2" \
  -F image="@input.png" \
  -F prompt="tint it green"
response
{ "data": [{"b64_json": "iVBORw0KG…"}],
  "usage": {"input_tokens": 1035, "input_tokens_details": {"image_tokens": 1024, "text_tokens": 11},
            "output_tokens": 229, "output_tokens_details": {"image_tokens": 229}} }
GET/v1/modelsOpenAI

List Models

The full callable catalog, with modality and the surfaces (suitable_api) each model accepts.

responsetypedescription
data[].id
optional
stringprovider/model identifier.
data[].input_modalities / output_modalities
optional
string[]text, image, video, audio, file, embeddings.
data[].suitable_api
optional
string[]chat.completions, messages, responses, images, imagen, gemini, veo, embeddings.
data[].billing
optional
stringtoken | image | video — how it's metered.
request
curl https://defai.gtio.work/v1/models -H "Authorization: Bearer sk-relay-…"
response
{ "object": "list", "data": [
  {"id": "openai/gpt-5.5", "output_modalities": ["text"],
   "suitable_api": ["chat.completions","messages","responses"], "billing": "token"}
]}
POST/vertex-ai/v1/publishers/{publisher}/models/{model}:{method}Google Vertex

Google GenAI / Vertex — image & video

A passthrough to the Google GenAI surface for Imagen, Gemini image, and Veo video. Point the google-genai SDK (vertex mode) at https://defai.gtio.work/vertex-ai with your relay key; it builds these paths for you. The :method tail selects the operation.

method (:tail)typedescription
:predict
optional
ImagenPer-image generation. Body { "instances": [{"prompt": "…"}], "parameters": {"sampleCount": 1} } → { "predictions": [{"bytesBase64Encoded" | "gcsUri"}] }.
:generateContent
optional
GeminiImage (and text). Body { "contents": [...], "generationConfig": {"responseModalities": ["TEXT","IMAGE"]} } → candidates[].content.parts[].inlineData + usageMetadata.
:predictLongRunning
optional
Veo (video)Async video. Body { "instances": [{"prompt": "…"}], "parameters": {"durationSeconds": 8, "resolution": "720p"} } → an operation name; poll :fetchPredictOperation until done, then read response.videos[].bytesBase64Encoded.
responsetypedescription
predictions[] / candidates[] / operation
optional
variesBy method, as above. Video is retrieved via the operation poll.
python (google-genai)
from google import genai
from google.genai import types

client = genai.Client(
    vertexai=True, api_key="sk-relay-…",
    http_options=types.HttpOptions(base_url="https://defai.gtio.work/vertex-ai", api_version="v1"),
)
# image (imagen)
client.models.generate_images(model="qwen/qwen-image-2.0", prompt="a koi pond")
# video (veo)  async: submit, then poll
op = client.models.generate_videos(
    model="google/veo-3.1-generate-001", prompt="a koi pond",
    config=types.GenerateVideosConfig(duration_seconds=8, resolution="720p"))
while not op.done:
    op = client.operations.get(op)
Mint a key, make the call.

One endpoint, every model and modality. Rates on the pricing page.