兼容 OpenAI API 格式,现有程序无需修改即可迁移。
同时支持 Anthropic 的 Claude 直接调用,
接口只需替换为 api.xuansuan.top
提供行业极具竞争力的价格,
帮助开发者与企业大幅降低AI调用成本。
高可用性保证业务运行高效流畅
# 导入OpenAI客户端
import openai
# 修改基础URL指向玄算
openai.api_base = "https://api.xuansuan.top/v1"
openai.api_key = "your_api_key"
# 使用完全相同的Python代码调用
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user",
"content": "你好"}]
)
print(response.choices[0].message.content)
# 直接连接Claude
import anthropic
# 修改基础URL
client = anthropic.Client(
api_key="your_api_key",
base_url="https://api.xuansuan.top"
)
# 使用相同API调用方式
response = client.messages.create(
model="claude-3-opus",
messages=[{"role": "user",
"content": "你好"}],
max_tokens=512
)
print(response.content[0].text)