智能问答3.5 联网和非联网

注意:本 API 属于生成式人工智能 API,出于安全考虑,请务必在使用时不要输入带有国家和企业机密的相关信息,同时本 API 也会严格遵循中华人民共和国《生成式人工智能服务管理办法》严格把控和过滤相关敏感、不道德、侵权等信息。

生成式大模型基于深度神经网络,可用于自然语言理解、自然语言生成、对话生成等多个领域。本 API 提供了 AI 智能问答的能力,并支持多轮对话问答和流式响应。支持联网获取最新内容,自动故障处理和内置风险内容过滤。
基于本 API 的聊天平台,对接了多轮对话和流式响应,自动关联账号的套餐信息,聊天自动消耗次数。
3.5 4.0 联网

一.您的KEY

点击前往获取KEY |【智能问答】点击KEY按钮获取

二.请求内容

请求地址:https://chatapi.ai-gs.cn/v1/chat/completions

请求方式:POST

请求头:

参数
Content-Type string 必填参数 application/json
Accept string 必填参数
联网,默认false
application/json
Authorization string 必填参数
注意Bearer后有个空格,“sk-xxxxxxxxxxxxxxx”为你的KEY
Bearer sk-xxxxxxxxxxxxxxx

请求体:

我们提供高速输出,并非廉价的慢速输出模式,合适对稳定和质量有要求的用户
模型0613和1106版本区别:1106输出更快,0613要聪明更灵活些
系统有自动故障处理,当任意版本大规模出现问题,会自动切换到其它版本,保障使用
参数
model string 必须
模型选择。gpt-3.5-turbo-16k默认为1106版本
temperature number 非必需
温度值默认0
presence_penalty number 非必需
默认0
frequency_penalty number 非必需
top_p number 非必需
默认0
messages array 必需 格式[{},{},{}]
role string 必填参数
角色
content string 必填参数
文本
stream boolean 非必需
流式返回,默认false
online boolean 非必需
联网,默认false

三.返回内容

响应状态:

  • 200 成功

    200表示成功,请根据流式和非流式处理
    • 流式返回

      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"你"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"好"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"你"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"好"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":","},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"有"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"什"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"么"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"可以"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"帮"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"到"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"你"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"的"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"吗"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{"content":"?"},"finish_reason":null}]}
      data: {"id":"chatcmpl-8S3rJuXY1uqXRMGBPHqpukO2VDEGw","object":"chat.completion.chunk","created":1701698709,"model":"gpt-3.5-turbo-1106","system_fingerprint":"fp_eeff13170a","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
      data: [DONE]

    • 联网流式返回

      因为联网会产生更多时间,当收到如下两条内容,前端提醒用户“正在联网”,获得更好用户体验,不提示也没问题,兼容性很高
      触发联网,会首先发你一条信息,表示需要联网,格式如下
      data: {"id":"chatcmpl-7yxhZA4JM55jxZ2Hi2hW0pEF6SrFX","object":"chat.completion.chunk","created":1694763529,"model":"gpt-3.5-turbo-0613","choices":[{"index":0,"delta":{"role":"assistant","content":null,"function_call":{"name":"web_search","arguments":""}},"finish_reason":null}]}

      联网完成后会发第二条信息,表示联网查询完成,格式如下
      data: {"id":"chatcmpl-7yxhZA4JM55jxZ2Hi2hW0pEF6SrFX","object":"chat.completion.chunk","created":1694763529,"model":"gpt-3.5-turbo-0613","choices":[{"index":0,"delta":{},"finish_reason":"function_call"}]}
      后续返回数据跟正常流式返回完全一致。

    • 非流式返回

      { "id": "chatcmpl-867TqPdem575QRHl1pjYWibSRm0x5", "object": "chat.completion", "created": 1696469414, "model": "gpt-3.5-turbo-0301", "choices": [{ "index": 0, "message": { "role": "assistant", "content": "红杏出墙春意浓,\n花香飘散满庭中。\n娇艳欲滴如痴女,\n迷人眼目动人心。\n\n墙外风光春色好,\n墙内佳人美如桃。\n相思苦恋难相守,\n唯有红杏作媒介。\n\n红杏出墙情难遮,\n两情相悦意难赊。\n愿与佳人长相伴,\n花好月圆情更好。" }, "finish_reason": "stop" }], "usage": { "prompt_tokens": 89, "completion_tokens": 146, "total_tokens": 235 } }


  • 401 错误

    一般都是KEY方面错误
    • no_api_key

      没有apikey。

    • invalid_request_error

      输入不正确。

    • invalid_api_key

      api key不合法。

  • 402 错误

    其它异常错误。
  • 403 错误

    输入性错误
    • insufficient_quota

      余额不足。

    • invalid_request_errorr

      请求不合法。

    • model_not_found

      模型未发现。
  • 501 错误

    网络 或 服务器错误
  • 502 错误

    网络 或 服务器错误
  • 503 错误

    网络 或 服务器错误