如何发送请求
您可以将以下命令粘贴到终端中以运行您的第一个 API 请求。确保替换为您的私有 API 密钥-YOUR_API_KEY
curl -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}'
此请求查询 Davinci 模型以完成文本,并提示“说这是一个测试”。max_tokens该参数设置 API 将返回多少令牌的上限。 您应该收到类似于以下内容的回复:
{ "id": "cmpl-GERzeJQ4lvqPk8SkZu4XMIuR", "object": "text_completion", "created": 1586839808, "model": "text-davinci:003", "choices": [ { "text": "\n\nThis is indeed a test", "index": 0, "logprobs": null, "finish_reason": "length" } ], "usage": { "prompt_tokens": 5, "completion_tokens": 7, "total_tokens": 12 } } 这样您完成一个简单请尝试,实际生产换成你生产数据来处理。
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2023-02-10,如有侵权请联系 cloudcommunity@tencent 删除入门数据系统apiopenai