admin管理员组

文章数量:1122851

自己搭建的网站,目前没任何限制,使用php调用官方接口。代码在下方分享给大家。chatGPT中文站


```php
// Set up the cURL request
$ch = curl_init();
 
curl_setopt($ch, CURLOPT_URL, "https://api.openai/v1/completions");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{
  "model": "text-davinci-003",
  "prompt": "'.$text.'",
  "max_tokens": 2048
}');
curl_setopt($ch, CURLOPT_POST, 1);
 
// Set the API key as an HTTP header
$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "Authorization: Bearer 你的KEY";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
 
// Send the request and parse the response
$response = curl_exec($ch);
$response_data = json_decode($response, true);

 
if (curl_errno($ch)) {
  // If there was an error executing the 

本文标签: 中文ChatGpt