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 AI Stats Gateway instead.

Overview

AI Stats 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

  • An AI Stats account and API key (get one at AI Stats Dashboard)
  • 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 AI Stats 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 (AI Stats)

curl https://api.phaseo.app/v1/chat/completions \
 -H "Authorization: Bearer your-ai-stats-key" \
 -H "Content-Type: application/json" \
 -d '{
"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

AI Stats 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 AI Stats. Use the /models endpoint to list available models.
  • Rate limits: AI Stats may have different rate limits than OpenAI.
  • Features: Some OpenAI-specific features may not be available or work differently.

Next Steps

  • Explore AI Stats’ additional features like analytics and multi-provider routing.
  • Check out the API Reference for full documentation.
Last modified on February 11, 2026