$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
'https://api.soloma.agency/v1/chat');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
json_encode([
'prompt' => 'Напиши статью',
'max_tokens' => 500
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$data = json_decode($response, true);
echo $data['choices'][0]['text'];