bash
# Install the OpenAI SDK (YiAI Router is 100% compatible)
pip install openai
# Set your API key
export YIAI_API_KEY="sk-your-key-here"01
Create Account
Register and generate your API key in seconds.
02
Set Base URL
Point your SDK to https://api.yi-ai.cn/v1
03
Call Any Model
Use any OpenAI SDK with no application-code rewrite.
Endpoint Reference
POST
/chat/completionsChat completions with streaming supportPOST
/completionsLegacy text completionsGET
/modelsList all available modelsPOST
/images/generationsImage generationPOST
/audio/transcriptionsSpeech to textPOST
/audio/speechText to speechPOST
/embeddingsText embeddings