SDK Integration
Applies to: Developers Updated: 2026-07-02
CloudRouter is compatible with the official OpenAI and Anthropic SDKs. No need to change your SDK — just change two lines of config (Base URL + API Key) to switch existing code over to CloudRouter.
The API address is
https://api.cloudrouter.online, with route prefix/v1, and authentication viaAuthorization: Bearer sk-xxx.
1. OpenAI Python SDK
The most common integration method. If you already have OpenAI code, change two lines:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY", # ← change to your CloudRouter Key
base_url="https://api.cloudrouter.online/v1" # ← add this line
)
resp = client.chat.completions.create(
model="claude-sonnet-4-6",
messages=[{"role": "user", "content": "Hello"}]
)
print(resp.choices[0].message.content)Install: pip install openai
2. OpenAI Node.js SDK
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.cloudrouter.online/v1",
});
const resp = await client.chat.completions.create({
model: "claude-sonnet-4-6",
messages: [{ role: "user", content: "Hello" }],
});
console.log(resp.choices[0].message.content);Install: npm install openai
3. Anthropic SDK
If you use Claude's native SDK, change base_url to point at CloudRouter:
from anthropic import Anthropic
client = Anthropic(
api_key="YOUR_API_KEY",
base_url="https://api.cloudrouter.online"
)
resp = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}]
)
print(resp.content[0].text)Install: pip install anthropic
The Anthropic SDK uses the
/v1/messagesendpoint, wheremax_tokensis a required parameter.
4. Other languages / general pattern
CloudRouter is a standard HTTP API; any language that can make HTTP requests can integrate.
Go
// Use the OpenAI-compatible endpoint, set a custom BaseURL
config := openai.DefaultConfig("YOUR_API_KEY")
config.BaseURL = "https://api.cloudrouter.online/v1"
client := openai.NewClientWithConfig(config)Generic curl (any environment)
curl https://api.cloudrouter.online/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"claude-sonnet-4-6","messages":[{"role":"user","content":"Hello"}]}'5. Integration checklist
When migrating to CloudRouter, confirm each item:
- [ ]
base_url/baseURLpoints at CloudRouter - [ ]
api_keyhas been changed to your CloudRouter Key (starts withsk-) - [ ] The
modelfield contains a call name copied from the console's "Call Guide" (bare name or with fingerprint, either works) - [ ] The target group / model is within your account's available range
- [ ] The rest of your business code requires no changes
For the difference between the bare-name and with-fingerprint forms of the
modelfield, see Call Guide & Dual Routing.
Next steps
- Figure out how to write the
modelfield → Call Guide & Dual Routing - Connect Claude Code / Cursor / frameworks → Third-party Tool Integration
- Handle errors → Errors & Troubleshooting
Contact us
- Email: support_cloudrouter@clouditera.com
- QQ group: 712273971
- Platform: cloudrouter.online