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.
Create an API Key
Generate a scoped sk-sr-v1 key with optional USD spend caps and RPM limits.
Open API Keys →Point baseURL
Set baseURL to https://api.sevenrelay.ai/v1 (or http://localhost:3000/api/v1 locally).
See SDK snippets →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.
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 TelemetryOpenAI, Python & Vercel AI SDKs
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 ?? "");
}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)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/autoAutomatically dispatches short queries to Flash models and deep coding/reasoning tasks to frontier flagships.
model:nitroRoutes to the highest tokens/second inference host (Cerebras, Groq, Fireworks) available for that model.
model:floorSelects the lowest $/1M token provider endpoint dynamically while preserving uptime guarantees.
provider.zdr: trueExcludes any provider that logs or retains prompt data. Ideal for regulated legal, health, and finance teams.
{
"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
/api/v1/chat/completionsUnified OpenAI-compatible chat completion endpoint supporting SSE streaming, smart routing, fallback chains, live BYOK proxying, and real-time credit metering.
/api/v1/modelsReturns the live machine-readable catalog of all 32+ routable models, pricing per token, context windows, and ZDR eligibility.
/api/v1/keyIntrospects the Bearer API key's remaining USD spend cap, RPM quota, allowed models scope, and account balance.
HTTP Status & Error Codes
| Code | Meaning | Recommended Action |
|---|---|---|
| 400 | Invalid Request | Verify JSON schema and ensure 'messages' is a non-empty array. |
| 401 | Unauthorized | Check 'Authorization: Bearer sk-sr-v1-...' header validity. |
| 402 | Budget / Balance Exhausted | Increase the key's USD cap in /keys or top up in /credits. |
| 403 | Key Disabled / Model Out of Scope | Re-enable the key or add the model to its allowed whitelist. |
| 429 | Rate Limited | Back off exponentially or configure a fallback model array. |
| 502 | Upstream Unavailable | SevenRelay auto-retries across alternate providers before returning 502. |