Интеграция с PHP

Запрос на генерацию текста [QA]

Endpoint /v1/chat/completions

Метод: POST


$url = "https://api.hydraai.ru/v1/chat/completions";

$headers = array(
  "Authorization: Bearer YOUR_API_KEY",
  "Content-Type: application/json"
);

$data = array(
  "messages" => array(
    array(
      "role" => "user",
      "content" => "Что такое небо?"
    )
  ),
  "model" => "gpt-4o-mini",
  "max_tokens" => 100,
  "temperature" => 0.8,
  "top_p" => 0.9,
  "stream" => false
);

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));

$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);

if ($httpCode == 200)
{
  print_r(json_decode($response, true));
}
else
{
  echo "Error: $httpCode\n";
  echo $response;
}

Получение профиля пользователя

Endpoint /v1/users/profile

Метод: GET


$url = "https://api.hydraai.ru/v1/users/profile";

$headers = array(
  "Authorization: Bearer YOUR_API_KEY"
);

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);

if ($httpCode == 200)
{
  print_r(json_decode($response, true));
}
else
{
  echo "Error: $httpCode\n";
  echo $response;
}

Получение списка моделей

Endpoint /v1/models

Метод: GET


$url = "https://api.hydraai.ru/v1/models";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);

if ($httpCode == 200)
{
  print_r(json_decode($response, true));
}
else
{
  echo "Error: $httpCode\n";
  echo $response;
}

Полная документация по API предоставляется после получения ключа.

IP: 216.73.216.152