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 275+ models from Anthropic, Google, Mistral, DeepSeek and more behind the same SDK
- EU-hosted, EUR-billed, GDPR-friendly โ no transatlantic data transfer required
Why Move Off OpenAI Direct?
OpenAI's API is excellent โ but it locks you into a single vendor, USD billing, and US-only inference regions. When GPT-4o costs spike or a competitor releases a better model, you cannot switch without rewriting integration code. Railwail solves this by exposing every major frontier model 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 three concrete reasons: EU data residency (inference and request logs stay inside Frankfurt), EUR-denominated invoices (no FX surprises on monthly bills), and the ability to test Claude, Gemini, Llama, DeepSeek and 270 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- and look like rw-live-xxxxxxxxxxxxxxxxxxxxxxxx. The free tier includes test credits so you can validate the migration without paying anything.
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.
Sponsored
Access 100+ AI Models with One API Key
GPT-4o, Claude, Gemini, Llama, Flux, DALL-E and more โ all through a single, OpenAI-compatible endpoint. No more juggling multiple providers.
Step 2 โ Change the Base URL
TypeScript / JavaScript
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://api.railwail.com/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.Python
from openai import OpenAI
client = OpenAI(
api_key=os.environ["RAILWAIL_API_KEY"],
base_url="https://api.railwail.com/v1",
)
resp = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)cURL
curl https://api.railwail.com/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. You can paste your existing OpenAI cookbook recipes verbatim.
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" }],
});Sponsored
Test Any AI Model Instantly
Our built-in playground lets you compare models side by side. Find the perfect model for your use case in minutes, not days.
API Endpoint Mapping
OpenAI endpoint โ Railwail endpoint
| OpenAI direct | Railwail equivalent | Notes |
|---|---|---|
| POST /v1/chat/completions | POST /v1/chat/completions | Identical schema |
| POST /v1/completions (legacy) | POST /v1/completions | Supported for backward compatibility |
| POST /v1/embeddings | POST /v1/embeddings | Same request shape; also supports Cohere and Voyage embeddings via the model field |
| POST /v1/images/generations | POST /v1/images/generations | Routes DALL-E 3 plus Flux, SDXL, Stable Diffusion 3 via model param |
| POST /v1/audio/transcriptions | POST /v1/audio/transcriptions | Whisper plus Deepgram via model param |
| POST /v1/audio/speech | POST /v1/audio/speech | OpenAI TTS plus ElevenLabs voices via model param |
| GET /v1/models | GET /v1/models | Returns all 275+ Railwail models, OpenAI-format response |
Model ID Mapping
OpenAI model IDs are passed through unchanged. 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.
OpenAI model โ Railwail model ID
| OpenAI | Railwail (drop-in) | Equivalent non-OpenAI alternative |
|---|---|---|
| gpt-4o | gpt-4o | claude-sonnet-4-6 or gemini-2.5-pro |
| gpt-4o-mini | gpt-4o-mini | claude-haiku-4-6 or gemini-2.5-flash |
| gpt-4-turbo | gpt-4-turbo | claude-opus-4-6 |
| o1-preview / o1-mini | o1-preview / o1-mini | deepseek-r1 (open-weight reasoning) |
| text-embedding-3-small | text-embedding-3-small | voyage-3 or cohere-embed-v4 |
| dall-e-3 | dall-e-3 | flux-pro-1.1 or stable-diffusion-3.5 |
| whisper-1 | whisper-1 | deepgram-nova-3 |
| tts-1 / tts-1-hd | tts-1 / tts-1-hd | eleven-multilingual-v3 |
Pricing Comparison (per 1M tokens, May 2026)
Same model, both platforms โ Railwail prices in EUR
| Model | OpenAI direct (USD) | Railwail (EUR) | Notes |
|---|---|---|---|
| gpt-4o input | $2.50 | EUR 2.30 | Same upstream model, no markup beyond FX |
| gpt-4o output | $10.00 | EUR 9.20 | Same |
| gpt-4o-mini input | $0.15 | EUR 0.14 | Same |
| gpt-4o-mini output | $0.60 | EUR 0.55 | Same |
| o1-preview input | $15.00 | EUR 13.80 | Same |
| text-embedding-3-small | $0.02 | EUR 0.018 | Same |
| dall-e-3 1024x1024 | $0.04 / image | EUR 0.037 / image | Same |
Railwail prices in EUR with a transparent FX pass-through and no per-request markup on OpenAI models. Your monthly invoice arrives in EUR, with VAT correctly applied for EU customers โ no manual currency conversion or reverse-charge paperwork.
Sponsored
Pay Only for What You Use
Transparent per-token pricing with no monthly minimums. Start with free credits and scale as you grow.
Why Railwail Over OpenAI Direct
- EU hosting โ Frankfurt-region inference and request logs, GDPR-compliant data residency
- EUR billing with VAT receipts โ no FX surprises, no reverse-charge friction
- 275+ models behind one API key โ Claude, Gemini, Mistral, Llama, DeepSeek, Flux, ElevenLabs
- 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 with no modification. Output is byte-for-byte equivalent to calling OpenAI directly.
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). The Files API for vision and audio inputs is supported.
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 monthly in EUR 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 up to 10,000 RPM in the dashboard. 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 tags each model with its hosting region. EU-only models include Mistral, Llama-via-Hetzner, and a subset of GPT-4o served from Microsoft's EU Azure deployment. Filter the catalog at railwail.com/models?region=eu to see only EU-resident options.
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 275+ available models at railwail.com/models
- Compare per-token pricing at railwail.com/pricing
- Check the provider catalog at railwail.com/providers