GoodPut AI

OpenAI 兼容 API

Chat Completions 与 Responses 端点、参数与响应结构。

Chat Completions

端点为 POST /v1/chat/completions,语义与 OpenAI 官方一致。鉴权使用 Authorization: Bearer <API Key>

from openai import OpenAI

client = OpenAI(
    base_url="https://api.goodputai.cn/v1",
    api_key="你的 GoodPut API Key",
)

resp = client.chat.completions.create(
    model="deepseek/deepseek-v4-pro",
    messages=[{"role": "user", "content": "你好"}],
)

支持的参数

参数说明
model必填,模型库中的模型 ID
messages必填,支持 system / user / assistant / tool 角色
stream / stream_options流式输出,见流式输出
tools / tool_choice工具调用,见工具调用
response_format结构化输出,见结构化输出
max_tokens / max_completion_tokens输出上限(含推理 token)
temperature / top_p / stop采样与停止控制
fallbacks平台扩展:备用模型列表,见平台概念

上游模型不支持的参数会被网关安全忽略,不会导致请求失败。

响应结构

与 OpenAI 一致。推理模型会额外返回思考过程与 token 细分:

{
  "choices": [{
    "message": {
      "role": "assistant",
      "content": "ok",
      "reasoning_content": "用户要求只回复 ok……"
    }
  }],
  "usage": {
    "prompt_tokens": 17,
    "completion_tokens": 25,
    "total_tokens": 42,
    "completion_tokens_details": {"reasoning_tokens": 22, "text_tokens": 3},
    "prompt_tokens_details": {"cached_tokens": 0}
  }
}
  • message.reasoning_content:推理模型的思考过程(详见推理模型
  • usage.completion_tokens_details.reasoning_tokens:推理 token 数,计入输出计费
  • usage.prompt_tokens_details.cached_tokens:缓存命中 token 数,按缓存读取价计费(详见提示词缓存

Responses API

端点为 POST /v1/responses,兼容 OpenAI Responses 协议,平台全部模型可用:

resp = client.responses.create(
    model="z-ai/glm-5.2",
    input="用一句话介绍你自己",
)
print(resp.output_text)

推理模型的思考过程会以 type: "reasoning" 的 output 项返回(流式为 reasoning_summary_text.delta 事件)。max_output_tokens 包含思考 token——推理模型建议设 512 以上,过小会导致 status: "incomplete" 且正文为空。

其他端点

端点说明
GET /v1/models当前 Key 可用的模型列表
POST /v1/completions传统文本补全(兼容保留,新集成请用 Chat Completions)
POST /v1/videos提交视频生成任务(异步),见视频生成
GET /v1/videos/{video_id}查询视频任务状态
GET /v1/videos/{video_id}/content下载生成的视频

注意事项

  • 模型不存在或未开通时返回 404(code: model_not_found),见错误码与限流
  • 单请求默认超时 300 秒起,长任务建议开启流式

本页目录