SDKs & Libraries
Use the Yunxin API with official and community SDKs.
Compatible SDKs
Yunxin is fully compatible with the OpenAI SDK — simply change the base URL and API key. No custom SDK needed.
Python (OpenAI SDK)
pip install openaifrom openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.yuhuanstudio.com/v1"
)
response = client.chat.completions.create(
model="model-id",
messages=[{"role": "user", "content": "Hello!"}]
)JavaScript / TypeScript (OpenAI SDK)
npm install openaiimport OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.yuhuanstudio.com/v1",
});
const response = await client.chat.completions.create({
model: "model-id",
messages: [{ role: "user", content: "Hello!" }],
});cURL
No installation needed — use cURL directly:
curl https://api.yuhuanstudio.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"model": "model-id", "messages": [{"role": "user", "content": "Hello!"}]}'Anthropic SDK (for Messages format)
If you prefer Anthropic's native message format:
from anthropic import Anthropic
client = Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.yuhuanstudio.com/v1"
)
message = client.messages.create(
model="model-id",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}]
)Environment Variables
We recommend using environment variables for all SDKs:
export YUNXIN_API_KEY="yx-your-key-here"
export YUNXIN_BASE_URL="https://api.yuhuanstudio.com/v1"import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["YUNXIN_API_KEY"],
base_url=os.environ["YUNXIN_BASE_URL"]
)How is this guide?