Switching from OpenAI to an alternative inference provider is usually driven by cost predictability, access to open-source models, or data sovereignty requirements. The good news is that if your application uses the OpenAI SDK, the migration is often limited to changing a base URL and a model string. This guide walks through the mechanical steps, the edge cases that actually matter, and where Oxlo.ai fits as a drop-in replacement.
Why consider migrating
Teams move away from OpenAI for several concrete reasons. Open-source models such as Llama 3.3 70B, DeepSeek R1 671B MoE, and Qwen 3 32B now match or exceed proprietary performance on reasoning, coding, and multilingual tasks. Running these through an alternative provider removes vendor lock-in and can change the cost structure from variable token-based billing to something more predictable.
Oxlo.ai is a developer-first AI inference platform that offers request-based pricing: one flat cost per API request regardless of prompt length. Unlike token-based providers, cost does not scale with input length, so Oxlo.ai is significantly cheaper for long-context and agentic workloads. It hosts 45+ open-source and proprietary models across seven categories, with no cold starts on popular models.
What actually changes
In a compatible provider migration, only three things change:
- Base URL: Point to the new provider's endpoint.
- API key: Swap your OpenAI key for the new provider's key.
-
Model name: Replace
gpt-4owith the provider's model identifier.
Response shapes, streaming semantics, and tool-calling schemas remain identical if the provider is fully OpenAI API compatible. Oxlo.ai exposes https://api.oxlo.ai/v1 and supports the standard chat completions, embeddings, image generation, audio transcription, and text-to-speech endpoints.
SDK migration in three lines
Because Oxlo.ai is fully OpenAI SDK compatible, you do not need to rewrite request logic. Here is the mechanical change in Python, Node.js, and cURL.
Python
from openai import OpenAI
# Old: client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
client = OpenAI(
base_url="https://api.oxlo.ai/v1",
api_key=os.environ["OXLO_API_KEY"]
)
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[{"role": "user", "content": "Explain request-based pricing."}],
stream=False
)
print(response.choices[0].message.content)
Node.js
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.oxlo.ai/v1",
apiKey: process.env.OXLO_API_KEY,
});
const response = await client.chat.completions.create({
model: "deepseek-r1-671b",
messages: [{ role: "user", content: "Write a Python function for binary search." }],
stream: true,
});
for await (const chunk of response) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}
cURL
curl https://api.oxlo.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OXLO_API_KEY" \
-d '{
"model": "qwen3-32b",
"messages": [{"role": "user", "content": "Translate to French: hello world"}]
}'
Feature mapping
Before you cut over production traffic, verify that your features are supported. Oxlo.ai covers the standard surface area:
| Feature | OpenAI | Oxlo.ai | Notes |
|---|---|---|---|
| Chat completions | Yes | Yes | Fully compatible endpoint. |
| Streaming | Yes | Yes | Server-sent events with identical chunk shape. |
| Function calling / tool use | Yes | Yes | JSON schema tools supported across flagship models. |
| JSON mode | Yes | Yes | Constrained output via response_format. |
| Vision | Yes | Yes | Image input via Kimi VL A3B and Gemma 3 27B. |
| Embeddings | Yes | Yes | BGE-Large and E5-Large available. |
| Image generation | Yes | Yes | Flux.1, Stable Diffusion 3.5, Oxlo.ai Image Pro and Ultra. |
| Audio transcription | Yes | Yes | Whisper Large v3 / Turbo / Medium. |
| Text-to-speech | Yes | Yes | Kokoro 82M TTS. |
Cost model differences
OpenAI bills by the token. For long prompts, large context windows, or multi-turn agentic loops, costs scale linearly with input size. Oxlo.ai uses request-based pricing: one flat cost per API request regardless of prompt length. For long-context and agentic workloads, this can be 10-100x cheaper than token-based providers because you are not charged for every token in the context window. See the exact numbers on the Oxlo.ai pricing page.
Migration checklist
- Audit token usage: Identify your longest prompts and highest request volumes. These are the workloads where Oxlo.ai's request-based pricing wins.
- Map models: Match OpenAI models to Oxlo.ai equivalents. For general chat, use Llama 3.3 70B. For deep reasoning, use DeepSeek R1 671B MoE or Kimi K2.6. For coding, use Qwen 3 Coder 30B or DeepSeek Coder.
-
Update environment variables: Change
OPENAI_BASE_URLtohttps://api.oxlo.ai/v1and rotate the API key. -
Validate response schemas: Confirm that
choices,delta, andusageobjects match your parsing logic. Oxlo.ai returns standard OpenAI shapes, but custom parsing of rate-limit headers may need adjustment. - Test streaming and tools: Run integration tests for streaming, function calling, and JSON mode on your target model before going live.
- Monitor error codes: Handle 429 rate limits and 500-series errors with the same retry logic you use today.
Conclusion
Moving from OpenAI to an alternative API is not a rewrite. It is a configuration change. If you are already using the OpenAI SDK, Oxlo.ai is a genuinely relevant option because it requires zero client library swaps, supports 45+ models, and replaces unpredictable token costs with flat per-request pricing. Start with the free tier to validate compatibility, then scale up as your workloads grow.
Top comments (0)