Migration from OpenAI
Switch from the OpenAI API to SoxAI with minimal code changes
Migration from OpenAI
SoxAI is fully OpenAI-compatible. Most applications require only two changes to migrate.
Two-Line Migration
Python
# Before
from openai import OpenAI
client = OpenAI(api_key="sk-...")
# After
from openai import OpenAI
client = OpenAI(
api_key="sox-...",
base_url="https://api.soxai.io/v1",
)Node.js
// Before
const client = new OpenAI({ apiKey: "sk-..." });
// After
const client = new OpenAI({
apiKey: "sox-...",
baseURL: "https://api.soxai.io/v1",
});Environment Variables
If your application reads from environment variables, update them:
# Before
OPENAI_API_KEY=sk-...
# After
OPENAI_API_KEY=sox-...
OPENAI_BASE_URL=https://api.soxai.io/v1The OpenAI SDK respects OPENAI_BASE_URL automatically — no code change needed.
Compatibility Notes
| Feature | Supported | Notes |
|---|---|---|
| Chat Completions | Yes | Full compatibility |
| Streaming | Yes | Full SSE compatibility |
| Function/Tool Calling | Yes | Full compatibility |
| Embeddings | Yes | Full compatibility |
| Image Generation | Yes | DALL-E 2 and 3 |
| Completions (legacy) | Yes | Full compatibility |
| Audio (Whisper, TTS) | Partial | Check model availability |
| Fine-tuning | No | Not supported |
| Assistants API | No | Use chat completions with your own state management |
| Batch API | No | Submit individual requests |
Testing Your Migration
Run your existing test suite against the SoxAI endpoint. If you do not have a test suite, verify manually:
import os
from openai import OpenAI
# Test with SoxAI
client = OpenAI(
api_key=os.environ["SOXAI_API_KEY"],
base_url="https://api.soxai.io/v1",
)
response = client.chat.completions.create(
model="gpt-5.4-mini",
messages=[{"role": "user", "content": "Say 'migration successful'"}],
max_tokens=10,
)
print(response.choices[0].message.content)
# Expected: "migration successful" or similarModel Name Mapping
SoxAI uses the same model IDs as OpenAI for OpenAI models. You do not need to change model names.
If you want to use non-OpenAI models, just change the model parameter:
# Use Anthropic's Claude via the same client
response = client.chat.completions.create(
model="claude-sonnet-4-6", # Anthropic model
messages=[{"role": "user", "content": "Hello!"}],
)Cost Comparison
After migrating, review your usage in the SoxAI Console under Dashboard → Usage. Compare against your previous OpenAI bill to verify costs are as expected.
Rollback Plan
Keep your original OpenAI API key available. To roll back, revert the base_url and api_key changes. The migration has no irreversible steps.