[英]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
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.