Usage guide

Getting started

RelayBases provides OpenAI-, Anthropic-, and Gemini-compatible API access. This page covers purchasing API Credits, creating API keys, and configuring clients such as Claude Code and Codex CLI.

API Credits and API keys

Start with available API Credits, then create API keys for each protocol or model group. Use separate Claude, OpenAI, Gemini, or image keys when you need a fixed route; use the auto group when one key should match models across multiple available groups.

Billing unit

Ɍ represents RelayBases API Credits

Ɍ is the display unit for API Credits. After a top-up, Credits are added to your account and deducted as you use the APIs according to model prices, group multipliers, and actual usage. Ɍ is not USD or any other currency, electronic money, or cryptocurrency.

Balance and usage
Balances, model prices, and usage costs are displayed in Ɍ, for example Ɍ0.08.
What you pay
Orders are priced in USD. Checkout and payment records show the amount and currency charged.
Refunds
Eligible unused paid Credits may be returned to the original payment method under the Refund Policy. Ɍ itself cannot be transferred, traded, or withdrawn.
  1. Buy Credits. Open the Credits page, review “You pay” and “You receive,” choose an amount, then complete payment.
  2. Open API Keys. Go to the API Keys page from the console sidebar and review existing groups.
  3. Create a key. Enter a name, choose a group, and set quota or expiration. The full key is shown once.
  4. Use it in clients. Put the key in environment variables or config files, never in public repos, screenshots, or logs.

Choose an API endpoint

The standard and US direct endpoints use the same API keys, model names, account balance, and billing rules. Only the network path changes. Use the standard endpoint by default, then switch to the US direct endpoint when a long-running synchronous request encounters a Cloudflare proxy timeout.

Endpoint Base URL When to use it
Standard API https://api.relaybases.com Cloudflare-accelerated with broader network compatibility. Recommended as the default; long-running synchronous requests may be subject to proxy timeouts.
US Direct API https://us.relaybases.com Connects directly to the US origin without Cloudflare proxy timeouts. Recommended for long-running synchronous requests; it may be unreachable from some networks.
Protocol paths do not change: use the hostname as shown for the native Anthropic protocol, without /v1; append /v1 for OpenAI-compatible clients. Image and video tasks continue to use the dedicated endpoint https://image-2.relaybases.com.

The direct endpoint bypasses only the Cloudflare proxy. Client, origin, upstream-model, or network failures can still interrupt a request. Switch back to the standard endpoint if the direct endpoint is not reachable.

Automatic routing and failover

When you create or edit an API key, select the auto group. RelayBases checks the groups that the key may use, in the priority order shown in the console, and selects the first group that supports the requested model and has an available route.

  1. Open API Keys. Create a new key or edit an existing key in the console.
  2. Select auto. Choose auto under Group.
  3. Review the group order. Keeping Inherit global Auto order is recommended so the key follows the complete platform-managed order. You can also choose and reorder candidate groups for this key.
  4. Enable Cross-group retry. If a route in the selected group fails, RelayBases can continue with later groups in order.
  5. Save and call the API normally. Your Base URL, model names, and key usage do not change.
Routing behavior: if a candidate group does not support the requested model or has no available route, RelayBases checks the next group automatically. Cross-group retry controls whether it also continues after an already selected route fails during the request.
Billing: auto has no separate multiplier. Each request is charged using the multiplier of the group actually selected, the model price, and actual usage. The request can still fail if no candidate group has an available route.

Inheritance uses the complete Auto order currently maintained by the platform. A custom order is stored for that key and remains subject to the account's current group permissions. Existing keys are not changed to auto automatically.

Claude Code

Claude Code uses the native Anthropic protocol, so the endpoint does not include /v1. Create a Claude group key for this setup.

Anthropic endpoint: https://api.relaybases.com. Store the key in ANTHROPIC_AUTH_TOKEN instead of project code.

Prerequisites

Claude Code needs Node.js 18 or newer. If Node.js is already installed, you can skip straight to installing Claude Code.

