ai-gateway
    ai-gateway
    • Suno
      • Suno Generate
        POST
      • Suno Feed
        GET
      • Suno Concat
        POST
      • Suno Generate (Extend)
        POST
    • Stable Diffusion
      • Stable Diffusion 文生图
        POST
      • Stable Diffusion 图生图
        POST
      • ReActor image
        POST
    • Create chat completion
      POST
    • Create chat completion with stream
      POST
    • Create image
      POST
    • Create speech
      POST
    • Create transcription
      POST
    • asr
      POST
    • asr Copy
      POST
    • Create transcription Copy
      POST

      Create chat completion with stream

      POST
      /v1/chat/completions

      请求参数

      Authorization
      在 Header 添加参数
      Authorization
      ,其值为在 Bearer 之后拼接 Token
      示例:
      Authorization: Bearer ********************
      Body 参数application/json
      object {0}
      示例
      {
        "model": "gpt-3.5-turbo",
        "stream": true,
        "max_tokens": 20,
        "messages": [
          {
            "role": "user",
            "content": "你好"
          }
        ]
      }

      示例代码

      Shell
      JavaScript
      Java
      Swift
      Go
      PHP
      Python
      HTTP
      C
      C#
      Objective-C
      Ruby
      OCaml
      Dart
      R
      请求示例请求示例
      Shell
      JavaScript
      Java
      Swift
      curl --location --request POST 'https://api.aigateway.work/v1/chat/completions' \
      --header 'Content-Type: application/json' \
      --data-raw '{
        "model": "gpt-3.5-turbo",
        "stream": true,
        "max_tokens": 20,
        "messages": [
          {
            "role": "user",
            "content": "你好"
          }
        ]
      }'

      返回响应

      🟢200成功
      text/event-stream
      Body
      object {0}
      示例
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"你"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"好"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"有"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"什"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"么"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"可以"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"帮"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"助"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"你"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"的"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"吗"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{"content":"?"},"logprobs":null,"finish_reason":null}]}
      
      data: {"id":"chatcmpl-8usmhlW6PtCes58mYfsH3A1fMykmM","object":"chat.completion.chunk","created":1708567651,"model":"gpt-3.5-turbo-0125","system_fingerprint":"fp_cbdb91ce3f","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]}
      
      data: [DONE]
      
      
      修改于 2024-03-14 05:41:50
      上一页
      Create chat completion
      下一页
      Create image
      Built with