Tom*_*ito 0 curl openai-api gpt-3
我正在尝试在 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
Run Code Online (Sandbox Code Playgroud)
鉴于我确实更改了我的密钥“MY_KEY”。
但我得到了:
{
"error": {
"message": "Invalid URL (POST /v1/conversations/text-davinci-003/messages)",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
Run Code Online (Sandbox Code Playgroud)
我还尝试将模型名称命名为text-davinci-002和text-davinci-001,但得到相同的无效 URL 错误。这里正确的网址是什么?我在文档(或 chatGPT 本身)中找不到它。
发送 POST 请求/v1/conversations/text-davinci-003/messages不会返回您想要的结果,因为 OpenAI API 不使用此 URL。
以下是完成消息的 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}'
Run Code Online (Sandbox Code Playgroud)
这是 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
}
}
Run Code Online (Sandbox Code Playgroud)
这是 API 路径的完整列表:
相反,您可以使用OpenAI 文档中列出的 URL :
https://api.openai.com/v1/modelshttps://api.openai.com/v1/models/{model}https://api.openai.com/v1/completionshttps://api.openai.com/v1/editshttps://api.openai.com/v1/images/generationshttps://api.openai.com/v1/images/editshttps://api.openai.com/v1/images/variationshttps://api.openai.com/v1/embeddings更多信息请参见OpenAI 文档。
| 归档时间: |
|
| 查看次数: |
11769 次 |
| 最近记录: |