TL;DR โ Switch in Under 2 Minutes
- Railwail is OpenAI-API-compatible โ your existing openai SDK works unchanged
- Migration = change two values: baseURL and apiKey. No code refactor
- Same chat completions endpoint, same streaming, same tool calling, same JSON mode
- Bonus: instantly unlock 200+ models from Anthropic, Google, DeepSeek and more behind the same SDK
OpenAI's most capable multimodal model. Excellent for complex reasoning, coding, and creative tasks.
Models in this article
Why Move Off OpenAI Direct?
OpenAI's API is excellent โ but it locks you into a single vendor. When GPT-4o costs spike or a competitor releases a better model, you cannot switch without rewriting integration code. Railwail solves this by exposing major frontier models behind the OpenAI-compatible Chat Completions schema. You get the OpenAI developer experience plus the freedom to swap providers with a single string change.
In addition to portability, teams move to Railwail for the ability to test Claude, Gemini, Llama, DeepSeek and 200+ more models without managing separate accounts. This guide walks through the full migration end to end.
Step 1 โ Get a Railwail API Key
Sign up at railwail.com, go to Dashboard โ API Keys, and click Create New Key. Keys are prefixed with rw_live_ and look like rw_live_xxxxxxxxxxxxxxxxxxxxxxxx. Sign up with Google to get 10 free credits ($0.10), usable 24 hours after sign-up.
Copy the key into your environment file. The convention in most projects is to keep the existing OPENAI_API_KEY name so you do not have to touch your config-loading code โ Railwail keys work in that variable transparently because the SDK does not validate the prefix.
Step 2 โ Change the Base URL
Before (OpenAI direct):
import OpenAI from "openai";
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
const res = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello" }],
});After (Railwail):
import OpenAI from "openai";
const openai = new OpenAI({
apiKey: process.env.RAILWAIL_API_KEY,
baseURL: "https://railwail.com/api/v1",
});
const res = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hello" }],
});That is the entire diff. The rest of your app โ streaming, function calling, vision, JSON mode, retries โ works unchanged.
from openai import OpenAI
client = OpenAI(
api_key=os.environ["RAILWAIL_API_KEY"],
base_url="https://railwail.com/api/v1",
)
resp = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)curl https://railwail.com/api/v1/chat/completions \
-H "Authorization: Bearer $RAILWAIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello"}],
"stream": false
}'Step 3 โ Verify Streaming, Tools, Vision
Run your existing test suite. Because Railwail proxies the upstream OpenAI API directly when you call OpenAI model IDs, streaming SSE chunks, function/tool-call deltas, vision messages with image_url, and the response_format JSON mode all behave identically.
Step 4 โ Try a Non-OpenAI Model
This is where the migration starts paying off. With the same SDK and the same client object, you can route a request to Claude or Gemini just by changing the model string. There is no second SDK to install, no second API key, no separate billing.
// Same client, different model
const claude = await openai.chat.completions.create({
model: "claude-sonnet-4-6",
messages: [{ role: "user", content: "Hello from Claude" }],
});
const gemini = await openai.chat.completions.create({
model: "gemini-2.5-pro",
messages: [{ role: "user", content: "Hello from Gemini" }],
});API Endpoint Mapping
Model ID Mapping
You only need to change the model string if you want to try a different provider โ and even then, you can keep the OpenAI SDK.
Why Railwail Over OpenAI Direct
- 200+ models behind one API key โ Claude, Gemini, DeepSeek, Flux
- Single SDK โ keep the OpenAI client your team already knows
- Built-in playground at railwail.com/models โ test any model before shipping
- Spend caps and per-key rate limits to prevent runaway bills
- Transparent per-token pricing โ no minimum monthly fees, no enterprise gating
FAQ
Do I need to change my code at all?
Only two values: the API key and the base URL. Everything else โ message format, streaming, tool calling, vision, JSON mode, retries, error codes โ is identical because Railwail implements the same OpenAI Chat Completions schema.
Will my OpenAI prompts still work the same way?
Yes. When you call an OpenAI model ID through Railwail, the request is forwarded to OpenAI's upstream API.
What about Assistants, Threads, and the OpenAI Files API?
The Assistants API is OpenAI-proprietary state management. Railwail supports the stateless Chat Completions surface โ which is what 95% of production apps use. For Assistants-style workflows, we recommend porting to the Chat Completions schema (it is simpler and more portable).
How do I handle billing during the migration?
Run both providers in parallel for a week. Send 10% of traffic to Railwail via a feature flag, verify output quality and latency, then ramp to 100%. Railwail bills in USD credits with itemized per-model usage so you can compare costs line-by-line.
Can I use OpenAI fine-tuned models through Railwail?
Custom OpenAI fine-tunes (ft:gpt-4o-mini:...) require your OpenAI account because the weights live in OpenAI's tenancy. You can keep calling them via the OpenAI SDK with the OpenAI base URL while routing everything else through Railwail in the same codebase.
Is there a rate limit on Railwail?
Default is 600 requests per minute per API key, configurable from 60 to 6,000 RPM when you create a key. There is no daily token cap โ you only stop hitting the API when your credit balance hits zero (or your monthly spend cap, if you have set one).
What if my data must never leave the EU?
Railwail does not offer EU data residency; the models run at the providers, mostly in the US.
Next Steps
- Create your free account at railwail.com
- Generate an API key in Dashboard โ API Keys
- Change two values in your code: baseURL and apiKey
- Read the full API reference at railwail.com/docs
- Browse all 200+ available models at railwail.com/models
- Compare per-token pricing at railwail.com/pricing
- Check the provider catalog at railwail.com/providers
Models in this article
Live prices from Railwail's current rules, October 7, 2026.
- GPT-4oOpenAI$3.00 / 1M input tokens$12.00/1M out1K in + 500 out tokens: โ $0.0090Try
- Claude Sonnet 4.6Anthropic$3.60 / 1M input tokens$18.00/1M out1K in + 500 out tokens: โ $0.0126Try
- Gemini 2.5 ProGoogle DeepMind$1.50 / 1M input tokens$12.00/1M out1K in + 500 out tokens: โ $0.0075Try
- GPT-4o MiniOpenAI$0.18 / 1M input tokens$0.72/1M out1K in + 500 out tokens: โ $0.00060Try
- WhisperOpenAIโ $0.0034 per runTry
- $0.024 / 1M input tokens1K in + 500 out tokens: โ $0.00010Try
โ billed by actual tokens or GPU time
Next step
Try GPT-4o on Railwail
Sign in with Google for 10 free credits (usable 24 hours after sign-up, runs up to 2 credits), or top up from $5.00. Unused balance does not expire.