Platform Recommended setup Verify
macOS Use brew update && brew install node, or install the LTS package from nodejs.org. node --version && npm --version
Windows Install Node.js LTS from nodejs.org, or use choco install nodejs / scoop install nodejs. node --version; npm --version
Linux Use NodeSource on Ubuntu / Debian, or install nodejs and npm from your package manager. node --version && npm --version

Install Claude Code

macOS Native

brew install --cask claude-code

# Or use the official install script
curl -fsSL https://claude.ai/install.sh | bash

Windows Native

# PowerShell
irm https://claude.ai/install.ps1 | iex

# CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd

Linux Native

curl -fsSL https://claude.ai/install.sh | bash

# Alpine Linux if ripgrep dependencies fail
apk add libgcc libstdc++ ripgrep
export USE_BUILTIN_RIPGREP=0

NPM fallback

npm install -g @anthropic-ai/claude-code
claude --version
claude doctor

Connect RelayBases

macOS / Linux temporary env

export ANTHROPIC_BASE_URL="https://api.relaybases.com"
export ANTHROPIC_AUTH_TOKEN="sk-relaybases-..."

claude

macOS / Linux persistent env

echo 'export ANTHROPIC_BASE_URL="https://api.relaybases.com"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="sk-relaybases-..."' >> ~/.zshrc
source ~/.zshrc

Windows PowerShell

$env:ANTHROPIC_BASE_URL = "https://api.relaybases.com"
$env:ANTHROPIC_AUTH_TOKEN = "sk-relaybases-..."

[System.Environment]::SetEnvironmentVariable(
  "ANTHROPIC_BASE_URL",
  "https://api.relaybases.com",
  [System.EnvironmentVariableTarget]::User
)
[System.Environment]::SetEnvironmentVariable(
  "ANTHROPIC_AUTH_TOKEN",
  "sk-relaybases-...",
  [System.EnvironmentVariableTarget]::User
)

~/.claude/settings.json

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.relaybases.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-relaybases-...",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}

VS Code extension

# After installing Claude Code for VS Code, create:
# macOS / Linux: ~/.claude/config.json
# Windows: C:\Users\your-name\.claude\config.json

{
  "primaryApiKey": "any-value"
}

Verify, start, update

echo $ANTHROPIC_BASE_URL
echo $ANTHROPIC_AUTH_TOKEN

cd /path/to/your/project
claude

npm install -g @anthropic-ai/claude-code

Codex CLI

Codex CLI uses an OpenAI compatible protocol, so the endpoint must include /v1. Create an OpenAI group key and load it from an environment variable.

OpenAI compatible endpoint: https://api.relaybases.com/v1. If your client has a Base URL field, include the full /v1 path.

Prerequisites

Codex CLI needs Node.js and npm. Before installing, make sure your terminal can run node and npm.

Platform Recommended setup Verify
macOS Use brew update && brew install node, or install the LTS package from nodejs.org. node --version && npm --version
Windows Install Node.js LTS, or use choco install nodejs / scoop install nodejs. node --version; npm --version
Linux Use NodeSource, your package manager, or your team's preferred Node version manager. node --version && npm --version

Install Codex CLI

Install Codex CLI

npm i -g @openai/codex

Verify installation

codex --version

cd /path/to/your/project
codex

Configure RelayBases

~/.codex/config.toml

model_provider = "rb"
model = "gpt-6.1-sol"
model_reasoning_effort = "high"
disable_response_storage = true
sandbox_mode = "workspace-write"

[features]
plan_tool = true
apply_patch_freeform = true
view_image_tool = true
web_search_request = true
unified_exec = false
streamable_shell = false
rmcp_client = true

[model_providers.rb]
name = "rb"
base_url = "https://api.relaybases.com/v1"
wire_api = "responses"
env_key = "RELAYBASES_API_KEY"
requires_openai_auth = true

[sandbox_workspace_write]
network_access = true

macOS / Linux env

export RELAYBASES_API_KEY="sk-relaybases-..."

# Persist it for future terminals
echo 'export RELAYBASES_API_KEY="sk-relaybases-..."' >> ~/.zshrc
source ~/.zshrc

Windows PowerShell

[System.Environment]::SetEnvironmentVariable(
  "RELAYBASES_API_KEY",
  "sk-relaybases-...",
  [System.EnvironmentVariableTarget]::User
)

