如何发送请求-OpenAI API系统快速入门
您可以将以下命令粘贴到终端中以运行您的第一个 API 请求。确保替换为您的私有 API 密钥-YOUR_API_KEY
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}'
此请求查询 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
}
}
这样您完成一个简单请尝试,实际生产换成你生产数据来处理。
浙公网安备 33010602011771号