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 Speech to Text: Beginner's Guide to Convert Voice to Text in 3 Steps
Learn how to convert speech to text using AI tools. Perfect for meeting notes, content creation, and video subtitles. Three practical scenarios with step-by-step instructions.
TutorialsAI Local Deployment Guide: Run Large Models in 3 Steps for Free
Learn how to deploy AI models locally in just 3 steps. No coding experience needed, completely free, and your data stays private on your own computer.
TutorialsAI Shopping Decision Guide: From Price Comparison to Avoiding Pitfalls
Learn how to use AI for shopping decisions. From price comparison to avoiding pitfalls - make smarter purchasing choices with AI assistance.
Comments are not yet available, stay tuned