<?php
$url = 'https://llm.api.cloud.yandex.net/foundationModels/v1/completion';
$apiKey = 'AQVN3IBcntZpifU8p5eBMn0vFdxRG4o2Qy_1L7Lz';
$folderId = 'b1g7ranflqskpkhqp19k';
$modelUri = 'gpt://b1g7ranflqskpkhqp19k/yandexgpt-lite';
$data = [
'modelUri' => $modelUri,
'completionOptions' => [
'stream' => false,
'temperature' => 0.6,
'maxTokens' => '2000'
],
'messages' => [
[
'role' => 'user',
'text' => 'раскажи сказку про кота'
]
]
];
$headers = [
'Authorization: Api-Key ' . $apiKey,
'x-folder-id: ' . $folderId,
'Content-Type: application/json'
];
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($curl);
curl_close($curl);
$result = json_decode($response, true);
print_r($result);
?>