API 参考

BigDogAI API 完全兼容 OpenAI 格式,可使用现有 SDK 直接调用。

Base URL

https://dashuaigou.cn/v1
URL

认证

所有请求需在 Header 中携带 API Key:

Authorization: Bearer sk-your-api-key
Header

Chat Completions

核心接口
POST /v1/chat/completions

参数

参数类型必填说明
modelstring必填模型 ID,如 qwen-turbo、qwen-plus
messagesarray必填消息列表,每条包含 role 和 content
temperaturenumber可选随机性 0-2,默认 1
max_tokensinteger可选最大输出 token 数
top_pnumber可选核采样参数
streamboolean可选是否流式输出
toolsarray可选Function Calling 工具定义
tool_choicestring可选工具调用策略:auto/none/required
response_formatobject可选JSON Mode 配置

请求示例

response = client.chat.completions.create(
    model="qwen-turbo",
    messages=[
        {"role": "system", "content": "你是专业助手"},
        {"role": "user", "content": "解释什么是API网关"}
    ],
    temperature=0.7,
    max_tokens=1000
)
Python

流式输出

设置 stream=True 可启用流式响应:

response = client.chat.completions.create(
    model="qwen-turbo",
    messages=[{"role": "user", "content": "写一首诗"}],
    stream=True
)

for chunk in response:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
Python

Function Calling

高级功能

支持 OpenAI 兼容的 Function Calling 格式:

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "获取指定城市的天气",
            "parameters": {
                "type": "object",
                "properties": {
                    "city": {"type": "string", "description": "城市名称"}
                },
                "required": ["city"]
            }
        }
    }
]

response = client.chat.completions.create(
    model="qwen-plus",
    messages=[{"role": "user", "content": "北京今天天气怎么样?"}],
    tools=tools,
    tool_choice="auto"
)
Python

JSON Mode

强制输出 JSON 格式:

response = client.chat.completions.create(
    model="qwen-plus",
    messages=[
        {"role": "system", "content": "请以JSON格式输出"},
        {"role": "user", "content": "列出3个编程语言及其特点"}
    ],
    response_format={"type": "json_object"}
)
Python

模型列表

GET /v1/models
curl https://dashuaigou.cn/v1/models   -H "Authorization: Bearer sk-your-api-key"
bash

错误码

状态码错误码说明
400invalid_request_error请求参数错误
401invalid_api_keyAPI Key 无效
429rate_limit_exceeded请求过于频繁
500server_error服务器内部错误

Cookie 设置

我们使用Cookie来提供更好的服务体验

必要 Cookie

登录状态、安全功能、基本服务运行

必选

分析 Cookie

百度统计、Sentry - 用于改进服务体验

可选

营销 Cookie

暂未启用,功能预留

暂无
查看隐私政策