Quickstart
Configure a private preview key and send your first request through the OffRail API.
OffRail uses one API key across its public image, video, chat, and audio routes.
Private preview — The self-service console is not open yet. Continue only if you have received an OffRail preview key.
1. Configure your key and model
Store the key on your server. Never expose it in browser-side code or commit it to source control.
export OFFRAIL_API_KEY="orl_..."
export OFFRAIL_MODEL="<model-id-from-the-public-catalogue>"Choose the model ID from the live public catalogue. The catalogue is the source of truth for current availability, route, delivery behavior, and pricing.
2. Choose the matching route
| Task | Endpoint | What returns |
|---|---|---|
| Chat | /v1/chat/completions | JSON or event stream |
| Image | /v1/images/generations | Image result or task |
| Video | /v1/videos | Asynchronous task |
| Audio | /v1/audio/speech | Binary audio payload |
The example below uses the chat route. Select a chat-capable model before running it.
3. Send your first request
curl https://api.offrail.ai/v1/chat/completions \
-H "Authorization: Bearer $OFFRAIL_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"model\": \"$OFFRAIL_MODEL\",
\"messages\": [
{\"role\": \"user\", \"content\": \"Write the next scene.\"}
]
}"const apiKey = process.env.OFFRAIL_API_KEY;
const model = process.env.OFFRAIL_MODEL;
if (!apiKey || !model) {
throw new Error("OFFRAIL_API_KEY and OFFRAIL_MODEL are required");
}
const response = await fetch("https://api.offrail.ai/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model,
messages: [{ role: "user", content: "Write the next scene." }],
}),
});
if (!response.ok) {
throw new Error(`OffRail request failed: ${response.status}`);
}
const result = await response.json();
console.log(result.choices[0].message.content);import os
import requests
response = requests.post(
"https://api.offrail.ai/v1/chat/completions",
headers={
"Authorization": f"Bearer {os.environ['OFFRAIL_API_KEY']}",
"Content-Type": "application/json",
},
json={
"model": os.environ["OFFRAIL_MODEL"],
"messages": [
{"role": "user", "content": "Write the next scene."}
],
},
timeout=60,
)
response.raise_for_status()
print(response.json()["choices"][0]["message"]["content"])4. Handle delivery by modality
- Chat — read a JSON response or set
stream: truefor server-sent events. - Image — handle the image result or task shape documented by the selected model.
- Video — store the task ID returned by
POST /v1/videos, then poll or use a webhook. - Audio — treat the
/v1/audio/speechresponse as binary audio, not JSON.
5. Handle errors
OffRail uses standard HTTP status codes. Log the response body and request ID when available, but never log your API key.
400— the request or model-specific option is invalid;401— the API key is missing or invalid;402— the account has insufficient credit;429— a rate limit was reached;5xx— the gateway or all eligible upstream routes failed.
See Error handling for the complete error shape.