~/.codex/auth.json

{
  "OPENAI_API_KEY": "sk-relaybases-..."
}

VS Code extension

# After installing Codex - OpenAI's coding agent,
# confirm ~/.codex/config.toml, ~/.codex/auth.json,
# and RELAYBASES_API_KEY are configured on this machine.

codex

Start and update

cd /path/to/your/project
codex

npm i -g @openai/codex

Other clients

Cursor, Cline, Chatbox, Cherry Studio, Gemini CLI, Dify, N8N, and similar tools usually need only a Base URL, model name, and API key. The endpoint changes by protocol.

Use case Base URL Key group
Claude / native Anthropic https://api.relaybases.com Claude or Anthropic related group
OpenAI compatible https://api.relaybases.com/v1 OpenAI / GPT / Codex related group
Gemini models / Gemini CLI Use the Gemini or OpenAI compatible Base URL required by your client Use an available Gemini group shown in the live model details
Image generation https://image-2.relaybases.com media group; use the synchronous image endpoints and check the live catalog for models and prices
Image and video tasks https://image-2.relaybases.com media group; use /v1/video/generations for sync video, /v1/videos for async tasks, and /v1/contents/generations/tasks for Seedance video

Image and video task API

Use an API key created in the media group and select a currently available model from the live catalog above. Images support synchronous generation and editing endpoints. Videos support synchronous generation and an asynchronous task workflow.

Purpose Method Path
Generate images synchronously POST /v1/images/generations
Edit images synchronously POST /v1/images/edits
Generate video synchronously POST /v1/video/generations
Create an async task POST /v1/videos
Query an async task GET /v1/videos/{task_id}
Download the task result GET /v1/videos/{task_id}/content
Create a Seedance video task POST /v1/contents/generations/tasks
Query a Seedance video task GET /v1/contents/generations/tasks/{task_id}

All paths use the Base URL https://image-2.relaybases.com. See the Seedance video section below for Seedance parameters and prices. The live catalog and console bill are authoritative.

Synchronous image generation

Generate synchronously

curl -sS --max-time 600 -X POST "https://image-2.relaybases.com/v1/images/generations" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "CURRENT_IMAGE_MODEL",
    "prompt": "Create a clean product poster on a white background with premium commercial photography lighting",
    "size": "1024x1024",
    "n": 1,
    "images": [
      "https://your-cdn.com/reference.jpg"
    ]
  }'

Synchronous response shape

{
  "created": 1714200180,
  "data": [
    {
      "url": "https://.../generated/image.jpg"
    }
  ]
}

Synchronous video call

Generate video synchronously

curl -sS --max-time 600 -X POST "https://image-2.relaybases.com/v1/video/generations" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "CURRENT_MEDIA_MODEL",
    "prompt": "A glass paper crane rotating on a tabletop, soft side light, macro shot",
    "duration": 4,
    "aspect_ratio": "1:1"
  }'

Synchronous video response

{
  "id": "task_xxx",
  "task_id": "task_xxx",
  "object": "video",
  "model": "CURRENT_MEDIA_MODEL",
  "status": "in_progress"
}

After the sync video endpoint returns a task object, keep using the query endpoint to obtain the final video_url. The async task endpoint is useful for background queueing or batch submission; use the live model details and console bill for pricing.

Create an async task

Async image task

curl -sS -X POST "https://image-2.relaybases.com/v1/videos" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "CURRENT_IMAGE_MODEL",
    "prompt": "Create a clean product poster on a white background with premium commercial photography lighting",
    "duration": 4,
    "resolution": "2k",
    "images": [
      "https://your-cdn.com/reference.jpg"
    ]
  }'

First/last-frame video task

curl -sS -X POST "https://image-2.relaybases.com/v1/videos" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "CURRENT_MEDIA_MODEL",
    "prompt": "Animate naturally from the first frame to the last frame with cinematic lighting and stable camera motion",
    "duration": 8,
    "aspect_ratio": "16:9",
    "images": [
      "https://your-cdn.com/first-frame.jpg",
      "https://your-cdn.com/last-frame.jpg"
    ]
  }'

Reference-media video task

