Gateway Referencev1.0 API

Relay API Documentation

Relay is a high-concurrency, edge-optimized inference gateway designed to sit between your client software and upstream foundational AI providers (Anthropic, OpenAI, DeepSeek, Google Vertex). Instead of wrangling disparate provider SDKs, handling provider rate limits, and implementing custom retries, point your application at Relay for instant key pooling, automatic sub-second failover, and exact per-token cost ledgering.

Multi-Provider Key Pooling

Rotate multiple upstream API keys dynamically with zero downtime. Healthy keys are prioritized automatically.

Instant Model Fallbacks

If an upstream provider returns 429 or 503, Relay seamlessly reroutes the payload through your configured backup model.

Claude Code CLI Drop-in

Drop Relay straight into Anthropic Claude Code CLI with simple environment variables—no client code patches needed.

ENDPOINT BASE URLSSSL READY
OpenAI Compatible Root
https://botliy.online/api/v1
Anthropic Native & Claude Code Base
https://botliy.online
Production ready SSL endpoint configured on https://botliy.online.

Quick Start Guide

OpenAI Compatible

Connect your existing OpenAI client library by changing just the baseURL and apiKey. Relay transparently proxies the call to the appropriate provider (e.g., Anthropic, DeepSeek, or OpenAI).

Execute First Inference Request
curl https://botliy.online/api/v1/chat/completions \
  -H "Authorization: Bearer rly_live_your_relay_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-7-sonnet",
    "messages": [
      {"role": "system", "content": "You are a distributed systems architect."},
      {"role": "user", "content": "Explain raft consensus in two sentences."}
    ]
  }'

Authentication & API Keys

All requests to Relay require authentication using a valid live API key prefixed with rly_live_. Keys are generated in your Dashboard and hashed cryptographically with Argon2id before storing. Relay accepts authentication in two standard header formats:

Authorization Bearer Header
Authorization: Bearer rly_live_...
Used by standard OpenAI SDKs, LangChain, LlamaIndex, and curl.
Anthropic x-api-key Header
x-api-key: rly_live_...
Used by the official Anthropic TypeScript/Python SDKs and Claude Code CLI.
Per-Key Spend Limits

When creating keys in your dashboard, you can define an optional spend cap (e.g., \$10.00 USD). If the cumulative spend of a key hits that threshold, Relay immediately refuses further requests from that key with HTTP 429 without terminating other keys on your account.

Autonomous Agent CLIs (Claude Code & Codex)

Drop-in Ready

Connect your frontier terminal coding agents directly to Relay. Seamless native emulation for both Anthropic Messages and OpenAI Chat protocols with zero rate-limit headache and transparent credit billing.

01

Install Claude Code

Recommended method: native PowerShell installer. Alternative: WinGet package manager.

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

Install Git for Windows if you want Claude Code to use Git Bash. Without it, Claude Code will seamlessly use PowerShell.

02

Create a Relay API Key

Open the API Keys page, create a key (e.g. rly_live_...), and copy it.

Treat this key like a password. Anyone with it can spend your Relay credit balance and plan limits.
03

Create settings.json

Save this file at C:\Users\YOUR_USERNAME\.claude\settings.json.

Create folder command
New-Item -ItemType Directory "$env:USERPROFILE\.claude" -Force
settings.json
{
  "env": {
    "ANTHROPIC_API_KEY": "YOUR_RELAY_API_KEY",
    "ANTHROPIC_BASE_URL": "https://botliy.online/",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  },
  "permissions": {
    "allow": [],
    "deny": []
  }
}

Replace YOUR_RELAY_API_KEY with your real key. If you used an older setup, remove any stale apiKeyHelper entries to prevent 401 Unauthorized errors.

04

Verify and start

Run in terminal
claude --version
claude doctor
cd path-to-your-project
claude
Claude Code Base URL
https://botliy.online/
Codex CLI Base URL
https://botliy.online/v1

Frequently Asked Questions

Use Codex CLI when you want OpenAI/DeepSeek chat completion workflows and the official Codex terminal agent. Use Claude Code when your workflow expects Anthropic-compatible tool calling, Claude Code project behavior, or autonomous multi-file refactoring.

POST /api/v1/chat/completions

OpenAI Schema

Standard chat completion route. Accepts system, user, and assistant messages, alongside temperature, max tokens, and streaming options.

FIELDTYPEREQDESCRIPTION
modelstringYesPublic model ID (e.g. claude-3-7-sonnet)
messagesarrayYesArray of message objects with role and content
streambooleanNoWhen true, pushes tokens via SSE
temperaturefloatNoSampling temperature 0.0–2.0 (default 0.7)
max_tokensintegerNoMaximum tokens to generate
Example Payload
curl https://botliy.online/api/v1/chat/completions \
  -H "Authorization: Bearer rly_live_your_relay_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-7-sonnet",
    "messages": [
      {"role": "system", "content": "You are a distributed systems architect."},
      {"role": "user", "content": "Explain raft consensus in two sentences."}
    ]
  }'

POST /api/v1/messages & /v1/messages

Anthropic Schema

