Migrate from Perplexity API to Railwail
Migration Guides

Migrate from Perplexity API to Railwail

Switch from Perplexity API to Railwail. Same Sonar models with live web search, OpenAI-compatible API, EU hosting, EUR billing, 275+ models on one key.

Railwail TeamĀ· Developer Relations7 min readMay 16, 2026

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

PerplexityRailwailNotes
POST /chat/completionsPOST /v1/chat/completionsIdentical schema
GET /models (undocumented)GET /v1/models?provider=perplexityList Sonar models

Model Mapping

Perplexity model → Railwail

PerplexityRailwailNotes
sonarperplexity-sonarBase
sonar-properplexity-sonar-proHigher quality
sonar-reasoningperplexity-sonar-reasoningWith reasoning
sonar-reasoning-properplexity-sonar-reasoning-proFrontier reasoning + search
sonar-deep-researchperplexity-sonar-deep-researchLong-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

ModelPerplexity (USD)Railwail (EUR)Notes
sonar input$1.00EUR 0.92Identical
sonar output$1.00EUR 0.92Identical
sonar-pro input$3.00EUR 2.76Identical
sonar-pro output$15.00EUR 13.80Identical
sonar-reasoning-pro input$2.00EUR 1.84Identical
sonar-reasoning-pro output$8.00EUR 7.36Identical
Per 1000 searches (sonar-pro)$5.00EUR 4.60Search 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

Railwail Team

Developer Relations

The Railwail team writes integration guides for developers migrating from single-provider AI APIs to a unified multi-model platform.

Tags:
Perplexity
Migration
Sonar
Web Search
Grounded AI