簡體   English   中英

測試 chatGPT API 的正確 URL 是什么?

[英]What's the correct URL to test chatGPT API?

我正在嘗試使用 Windows CMD 中的 curl 請求測試 GPT-3 api:

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer MY_KEY" -d "{\"text\": \"is this working\"}" https://api.openai.com/v1/conversations/text-davinci-003/messages

鑒於我確實為我的密鑰更改了“MY_KEY”。

但我得到了:

{
  "error": {
    "message": "Invalid URL (POST /v1/conversations/text-davinci-003/messages)",
    "type": "invalid_request_error",
    "param": null,
    "code": null
  }
}

我還嘗試將 model 名稱作為 text-davinci-002 和 text-davinci-001,但得到相同的無效 URL 錯誤。 這里正確的 URL 是什么? 我無法在文檔(或 chatGPT 本身)中找到它。

/v1/conversations/text-davinci-003/messages發送 POST 請求不會返回你想要的結果,因為這個 URL 沒有被 OpenAI API 使用。

這是完成消息的 cURL 請求的示例Say this is a test

curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"model": "text-davinci-003", "prompt": "Say this is a test", "temperature": 0, "max_tokens": 7}'

這是 API 將響應的示例:

{
    "id": "cmpl-GERzeJQ4lvqPk8SkZu4XMIuR",
    "object": "text_completion",
    "created": 1586839808,
    "model": "text-davinci:003",
    "choices": [
        {
            "text": "This is indeed a test",
            "index": 0,
            "logprobs": null,
            "finish_reason": "length"
        }
    ],
    "usage": {
        "prompt_tokens": 5,
        "completion_tokens": 7,
        "total_tokens": 12
    }
}

這是 API 路徑的完整列表:

相反,您可以使用OpenAI 文檔中列出的 URL:

  • 列出模型

    獲取https://api.openai.com/v1/models
  • 取回 model

    獲取https://api.openai.com/v1/models/{model}
  • 創建完成

    https://api.openai.com/v1/completions
  • 創建編輯

    https://api.openai.com/v1/edits
  • 創建圖像

    https://api.openai.com/v1/images/generations
  • 創建圖像編輯

    https://api.openai.com/v1/images/edits
  • 創建圖像變體

    https://api.openai.com/v1/images/variations
  • 創建嵌入

    https://api.openai.com/v1/embeddings

OpenAI 文檔中可以找到更多內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM