跳过至正文

状态码

端点会根据 HTTP 状态行中请求的成功或失败返回相应的 HTTP 状态码(例如 HTTP/1.1 200 OKHTTP/1.1 400 Bad Request)。常见的状态码有:
  • 200: 成功
  • 400: 错误请求(缺少参数、无效 JSON 等)
  • 404: 未找到(模型不存在等)
  • 429: 请求过多(例如超出速率限制时)
  • 500: 内部服务器错误
  • 502: 错误网关(例如无法访问云端模型时)

错误信息

错误以 application/json 格式返回,结构如下,错误信息包含在 error 属性中:
{
  "error": "the model failed to generate a response"
}

流式传输过程中发生的错误

如果在流式传输过程中发生错误,错误将以 application/x-ndjson 格式的对象返回,并带有 error 属性。由于响应已经开始,响应的状态码将不会改变。
{"model":"gemma3","created_at":"2025-10-26T17:21:21.196249Z","response":" Yes","done":false}
{"model":"gemma3","created_at":"2025-10-26T17:21:21.207235Z","response":".","done":false}
{"model":"gemma3","created_at":"2025-10-26T17:21:21.219166Z","response":"I","done":false}
{"model":"gemma3","created_at":"2025-10-26T17:21:21.231094Z","response":"can","done":false}
{"error":"an error was encountered while running the model"}