Skip to main content

Migrating from OpenAI SDK

This guide will help you migrate your existing OpenAI SDK (Python or Node.js) integration to use the Phaseo Gateway instead.

Overview

Phaseo Gateway provides OpenAI-compatible endpoints, making migration straightforward. You’ll primarily need to:
  • Change the API base URL
  • Update your API key
  • Update authentication method (from api_key to Authorization: Bearer)

Prerequisites

  • A Phaseo account and API key (get one at Gateway Keys)
  • Existing OpenAI SDK code

Migration Steps

1. Update API Key and Base URL

Instead of using the OpenAI API key and default base URL, use your Phaseo credentials.
# Before (OpenAI)
curl https://api.openai.com/v1/chat/completions \
  -H "Authorization: Bearer sk-your-openai-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

# After (Phaseo)

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

import openai

# Before
client = openai.OpenAI(api_key="sk-your-openai-key")

# After
client = openai.OpenAI(
    api_key="your-phaseo-key",
    base_url="https://api.phaseo.ai/v1"
)

response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello!"}]
)
import OpenAI from "openai";

// Before
const client = new OpenAI({
	apiKey: "sk-your-openai-key",
});

// After
const client = new OpenAI({
	apiKey: "your-phaseo-key",
	baseURL: "https://api.phaseo.ai/v1",
});

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

3. Test Your Integration

Run your existing code with the updated configuration to ensure it works.

4. Handle Model Names

Phaseo supports a wide range of models. Check the models endpoint for available models and their names. Some model names may differ from OpenAI’s naming convention.

Common Issues

  • Model not found: Ensure the model name is available in Phaseo. Use the /models endpoint to list available models.
  • Rate limits: Phaseo may have different rate limits than OpenAI.
  • Features: Some OpenAI-specific features may not be available or work differently.

Next Steps

  • Explore Phaseo’ additional features like analytics and multi-provider routing.
  • Check out the API Reference for full documentation.
Last modified on July 9, 2026