maxduke / go-chatgpt-api

一个尝试绕过 Cloudflare 来使用 ChatGPT 接口的程序
MIT License
141 stars 33 forks source link

请问是我操作不对么,一直显示{"errorMessage":"Post \"/v1/chat/completions\": invalid URL scheme: []"} #51

Closed Wszhdg closed 2 months ago

Wszhdg commented 2 months ago

这是我用的php代码,actk是正确的,但是不论怎么访问都提示 {"errorMessage":"Post \"/v1/chat/completions\": invalid URL scheme: []"}

Wszhdg commented 2 months ago

$API_KEY = ''; $BASE_URL = 'http://127.0.0.1:8090/v1/chat/completions';

$headers = array( 'Authorization: Bearer '.$API_KEY, 'Content-Type: application/json', );

$data = array( 'model' => 'gpt-3.5-turbo', 'messages' => array( array( 'role' => 'user', 'content' => 'How do I list all files in a directory using Python?' ) ) );

$options = array( CURLOPT_URL => $BASE_URL, CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_POSTFIELDS => json_encode($data), );

$curl = curl_init(); curl_setopt_array($curl, $options); $result = curl_exec($curl);

if(!$result){ die('Error: "' . curl_error($curl) . '" - Code: ' . curl_errno($curl)); }

curl_close($curl);

$response = json_decode($result, true); // echo $response['choices'][0]['message']['content']; print_r($result);

maxduke commented 2 months ago

/imitate/v1/chat/completions

Wszhdg commented 2 months ago

好的,感谢