Guide
Migrate from OpenAI in 3 lines
Rhodes speaks the OpenAI chat completions API. Point your existing SDK at our base URL, swap the API key, and prefix model names with rhodes/. Streaming, function calling, and error handling all work the same.
Three changes
Set baseURL
Add the baseURL parameter to your OpenAI client constructor. Point it at https://api.rhodes.ai/v1. Everything else stays the same.
const client = new OpenAI({
baseURL: 'https://api.rhodes.ai/v1',
apiKey: process.env.OPENAI_API_KEY,
}); Replace API key
Generate a Rhodes API key at app.rhodes.ai. Replace your OpenAI key with it. The key is shown once โ save it in your environment or secrets manager.
# Before
OPENAI_API_KEY=sk-proj-abc123...
# After
RHODES_KEY=sk-rhodes-def456... Prefix model name
Add rhodes/ to the front of your model name. gpt-4 becomes rhodes/gpt-4. This tells the gateway which upstream provider to route to.
model: 'rhodes/gpt-4' // was 'gpt-4' Full example
Before (OpenAI direct)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
const completion = await client.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello' }],
}); After (Rhodes routing)
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.rhodes.ai/v1', // ๐ Add this
apiKey: process.env.RHODES_KEY, // ๐ Change this
});
const completion = await client.chat.completions.create({
model: 'rhodes/gpt-4', // ๐ Prefix with rhodes/
messages: [{ role: 'user', content: 'Hello' }],
});
The response object is identical. If your code parses completion.choices[0].message.content, it still works. Error handling, streaming chunks, and function calls all follow the same shape.
What stays the same
SDK
No Rhodes-specific library. Use the official openai package, same version.
Request format
Messages array, temperature, max_tokens, top_p โ all parameters work as documented.
Response shape
Same JSON structure. id, object, created, model, choices, usage โ nothing moves.
Streaming
Set stream: true. Server-sent events arrive in the same format, same delta shape.
Function calling
Tools parameter passes through. GPT-4/Claude/Gemini handle tool calls identically.
Error codes
400 for bad input, 401 for invalid key, 402 when balance is zero, 429 on rate limit.
Frequently asked questions
Do I need to change my SDK?
No. Rhodes speaks the OpenAI chat completions API. The official openai package, LangChain, LlamaIndex, and any other library that supports OpenAI-compatible endpoints work without modification.
Does streaming still work?
Yes. Set stream: true in the request. The same server-sent event format is returned. Your existing streaming handlers do not need to change.
What about function calling?
Function calling (tool use) passes through unchanged for models that support it. GPT-4, Claude, and Gemini all handle tools the same way through Rhodes as they do direct.
Can I keep some requests on OpenAI direct?
Yes. Create two client instances with different base URLs. Route some calls through Rhodes, others direct to OpenAI. Useful during a gradual migration or A/B test.
Is there a cost to migrate?
The migration itself is free. You pay Rhodes usage rates, which are typically 10-15% cheaper than OpenAI list for GPT-4 and comparable for GPT-4o. Check /pricing for current rates.
Migrate your first request
Get a Rhodes API key and change three lines. Test it with a single request before switching production traffic.