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

      POST
      /v1/chat/completions
      原文参考:https://platform.openai.com/docs/api-reference/chat/create

      请求参数

      Authorization
      在 Header 添加参数
      Authorization
      ,其值为在 Bearer 之后拼接 Token
      示例:
      Authorization: Bearer ********************
      Body 参数application/json

      示例
      {
        "model": "claude-3-7-sonnet-20250219",
        "stream": true,
        "stream_options": {
          "include_usage": true
        },
        "messages": [
          {
            "role": "system",
            "content": "You are a helpful assistant."
          },
          {
            "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 'Authorization: Bearer <token>' \
      --header 'Content-Type: application/json' \
      --data-raw '{
        "model": "claude-3-7-sonnet-20250219",
        "stream": true,
        "stream_options": {
          "include_usage": true
        },
        "messages": [
          {
            "role": "system",
            "content": "You are a helpful assistant."
          },
          {
            "role": "user",
            "content": "你好!"
          }
        ]
      }'

      返回响应

      🟢200成功
      application/json
      Body

      示例
      {
        "id": "chatcmpl-8uxQ3O1u0Z79h7u9JjZ4FOEZapsko",
        "object": "chat.completion",
        "created": 1708585467,
        "model": "gpt-3.5-turbo-0125",
        "choices": [
          {
            "index": 0,
            "message": {
              "role": "assistant",
              "content": "你好!有什么我可以帮助你的吗?"
            },
            "logprobs": null,
            "finish_reason": "stop"
          }
        ],
        "usage": {
          "prompt_tokens": 20,
          "completion_tokens": 18,
          "total_tokens": 38
        },
        "system_fingerprint": "fp_cbdb91ce3f"
      }
      
      修改于 2025-06-30 03:20:35
      上一页
      ReActor image
      下一页
      Create chat completion with stream
      Built with