Blog

Engineering updates and practical guides

All posts
Tutorials

Use RoutePlex with the OpenAI SDK

How to access 22+ AI models through the familiar OpenAI SDK — just change the base URL.

RoutePlex Team
February 3, 20262 min read
Use RoutePlex with the OpenAI SDK

Use RoutePlex with the OpenAI SDK

You don't need a new SDK to use RoutePlex. If you already use the OpenAI SDK, you can access all 22+ models — including Claude, Gemini, and more — by changing a single line of code.

How It Works

RoutePlex implements the OpenAI Chat Completions API specification. This means any tool, library, or framework that speaks the OpenAI protocol works with RoutePlex out of the box.

Python

from openai import OpenAI

client = OpenAI(
    base_url="https://api.routeplex.com/api/v1",
    api_key="rpx_your_api_key"
)

response = client.chat.completions.create(
    model="routeplex-ai",  # or "anthropic/claude-sonnet-4", "google/gemini-2.5-flash", etc.
    messages=[
        {"role": "user", "content": "Hello from RoutePlex!"}
    ]
)

TypeScript / JavaScript

import OpenAI from "openai";

const client = new OpenAI({
    baseURL: "https://api.routeplex.com/api/v1",
    apiKey: "rpx_your_api_key"
});

const response = await client.chat.completions.create({
    model: "routeplex-ai",
    messages: [
        { role: "user", content: "Hello from RoutePlex!" }
    ]
});

cURL

curl https://api.routeplex.com/api/v1/chat/completions \
  -H "Authorization: Bearer rpx_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "routeplex-ai",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

What You Get

By switching to RoutePlex, your existing OpenAI integration instantly gains:

  • 22+ models from OpenAI, Anthropic, and Google
  • Automatic failover across providers
  • Intelligent routing with routeplex-ai
  • Unified billing across all models
  • Real-time cost tracking per request
  • Web search & URL fetching auto-detected from your prompts
  • Content moderation built-in on every request

Try It Now

  1. Sign up for free
  2. Get your API key from the dashboard
  3. Replace your base URL
  4. Done.

Same code. More models. Better reliability.