curl -sS -X POST "https://image-2.relaybases.com/v1/videos" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "CURRENT_MEDIA_MODEL",
    "prompt": "High quality product commercial, smooth camera movement, premium visual style",
    "duration": 6,
    "aspect_ratio": "16:9",
    "image_url": "https://your-cdn.com/main-reference.jpg",
    "extra_images": ["https://your-cdn.com/ref-1.jpg"],
    "extra_videos": ["https://your-cdn.com/ref-video.mp4"],
    "extra_audios": ["https://your-cdn.com/ref-audio.mp3"]
  }'

Video edit

curl -sS -X POST "https://image-2.relaybases.com/v1/videos" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "CURRENT_MEDIA_MODEL",
    "prompt": "Make the reference video brighter and more cinematic while preserving the subject motion",
    "duration": 10,
    "aspect_ratio": "16:9",
    "video_url": "https://your-cdn.com/reference-video.mp4",
    "Ingredients_images": [
      "https://your-cdn.com/product.jpg"
    ]
  }'

Poll and read the result

Poll task status

curl -sS "https://image-2.relaybases.com/v1/videos/TASK_ID" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY"

Common response fields

{
  "id": "task_385412",
  "task_id": "task_385412",
  "object": "video",
  "model": "CURRENT_MEDIA_MODEL",
  "status": "completed",
  "task_status": "completed",
  "progress": 100,
  "image_url": null,
  "video_url": "https://.../generated/video.mp4",
  "url": "https://.../generated/video.mp4",
  "result_urls": ["https://.../generated/video.mp4"]
}

Download task video

curl -sS -L "https://image-2.relaybases.com/v1/videos/TASK_ID/content" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY" \
  -o generated-video.mp4

Read the content only after the task reaches completed.

The task does not immediately return media

That is expected. /v1/videos is an async task API. A successful create request returns a task_id; keep polling while the status is queued, processing, or in_progress. When it is completed, read video_url, image_url, url, or result_urls.

When should I use sync or async?

Use /v1/images/generations or /v1/images/edits for synchronous images, /v1/video/generations for synchronous video, and /v1/videos for asynchronous tasks. Select a currently available model from the live catalog above; the catalog and console bill are authoritative.

What happens on invalid input or task failure?

Supported media inputs, image counts, durations, aspect ratios, and resolutions vary by model; use the live model details as the source of truth. For rejected or failed tasks, use the console bill as authoritative. If a charge looks incorrect, keep the task_id and use the support links in the page footer to request a review.

Model or group not available

Confirm that the API key belongs to the media group and that the request URL matches the interface: sync images use /v1/images/generations, sync videos use /v1/video/generations, and async tasks use /v1/videos. Do not send these models to /v1/chat/completions or /v1/responses.

Seedance video (official task API)

Doubao Seedance 2.0, 2.0 Fast, 2.0 Mini, and 2.5 use the official Seedance task API: submitting a task returns a task ID immediately, and you poll for the result. Use an API key created in the media group with the Base URL https://image-2.relaybases.com.

Purpose Method Path
Create a task POST /v1/contents/generations/tasks
Query a task GET /v1/contents/generations/tasks/{task_id}

Programs already built on the official Seedance task API only need to switch the Base URL to https://image-2.relaybases.com/v1 and use a RelayBases API key.

Models and specifications

Model Model ID Resolution Duration
Seedance 2.0 doubao-seedance-2-0-260128 480p 720p 1080p 4k 4–15 seconds
Seedance 2.0 Fast doubao-seedance-2-0-fast-260128 480p 720p 4–15 seconds
Seedance 2.0 Mini doubao-seedance-2-0-mini-260615 480p 720p 4–15 seconds
Seedance 2.5 doubao-seedance-2-5-260628 480p 720p 1080p 4–30 seconds

Supported aspect ratios are 16:9, 9:16, 1:1, 21:9, 4:3, and 3:4, with 16:9 as the default. When duration is omitted, the default is 4 seconds.

Pricing

