Migration Guide
Migrate to Yunxin from OpenAI, Anthropic, or other API providers.
From OpenAI
Yunxin is fully compatible with the OpenAI API. Migration requires only two changes:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_YUNXIN_KEY", # Change API key
base_url="https://api.yuhuanstudio.com/v1" # Change base URL
)
# All existing code works as-is
response = client.chat.completions.create(
model="model-id",
messages=[{"role": "user", "content": "Hello!"}]
)What works immediately:
- Chat Completions
- Streaming
- Function calling
- Vision (multimodal)
- Embeddings
- Image generation
- Audio (TTS/STT)
- Video generation
- Music generation
- 3D generation
- Realtime API
- File operations
- Batch API
From Anthropic
Use the Anthropic Messages format directly:
from anthropic import Anthropic
client = Anthropic(
api_key="YOUR_YUNXIN_KEY",
base_url="https://api.yuhuanstudio.com/v1"
)
message = client.messages.create(
model="model-id",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}]
)Or use Anthropic models through the OpenAI-compatible endpoint:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_YUNXIN_KEY",
base_url="https://api.yuhuanstudio.com/v1"
)
response = client.chat.completions.create(
model="model-id",
messages=[{"role": "user", "content": "Hello!"}]
)From Other Providers
For any provider using OpenAI-compatible API, the migration is the same — change api_key and base_url.
Environment Variables
# Before (direct OpenAI)
export OPENAI_API_KEY="sk-..."
export OPENAI_BASE_URL="https://api.openai.com/v1"
# After (Yunxin)
export OPENAI_API_KEY="yx-..."
export OPENAI_BASE_URL="https://api.yuhuanstudio.com/v1"Key Benefits After Migration
| Feature | Direct Provider | Yunxin |
|---|---|---|
| API keys to manage | One per provider | One for all |
| Model switching | Code change per provider | Change model string only |
| Billing | Multiple bills | Unified billing |
| Monitoring | Per-provider dashboards | Single analytics dashboard |
| Failover | Manual | Automatic |
How is this guide?