开始使用

发出第一条请求

把下面命令里的令牌换成你在控制台创建的 sk-...。模型名可到 https://www.cokeapi.com/pricing 查看,下面示例使用 gpt-5.4-mini


curl https://www.cokeapi.com/v1/chat/completions \

  -H "Content-Type: application/json" \

  -H "Authorization: Bearer sk-你的令牌" \

  -d '{

    "model": "gpt-5.4-mini",

    "messages": [{"role": "user", "content": "Say this is a test!"}]

  }'

成功时会返回类似结构:


{

  "id": "chatcmpl-...",

  "object": "chat.completion",

  "model": "gpt-5.4-mini",

  "choices": [

    {

      "index": 0,

      "message": {

        "role": "assistant",

        "content": "This is a test!"

      },

      "finish_reason": "stop"

    }

  ],

  "usage": {

    "prompt_tokens": 13,

    "completion_tokens": 7,

    "total_tokens": 20

  }

}

不想用命令行时,可先在 Playground 测通:https://www.cokeapi.com/playground