Using OpenAI SDK to seamlessly switch to domestic large models

Why Choose the Compatible Solution?
OpenAI's Python SDK has become the de facto standard for AI development. However, using OpenAI directly faces two issues: network restrictions and model selection.
Ciyuano's compatible solution allows you to freely switch between multiple models without changing a single line of code.
Principle
All requests from the OpenAI SDK are sent to base_url:
# native OpenAI
client = OpenAI(api_key="sk-xxx")
# Ciyuano — Change just two lines!
client = OpenAI(
base_url="https://www.ciyuano.com/v1",
api_key="sk-relay-xxx"
)
The underlying protocols (REST API, SSE streaming, Chat Completions endpoint) are exactly the same.
Hands-on: Multi-Model Comparison Test
from openai import OpenAI
client = OpenAI(
base_url="https://www.ciyuano.com/v1",
api_key="sk-relay-your-key"
)
models = ["deepseek-v4", "glm-5", "qwen-plus"]
prompt = "Using Python Write a quicksort algorithm,with comments"
for model in models:
print(f"n=== {model} ===")
response = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": prompt}],
temperature=0.7,
max_tokens=1024
)
print(response.choices[0].message.content)
Framework Integration
LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="deepseek-v4",
openai_api_key="sk-relay-xxx",
openai_api_base="https://www.ciyuano.com/v1"
)
Vercel AI SDK
import { createOpenAI } from "@ai-sdk/openai";
const openai = createOpenAI({
baseURL: "https://www.ciyuano.com/v1",
apiKey: "sk-relay-xxx",
});
Dify / FastGPT / LobeChat
Add an OpenAI-compatible interface in "Model Providers", then fill in Ciyuano's base_url and api_key.
Best Practices
- Use the
automodel: Let the platform automatically select the best available model - Enable streaming output (
stream=True): Better user experience - Set
max_tokensreasonably: Control costs - Choose
qwen-plusif price matters, choosedeepseek-v4if quality matters
Summary
OpenAI SDK + Ciyuano = A unified entry point for any domestic large model. No code changes, no framework swaps, no hassle with keys.
Related Articles
AI 本地部署入门:零基础三步跑起大模型,完全免费
不用注册、不用充钱、完全离线。本文手把手教你用 Ollama 等工具,在自家电脑上部署运行开源大模型,从零开始完成本地 AI 部署的全过程。
TutorialsAI 帮你做购物决策:从比价到避坑的完整实操指南
买手机、买耳机、买电脑,AI 真的能帮你选对吗?本文用五个实操步骤,手把手教你让 AI 完成价格对比、参数解析、口碑筛选和避坑提醒,小白也能 10 分钟搞定购物决策。
TutorialsAI 语音输入与语音转文字:零基础 5 分钟上手,解放双手的写作新方式
打字太慢?说话比打字快 3 倍。这篇文章手把手教你用 AI 语音输入工具,从选择工具、开始录音到转文字、编辑导出,五大步骤、六大场景,让你从此"说话即写作"。
Comments are not yet available, stay tuned