Model Resolution Without reference video With reference video
Seedance 2.0 480p 720p Ɍ43.7 per 1M tokens Ɍ26.6 per 1M tokens
Seedance 2.0 1080p Ɍ48.45 per 1M tokens Ɍ29.45 per 1M tokens
Seedance 2.0 4k Ɍ24.7 per 1M tokens Ɍ15.2 per 1M tokens
Seedance 2.0 Fast 480p 720p Ɍ35.15 per 1M tokens Ɍ20.9 per 1M tokens
Seedance 2.0 Mini 480p 720p Ɍ21.85 per 1M tokens Ɍ13.3 per 1M tokens
Seedance 2.5 480p 720p Ɍ66.5 per 1M tokens Ɍ39.9 per 1M tokens
Seedance 2.5 1080p Ɍ73.15 per 1M tokens Ɍ43.7 per 1M tokens

Billing settles on the actual token usage returned upstream. When the request content carries a video_url reference video, the with-reference-video price applies. Token usage is roughly seconds × width × height × 24 ÷ 1024: about 9.6K tokens per second at 480p, 21.6K at 720p, 48.6K at 1080p, and 194.4K at 4K. For example, a 5-second 720p Seedance 2.0 video without a reference video uses about 108K tokens, or about Ɍ4.72.

Request parameters

Field Type Required Description
model string Yes A model ID from the table above.
content array Yes At least one non-empty text item; image_url, video_url, and audio_url items may be added under the rules below.
resolution string Yes A resolution the model supports, per the table above. Unsupported values are rejected without a charge.
duration integer No Video length in seconds. Seedance 2.0, 2.0 Fast, and 2.0 Mini support 4–15 seconds; Seedance 2.5 supports 4–30 seconds. Defaults to 4 seconds when omitted.
ratio string No Aspect ratio, 16:9 by default; supports 16:9, 9:16, 1:1, 21:9, 4:3, and 3:4.
seed integer No Random seed, passed to the generation service unchanged.
generate_audio boolean No Whether to generate audio; depends on the upstream model.
watermark boolean No Watermark setting; depends on the upstream model.
return_last_frame boolean No Returns the last frame when the upstream supports it.
priority integer No Task priority, passed to the generation service unchanged.
execution_expires_after integer No Task execution validity period; unit and range follow the upstream protocol.
tools array No Model tool configuration, passed to the generation service unchanged.
safety_identifier string No A safety identifier supplied by the caller.

Reference materials

Type role Rules
text — Required; at least one non-empty item.
image_url reference_image first_frame last_frame A public URL or an asset://… material reference. At most one first frame and one last frame; with first/last frames, at most two images in total and no reference video.
video_url reference_video A public URL or an asset://… material reference; the with-reference-video price applies.
audio_url reference_audio A public URL or an asset://… material reference.

Examples

Create a Seedance task

curl -sS -X POST "https://image-2.relaybases.com/v1/contents/generations/tasks" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedance-2-0-260128",
    "content": [
      {"type": "text", "text": "Sunset over the sea, slow push-in, cinematic lighting"},
      {"type": "image_url", "image_url": {"url": "https://your-cdn.com/reference.jpg"}, "role": "reference_image"}
    ],
    "resolution": "720p",
    "duration": 5,
    "ratio": "16:9",
    "generate_audio": true
  }'

Create response

{
  "id": "task_xxx"
}

Query a task

curl -sS "https://image-2.relaybases.com/v1/contents/generations/tasks/task_xxx" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY"

Success response

{
  "id": "task_xxx",
  "model": "doubao-seedance-2-0-260128",
  "status": "succeeded",
  "content": {
    "video_url": "https://.../result.mp4"
  },
  "resolution": "720p",
  "duration": 5,
  "ratio": "16:9",
  "usage": {
    "completion_tokens": 108000,
    "total_tokens": 108000
  }
}

How to read the task status

queued and processing mean the task is still waiting or generating, so keep polling. On succeeded, read content.video_url and usage.total_tokens. On failed, read error.message. The video URL comes from the upstream, so download and store it promptly.

How billing works

An estimated amount is reserved when the task is created. After success, the task settles on the usage.total_tokens returned upstream, with any difference refunded or charged. Failed or rejected tasks release the reservation. The console bill is authoritative.

Image generation and editing

Image generation and editing use the dedicated Base URL https://image-2.relaybases.com. Use an API key created in the media group and select a currently available image model from the live catalog above. Supported parameters, response formats, and prices are defined by the model details and console bill.

