Any documentation of this chat endpoint?


Asking to chatgpt it recommended to use this API endpoint for chatting purposes:

I didn’t find any information about it, but exists, got this answer:

    "error": {
        "message": "You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from",
        "type": "invalid_request_error",
        "param": null,
        "code": null

Tried to connect using PHP in this way, get, post, with or without headers, with or without data, but just get an empty string or bool(true)

$headers = [
    'Authorization' => 'Bearer ' . 'sk-A_KEY',
    'Content-Type' => 'application/json',

$data = [
    'prompt' => "hola qué tal?",
    'max_tokens' => 100,
    'temperature' => 0.7
    //'top_p' => (float)env('GPT_TOP_P'),
    //'n' => (int)env('GPT_N'),
$response = sendPostRequest($url, $headers, $data);


function sendPostRequest($url, $headers, $data) {
    // Initialize cURL session
    $ch = curl_init();
    // Set cURL options
    curl_setopt($ch, CURLOPT_URL, $url);
    //curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'OPTIONS');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    //curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    // Execute cURL request and get response
    $response = curl_exec($ch);
    // Close cURL session
    return $response;

Any idea about how to connect to that?

And if you know a working approach to try to chat, please share.


Hi Jose. There’s something amiss with the API key in your code.

I think it might help if you take a look at how others define the API key with PHP.

Here’s another great example.

1 Like

I’ll check, thanks.

By the way, I asked to the team before and got this answer, maybe could be useful for others:

GPT-3 predicts feasible responses, which look like reasonable text but may not always be true. This is called information hallucination and is an open problem in the research space. For example, you can ask ‘Describe what it was like when humans landed on the Sun’ and it will respond as though that has happened. You may ask it to complete some task (e.g. send an email or print the current directory) and it may respond as though it has some external operating power. GPT is only a text-in, text-out system and has no additional capabilities.

In this case, it is possible that the advice given by ChatGPT and Davinci is incorrect. Please refer to our documentation for guidance.

1 Like

Hi @josephfrusetta are there any documented limits to the post data to the Chat endpoint? For instance, can it receive a payload as big as 10 MB?

@jvalle, your API key might be fine after all. If we look to OpenAI’s documentation for the chat/engine endpoint, we see that it has been deprecated. This is the most likely reason why you’re seeing that error.

Instead, everyone should be using the model endpoint as seen here:

@kerbymart the max token per request depends on the model used. Here’s a chart showing the limits.

Depending on the model used, requests can use up to 4097 tokens shared between prompt and completion. If your prompt is 4000 tokens, then your completion can be 97 tokens at most. Here’s some more information on how tokens work.

1 Like