不出意外的话,这应该是你看到的最后一个ChatGPT使用教程。不仅完全免费使用ChatGPT和GPT4,最重要的是不需要注册OpenAI账号,免登录就可以直接使用,也不限使用次数。那我在想那些买的账号然后被封的应该得哭死。那今天分享的网站不...
Tag:安卓手机AndroidApp推荐装机必备软件ChatGPTgpt4.0ChatGPT4.0AI手机绘画软件ChatGPT安卓版下载open AI中文版网站02月04日
<?php
// Set up the cURL request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.openai.com/v1/text-generator");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{
"model": "text-davinci-002",
"prompt": "What is the capital of France?",
"max_tokens": 128
}');
curl_setopt($ch, CURLOPT_POST, 1);
// Set the API key as an HTTP header
$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "Authorization: Bearer <YOUR_API_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 cURL request, print it out
echo 'Error: ' . curl_error($ch);
} else {
// Otherwise, print the response from the GPT-3 API
echo $response_data['data']['text'];
}
curl_close($ch);
?>
在上面的代码中,您需要替换 <YOUR_API_KEY> 为您的 OpenAI API 密钥。 您可以在 OpenAI 的控制台中找到您的 API 密钥。继续浏览有关 ChatGPT 的文章