简体   繁体   English

测试 chatGPT API 的正确 URL 是什么?

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

I'm trying to test the GPT-3 api with a request using curl in Windows CMD:我正在尝试使用 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

Given that I did change "MY_KEY" for my key.鉴于我确实为我的密钥更改了“MY_KEY”。

But I got:但我得到了:

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

I also tried the model name as text-davinci-002 and text-davinci-001, but get the same invalid URL error.我还尝试将 model 名称作为 text-davinci-002 和 text-davinci-001,但得到相同的无效 URL 错误。 What's the correct URL here?这里正确的 URL 是什么? I can't find it on the docs (or in chatGPT itself).我无法在文档(或 chatGPT 本身)中找到它。

Sending a POST request to /v1/conversations/text-davinci-003/messages will not return the result you want, because this URL is not used by the OpenAI API./v1/conversations/text-davinci-003/messages发送 POST 请求不会返回你想要的结果,因为这个 URL 没有被 OpenAI API 使用。

Here's an example of a cURL request which completes the message Say this is a test这是完成消息的 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}'

And this is an example of what the API will respond with:这是 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
    }
}

This is the full list of API paths:这是 API 路径的完整列表:

Instead, you can use the URLs listed in the OpenAI documentation :相反,您可以使用OpenAI 文档中列出的 URL:

  • List models列出模型

    GET https://api.openai.com/v1/models获取https://api.openai.com/v1/models
  • Retrieve model取回 model

    GET https://api.openai.com/v1/models/{model}获取https://api.openai.com/v1/models/{model}
  • Create completion创建完成

    POST https://api.openai.com/v1/completions https://api.openai.com/v1/completions
  • Create edit创建编辑

    POST https://api.openai.com/v1/edits https://api.openai.com/v1/edits
  • Create image创建图像

    POST https://api.openai.com/v1/images/generations https://api.openai.com/v1/images/generations
  • Create image edit创建图像编辑

    POST https://api.openai.com/v1/images/edits https://api.openai.com/v1/images/edits
  • Create image variation创建图像变体

    POST https://api.openai.com/v1/images/variations https://api.openai.com/v1/images/variations
  • Create embeddings创建嵌入

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

More found in the OpenAI documentation .OpenAI 文档中可以找到更多内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM