sevenrelay
Developer Documentation

SevenRelay Quickstart

SevenRelay exposes a unified, OpenAI-compatible HTTP API over 32+ frontier and open-weight AI models. Route traffic across 7 global edge relays with automatic failover, real-time credit metering, and zero SDK lock-in.

STEP 01

Create an API Key

Generate a scoped sk-sr-v1 key with optional USD spend caps and RPM limits.

Open API Keys →
STEP 02

Point baseURL

Set baseURL to https://api.sevenrelay.ai/v1 (or http://localhost:3000/api/v1 locally).

See SDK snippets →
STEP 03

Attach BYOK or Test

Stream immediately via Edge Simulator or add real upstream keys in Providers.

Configure Upstreams →

Authentication & Attribution Headers

Pass your SevenRelay secret key in the standard Authorization Bearer header. Optional HTTP-Referer and X-Title headers attribute your product in the SevenRelay Top Apps rankings.

HTTP Headers
Authorization: Bearer sk-sr-v1-...
Content-Type: application/json
HTTP-Referer: https://your-app.com    # Optional: App URL for Rankings
X-Title: Your App Name                # Optional: App Name for Telemetry

OpenAI, Python & Vercel AI SDKs

TypeScript / Node.js (openai npm package)
import OpenAI from "openai";

const sevenrelay = new OpenAI({
  baseURL: "http://localhost:3000/api/v1", // Production: https://api.sevenrelay.ai/v1
  apiKey: process.env.SEVENRELAY_API_KEY,
  defaultHeaders: {
    "HTTP-Referer": "https://your-app.com",
    "X-Title": "My AI Product",
  },
});

const stream = await sevenrelay.chat.completions.create({
  model: "anthropic/claude-sonnet-4.6",
  stream: true,
  messages: [{ role: "user", content: "Design an idempotent billing webhook." }],
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
Python (openai pip package)
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:3000/api/v1",
    api_key="sk-sr-v1-your-key",
)

resp = client.chat.completions.create(
    model="sevenrelay/auto",
    messages=[{"role": "user", "content": "Summarize multi-region failover best practices."}],
)
print(resp.choices[0].message.content)
Cursor / Cline / Continue IDE Configuration
Provider:   OpenAI Compatible
Base URL:   https://api.sevenrelay.ai/v1
API Key:    sk-sr-v1-your-key
Model ID:   sevenrelay/code  (or anthropic/claude-sonnet-4.6)

Smart Routing, Suffixes & Failover

Control speed, price, privacy, and automatic fallback chains directly from the request payload without changing code structure:

sevenrelay/auto
Adaptive Complexity Router

Automatically dispatches short queries to Flash models and deep coding/reasoning tasks to frontier flagships.

model:nitro
Throughput Priority

Routes to the highest tokens/second inference host (Cerebras, Groq, Fireworks) available for that model.

model:floor
Price Floor Priority

Selects the lowest $/1M token provider endpoint dynamically while preserving uptime guarantees.

provider.zdr: true
Zero Data Retention Lock

Excludes any provider that logs or retains prompt data. Ideal for regulated legal, health, and finance teams.

Explicit Fallback Chain + ZDR Routing JSON
{
  "model": "anthropic/claude-sonnet-4.6",
  "models": [
    "anthropic/claude-sonnet-4.6",
    "openai/gpt-5.4",
    "deepseek/deepseek-v3.2"
  ],
  "provider": {
    "sort": "latency",
    "zdr": true,
    "region": "eu"
  },
  "messages": [{ "role": "user", "content": "Audit this GDPR clause." }]
}

Live API Endpoints

POST/api/v1/chat/completions

Unified OpenAI-compatible chat completion endpoint supporting SSE streaming, smart routing, fallback chains, live BYOK proxying, and real-time credit metering.

GET/api/v1/models

Returns the live machine-readable catalog of all 32+ routable models, pricing per token, context windows, and ZDR eligibility.

GET/api/v1/key

Introspects the Bearer API key's remaining USD spend cap, RPM quota, allowed models scope, and account balance.

HTTP Status & Error Codes

CodeMeaningRecommended Action
400Invalid RequestVerify JSON schema and ensure 'messages' is a non-empty array.
401UnauthorizedCheck 'Authorization: Bearer sk-sr-v1-...' header validity.
402Budget / Balance ExhaustedIncrease the key's USD cap in /keys or top up in /credits.
403Key Disabled / Model Out of ScopeRe-enable the key or add the model to its allowed whitelist.
429Rate LimitedBack off exponentially or configure a fallback model array.
502Upstream UnavailableSevenRelay auto-retries across alternate providers before returning 502.