Getting started
Quick Start
From zero to a first answer in three steps. The examples use the official OpenAI SDKs, plain cURL or the railwail npm package; pick your language in the tabs.
- 1
Create an API key
Sign in and open API keys. Keys start with
rw_live_and are shown once, so copy yours right away.A new key has the scopes
readandchat. That is enough for this page. For images, video, audio or embeddings tick those scopes (orall) when you create the key; otherwise those calls return403 insufficient_scope. - 2
Put the key in your environment
Every example in these docs reads the key from
RAILWAIL_API_KEY, so they run as copied.export RAILWAIL_API_KEY="rw_live_..."$env:RAILWAIL_API_KEY = "rw_live_..."RAILWAIL_API_KEY=rw_live_...Check the key for free: listing one model costs nothing and answers 401 if the key is wrong.
bash curl -s "https://railwail.com/api/v1/models?limit=1" \ -H "Authorization: Bearer $RAILWAIL_API_KEY" - 3
Make your first request
Chat with
gpt-4o-mini.max_tokenscaps the answer, and with it the credits the API reserves for the call.curl https://railwail.com/api/v1/chat/completions \ -H "Authorization: Bearer $RAILWAIL_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Explain quantum computing in one paragraph."}], "max_tokens": 300 }'# pip install openai import os from openai import OpenAI client = OpenAI( api_key=os.environ["RAILWAIL_API_KEY"], base_url="https://railwail.com/api/v1", ) completion = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Explain quantum computing in one paragraph."}], max_tokens=300, ) print(completion.choices[0].message.content)// npm i openai (ESM: save as quickstart.mjs) import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.RAILWAIL_API_KEY, baseURL: "https://railwail.com/api/v1", }); const completion = await client.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "user", content: "Explain quantum computing in one paragraph." }], max_tokens: 300, }); console.log(completion.choices[0].message.content);// npm i railwail (ESM: save as quickstart.mjs) import railwail from "railwail"; const rw = railwail(process.env.RAILWAIL_API_KEY); const reply = await rw.run("gpt-4o-mini", "Explain quantum computing in one paragraph.", { max_tokens: 300, }); console.log(reply);
Testing on the free trial
max_tokens reserves credits for 4,096 output tokens (or the model's limit if lower) and can hit that cap (429 trial_limit), so keep max_tokens small. What a model costs is on its model page and on the pricing page.More examples
Chat with a system prompt and history
Pass the whole conversation; the model sees every message.
curl https://railwail.com/api/v1/chat/completions \
-H "Authorization: Bearer $RAILWAIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 400,
"messages": [
{"role": "system", "content": "You are a helpful coding assistant."},
{"role": "user", "content": "How do I reverse a string in Python?"}
]
}'completion = client.chat.completions.create(
model="claude-sonnet-4-6",
max_tokens=400,
messages=[
{"role": "system", "content": "You are a helpful coding assistant."},
{"role": "user", "content": "How do I reverse a string in Python?"},
],
)
print(completion.choices[0].message.content)const completion = await client.chat.completions.create({
model: "claude-sonnet-4-6",
max_tokens: 400,
messages: [
{ role: "system", content: "You are a helpful coding assistant." },
{ role: "user", content: "How do I reverse a string in Python?" },
],
});
console.log(completion.choices[0].message.content);const reply = await rw.run(
"claude-sonnet-4-6",
[
{ role: "system", content: "You are a helpful coding assistant." },
{ role: "user", content: "How do I reverse a string in Python?" },
],
{ max_tokens: 400 },
);
console.log(reply);Generate an image
Needs a key with the images scope. The response carries a URL per image; it can be a temporary provider link, so download the file if you want to keep it.
curl https://railwail.com/api/v1/images/generations \
-H "Authorization: Bearer $RAILWAIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-1-schnell",
"prompt": "A cyberpunk cityscape at dusk, neon reflections on wet streets"
}'image = client.images.generate(
model="flux-1-schnell",
prompt="A cyberpunk cityscape at dusk, neon reflections on wet streets",
)
print(image.data[0].url) # None while a slow run is still processing (HTTP 202)const image = await client.images.generate({
model: "flux-1-schnell",
prompt: "A cyberpunk cityscape at dusk, neon reflections on wet streets",
});
console.log(image.data[0].url); // null while a slow run is still processing (HTTP 202)const res = await rw.image(
"flux-1-schnell",
"A cyberpunk cityscape at dusk, neon reflections on wet streets",
);
console.log(res.data[0].url);Embeddings
Vectors for search and retrieval, with the same key (it needs the embeddings scope). Limits and errors are on the embeddings page.
res = client.embeddings.create(model="text-embedding-3-small", input=["first text", "second text"])
print(len(res.data), len(res.data[0].embedding)) # 2 1536const res = await client.embeddings.create({ model: "text-embedding-3-small", input: ["first text", "second text"] });
console.log(res.data.length, res.data[0].embedding.length); // 2 1536Next steps
Chat Completions
Streaming, tools, JSON schema output and every parameter the endpoint accepts.
Images, video, speech
Image generation, video jobs, text to speech and transcription, each with live model lists.
railwail npm SDK
The small SDK: run, chat, image, embed, models, job. What it covers and what it does not.
Connect your coding agent
One MCP config gives Claude Code, Cursor or VS Code the catalog, prices and these docs.