TL;DR ā Switch in Under 5 Minutes
- Perplexity API is OpenAI-compatible ā change baseURL only
- Sonar Small, Sonar Pro, Sonar Reasoning Pro all mirrored
- Live web search via the search_recency_filter and return_citations params
- EU-hosted, EUR billing
- Plus 270+ other models on the same key (Claude, GPT-4o, Gemini, Llama)
Why Move Off Perplexity API?
Perplexity API is the de facto standard for LLMs with built-in web search grounding. The trade-offs: US-only hosting, USD billing, narrow catalog (only Sonar family), and no closed-source frontier model access. Railwail mirrors Sonar via the same OpenAI-compatible schema and adds 270+ other models behind one key.
Step 1 ā Get a Railwail API Key
Sign up at railwail.com and generate a key.
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 Base URL
TypeScript / JavaScript
Before (Perplexity):
import OpenAI from "openai";
const pplx = new OpenAI({
apiKey: process.env.PERPLEXITY_API_KEY,
baseURL: "https://api.perplexity.ai",
});
const res = await pplx.chat.completions.create({
model: "sonar-pro",
messages: [{ role: "user", content: "What happened in AI this week?" }],
});After (Railwail):import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.RAILWAIL_API_KEY,
baseURL: "https://api.railwail.com/v1",
});
const res = await client.chat.completions.create({
model: "perplexity-sonar-pro",
messages: [{ role: "user", content: "What happened in AI this week?" }],
});
console.log(res.choices[0].message.content);
console.log(res.citations);The search_recency_filter, return_citations, return_images, and search_domain_filter parameters all work as extension params.Python with citations
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="perplexity-sonar-pro",
messages=[{"role": "user", "content": "Latest GPT-4o benchmark scores"}],
extra_body={
"search_recency_filter": "week",
"return_citations": True,
},
)
print(resp.choices[0].message.content)
for cite in resp.citations:
print(cite)cURL
curl https://api.railwail.com/v1/chat/completions \
-H "Authorization: Bearer $RAILWAIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "perplexity-sonar-pro",
"messages": [{"role": "user", "content": "Latest AI news"}],
"search_recency_filter": "week",
"return_citations": true
}'API Endpoint Mapping
Perplexity endpoint ā Railwail equivalent
| Perplexity | Railwail | Notes |
|---|---|---|
| POST /chat/completions | POST /v1/chat/completions | Identical schema |
| GET /models (undocumented) | GET /v1/models?provider=perplexity | List Sonar models |
Model Mapping
Perplexity model ā Railwail
| Perplexity | Railwail | Notes |
|---|---|---|
| sonar | perplexity-sonar | Base |
| sonar-pro | perplexity-sonar-pro | Higher quality |
| sonar-reasoning | perplexity-sonar-reasoning | With reasoning |
| sonar-reasoning-pro | perplexity-sonar-reasoning-pro | Frontier reasoning + search |
| sonar-deep-research | perplexity-sonar-deep-research | Long-form research |
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.
Pricing Comparison (per 1M tokens + per search, May 2026)
Same Sonar model, Railwail in EUR
| Model | Perplexity (USD) | Railwail (EUR) | Notes |
|---|---|---|---|
| sonar input | $1.00 | EUR 0.92 | Identical |
| sonar output | $1.00 | EUR 0.92 | Identical |
| sonar-pro input | $3.00 | EUR 2.76 | Identical |
| sonar-pro output | $15.00 | EUR 13.80 | Identical |
| sonar-reasoning-pro input | $2.00 | EUR 1.84 | Identical |
| sonar-reasoning-pro output | $8.00 | EUR 7.36 | Identical |
| Per 1000 searches (sonar-pro) | $5.00 | EUR 4.60 | Search costs preserved |
Why Railwail Over Perplexity Direct
- EU hosting with EUR billing
- Same Sonar models with full citation and search features
- Adds Claude, GPT-4o, Gemini for everything that does not need live search
- Same OpenAI-compatible API surface
- Built-in playground for cross-model testing
- Single VAT invoice covering grounded search + standard LLM workloads
FAQ
Are citations returned the same way?
Yes. The citations array on the response is preserved, with title, url, and snippet for each cited source.
Can I control the search domain or recency?
Yes. search_domain_filter, search_recency_filter (day/week/month/year), and return_images all work as extension parameters.
What about the related_questions feature?
Pass return_related_questions: true to get a related_questions array in the response.
Is the structured-output / JSON mode supported?
Yes. response_format with json_schema works on sonar-pro.
Does Perplexity's Spaces / Threads concept have an equivalent?
Perplexity Spaces is the consumer product, not the API. Railwail is API-only ā for stateful multi-turn flows, manage the conversation history client-side.
Sponsored
Pay Only for What You Use
Transparent per-token pricing with no monthly minimums. Start with free credits and scale as you grow.
Next Steps
- Sign up at railwail.com
- Generate an API key
- Update baseURL to https://api.railwail.com/v1
- Prefix Sonar model slugs with perplexity-
- Read the reference at railwail.com/docs
- Compare pricing at railwail.com/pricing