Use JSON with /v1/images/generations for text-to-image generation. Use multipart/form-data with /v1/images/edits for image editing. Replace CURRENT_IMAGE_MODEL in the examples with an available model from the live catalog.

Generate an image

curl -sS --max-time 600 -X POST "https://image-2.relaybases.com/v1/images/generations" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "CURRENT_IMAGE_MODEL",
    "prompt": "An orange cat under neon lights in a cyberpunk city, cinematic, richly detailed",
    "size": "1024x1024",
    "quality": "high",
    "output_format": "png",
    "n": 1
  }' \
  -o response.json

Edit an image

curl -sS --max-time 600 -X POST "https://image-2.relaybases.com/v1/images/edits" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY" \
  -F "model=CURRENT_IMAGE_MODEL" \
  -F "image[]=@/path/to/source.png" \
  -F "prompt=Change the background to Tokyo at night while preserving the person's face, hair, expression, and pose" \
  -F "size=1024x1024" \
  -F "quality=high" \
  -F "output_format=png" \
  -F "n=1" \
  -o response.json

Multiple reference images

curl -sS --max-time 600 -X POST "https://image-2.relaybases.com/v1/images/edits" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY" \
  -F "model=CURRENT_IMAGE_MODEL" \
  -F "image[]=@/path/to/1.png" \
  -F "image[]=@/path/to/2.png" \
  -F "prompt=Use both references to create a new scene with the same person" \
  -F "size=1024x1024" \
  -F "quality=high" \
  -F "output_format=png" \
  -F "n=1"

Read the response

# OpenAI-compatible image responses commonly use the data array:
# data[0].url             image URL when returned by the current model
# data[0].b64_json        inline base64 image data when returned
# data[0].revised_prompt  revised prompt when provided

jq -r '.data[0].url // .data[0].b64_json // empty' response.json

GPT Image (gpt-image-2 / 2.5 / 2.6)

gpt-image-2, gpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2.6-flare and gpt-image-2.6-sunburst use the OpenAI image endpoints and the Base URL above; keys from both the media and image-cheap groups can call them. All five models share one price: billing is a flat price per generated or edited image, whatever the quality or size; Model Square shows the per-image price for each group.

  1. Flare is faster and suits quick iteration; Sunburst keeps more detail and suits dense compositions, text-heavy images and multi-turn edits.
  2. gpt-image-2.6 accepts custom sizes in multiples of 16 pixels with aspect ratios from 1:3 to 3:1; the image-cheap group does not support native 4K.
  3. To switch models, change only the model parameter, for example to gpt-image-2.6-flare; the other parameters stay as in the examples above.

Nano Banana (Gemini image models)

Nano Banana 2, Nano Banana 2.1 and Nano Banana Pro use the same media-group key and the Base URL above. Call them through the OpenAI image endpoints above or through the native Gemini API; billing is per generated image.

OpenAI image endpoints

curl -sS --max-time 600 -X POST "https://image-2.relaybases.com/v1/images/generations" \
  -H "Authorization: Bearer $RELAYBASES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3-pro-image",
    "prompt": "A quiet alley after the rain, lanterns reflected on the stone path, cinematic",
    "size": "1536x1024",
    "n": 1
  }' \
  -o response.json

# Edits: send model, prompt and image[] (one or more) as multipart to /v1/images/edits
#   -F "model=gemini-nano-banana-2.1" -F "image[]=@1.png" -F "image[]=@2.png" -F "prompt=..."

Native Gemini API

curl -sS --max-time 600 -X POST \
  "https://image-2.relaybases.com/v1beta/models/gemini-3.1-flash-image:generateContent" \
  -H "x-goog-api-key: $RELAYBASES_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [{"parts": [{"text": "A shiba inu wearing a red scarf, watercolor"}]}],
    "generationConfig": {
      "responseModalities": ["IMAGE"],
      "imageConfig": {"aspectRatio": "16:9", "imageSize": "2K"}
    }
  }' \
  -o response.json