Native Anthropic format supporting anthropic-version: 2023-06-01, structured system messages, multimodal image inputs, and Anthropic SSE streams.

Anthropic Messages Invocation
curl https://botliy.online/api/v1/messages \
  -H "x-api-key: rly_live_your_relay_key" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-7-sonnet",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Write an enterprise unit test in Jest"}
    ]
  }'

POST /api/v1/responses

OpenAI Responses API

Direct endpoint for quick single-turn prompt responses, compatible with OpenAI's Responses endpoint interface.

POST /api/v1/responses
curl https://botliy.online/api/v1/responses \
  -H "Authorization: Bearer rly_live_your_relay_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "input": "Summarize microservice choreography vs orchestration"
  }'

POST /v1/messages/count_tokens

Context Budgeting

Allows client agents and tools to calculate accurate token weights before sending long prompts or multi-file context windows. This does not consume account credits.

Token Calculation Request
curl https://botliy.online/v1/messages/count_tokens \
  -H "x-api-key: rly_live_your_relay_key" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-7-sonnet",
    "messages": [
      {"role": "user", "content": "Calculate the exact token count before sending"}
    ]
  }'

GET /api/v1/models & /v1/models

View Model Matrix

Returns the list of active public models with context window limits and real-time per-million token pricing in standard OpenAI list format.

SAMPLE JSON RESPONSE
{
  "object": "list",
  "data": [
    {
      "id": "claude-3-7-sonnet",
      "object": "model",
      "created": 1715000000,
      "owned_by": "relay",
      "context_window": 200000,
      "pricing": {
        "prompt": 0.000003,
        "completion": 0.000015
      }
    },
    {
      "id": "gpt-4o",
      "object": "model",
      "created": 1715000000,
      "owned_by": "relay",
      "context_window": 128000,
      "pricing": {
        "prompt": 0.0000025,
        "completion": 0.00001
      }
    }
  ]
}

Realtime Server-Sent Events (SSE)

When "stream": true is supplied, Relay establishes an immediate HTTP SSE connection. Upstream tokens are piped directly to your client with negligible latency, while billing meters debit credits asynchronously upon stream completion.

Streaming Requests
curl https://botliy.online/api/v1/chat/completions \
  -H "Authorization: Bearer rly_live_your_relay_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v3",
    "stream": true,
    "messages": [{"role": "user", "content": "Stream response in realtime token by token"}]
  }'
Streaming Safety & Metering

If a streaming connection terminates prematurely (client disconnect or upstream error), Relay calculates tokens generated up to that disconnect moment and logs the exact trace without overcharging.

Smart Routing & Automatic Fallbacks

Relay decouples client-facing model IDs from upstream credentials. When you route through Relay, four intelligent mechanisms ensure maximum uptime:

1. Priority Order Pooling

Assign multiple API keys to a single provider. Primary keys handle traffic first; backup keys are called if limits are reached.

2. Dynamic Latency Optimization

Automatically routes traffic to provider keys exhibiting the lowest sliding 5-minute p95 response times.

3. Cascading Fallback Chains

If an upstream model encounters global capacity depletion (503/429), the gateway transparently reroutes to your configured fallback model.

4. Prompt Cache Deduplication

Identical system instructions and context windows are hashed with SHA-256 to save latency and token costs on repeated tool iterations.

Rate Limits & Headers

Relay returns explicit rate-limit and correlation headers on every response, ensuring production monitoring systems can track usage:

HEADERDESCRIPTION
X-Request-IdUnique correlation ID for audits and trace logs
X-Response-Time-MsRound-trip execution latency in milliseconds
X-RateLimit-Limit-RequestsMaximum RPM for your active plan
X-RateLimit-Remaining-RequestsRemaining calls in the sliding 60-second window
Retry-AfterRecommended wait duration (seconds) on HTTP 429

Error Codes & Taxonomy

Relay uses standard HTTP response codes paired with machine-readable JSON error payloads:

STATUSERROR TYPEMEANING & RESOLUTION
400invalid_request_errorMalformed JSON or missing model / messages.
401authentication_errorMissing, revoked, or expired API key.
402insufficient_creditsCredit balance depleted. Top up in Dashboard > Billing.
403permission_errorAccount suspended or lacks model permission.
404not_found_errorModel ID not found or disabled in the Model Matrix.
429rate_limit_errorRPM or key spend limit reached. Respect Retry-After.
500 / 502gateway_errorUpstream provider failed, all fallbacks exhausted.

Billing & Credits Guide

Go to Billing

Relay uses flexible on-demand credit top-ups designed for engineering teams. Zero card checkout traps, zero surprise recurring subscriptions.

1
Scan QR Code

Navigate to Dashboard > Billing and scan the verified UPI QR code using any UPI app (GPay, PhonePe, Paytm, CRED).

2
Submit 12-Digit UTR

Enter the exact paid amount and paste your bank transaction reference (UTR / UPI Ref ID). You can optionally upload a payment screenshot.

3
Instant Ledger Top-Up

Once verified, credits are added directly to your account balance with full audit logs visible in your credit transaction history.