# The image is in candidates[0].content.parts[].inlineData.data (base64)
  1. size accepts pixel dimensions (such as 1536x1024 or 3840x2160), an aspect ratio (such as 16:9) or 1K, 2K or 4K; the gateway converts it to the closest aspect ratio and resolution. Leave it empty or use auto for the model default.
  2. Each image is generated separately: n images are generated at the same time and billed as n images. Edits accept several reference images; mask is not supported.
  3. One image usually takes 15–45 seconds and 4K takes longer, so set the client timeout to at least 300 seconds. Programs that already use a Gemini SDK only need to set the Base URL to https://image-2.relaybases.com and nothing else.

Does the response use a URL or b64_json?

The response format depends on the current model and request parameters; handle both data[0].url and data[0].b64_json. If you get an error object, follow its message; retry transient 502 or server_error responses later.

Model or group not available

This usually means the key is not in the media group, or the request was sent to a general text endpoint. Create a media-group key and confirm the URL is https://image-2.relaybases.com.

Connection dropped / timeout (curl 56, schannel closed abruptly)

The image endpoints respond synchronously; a quality=high request typically takes 1–3 minutes, and larger sizes take longer. If the client or an intermediate proxy times out during the wait, you see errors like curl: (56) schannel: server closed abruptly. Raise the timeout and auto-retry, e.g. --max-time 600 --retry 3 --retry-all-errors, and start with 1024x1024 before scaling up.

Running on Windows

In PowerShell, curl is an alias for Invoke-WebRequest — use curl.exe and put the command on a single line (drop the trailing \). Windows has no built-in jq/base64, so save the response with -o response.json and decode it in PowerShell: powershell -Command "$j=Get-Content response.json | ConvertFrom-Json; [IO.File]::WriteAllBytes('out.png', [Convert]::FromBase64String($j.data[0].b64_json))".

Commands

Slash commands vary by Claude Code and Codex CLI version, but these are the ones most useful for day-to-day setup, context cleanup, and cost checks.

Command What it does When to use it
/help Shows supported commands and shortcuts for the current client. Run it after a fresh install or upgrade.
/clear Clears the current conversation context. Use it when switching tasks or when old context starts leaking into the answer.
/compact Compresses the current context while keeping the important progress. Useful for long coding sessions you want to continue.
/cost Shows session usage or cost details when the client supports it. Use it to estimate spend or investigate Credits usage.
/model Shows or changes the active model. Use it when switching between speed, cost, and reasoning quality.
If a command is missing, trust the current client's /help output. Command names can change slightly between releases.

Troubleshooting

Install fails or downloads slowly

Check that your network can reach the official install source, then review proxy, firewall, and DNS settings. On Windows, retry from an administrator terminal.

Command not found

Make sure Node.js, npm, and your global npm bin directory are on PATH. On macOS / Linux, check npm config get prefix. On Windows, reopen PowerShell or VS Code after changing environment variables.

Invalid key or 401

Check that the key was copied completely, has no extra spaces, and is not disabled or expired. The full key is only shown once after creation.

Wrong endpoint

Claude Code uses the selected hostname itself, such as https://api.relaybases.com. OpenAI-compatible clients append /v1, such as https://api.relaybases.com/v1. The US direct endpoint follows the same rule.

Long-running synchronous request times out

The standard endpoint passes through Cloudflare, so a long-running synchronous request may be subject to a proxy timeout. Change only the hostname to us.relaybases.com, keeping the same protocol path and API key. The direct endpoint may be unreachable from some networks.

Environment variables did not apply

Temporary environment variables only apply to the current terminal. After editing ~/.zshrc, ~/.bashrc, or Windows user environment variables, reopen your terminal and editor.

Cannot connect to the API

Check the Base URL first, then review proxy, firewall, and DNS settings. On macOS / Linux, test both curl -I https://api.relaybases.com and curl -I https://us.relaybases.com. On Windows, use Test-NetConnection api.relaybases.com -Port 443 and Test-NetConnection us.relaybases.com -Port 443.

Balance or group mismatch

Confirm that your account has enough API Credits and that the key group matches the model. Image models need the image group and image endpoint.

Image API does not work

Image generation should use https://image-2.relaybases.com, not the general OpenAI compatible endpoint. Also confirm that the key belongs to the media group.