BETA
Documentation
PHP Basic Chat
Apily has no official PHP SDK — plain cURL or Guzzle against the OpenAI-compatible endpoint works fine, since it's just JSON over HTTP.
Minimal chat (cURL)
chat.php
<?php
$ch = curl_init("https://apily.pro/v1/chat/completions");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer apily_your-api-key",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"model" => "gpt-5.6-sol",
"messages" => [["role" => "user", "content" => "Hello?"]],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $response["choices"][0]["message"]["content"];Using Guzzle
terminal
composer require guzzlehttp/guzzlechat.php
<?php
require "vendor/autoload.php";
$client = new GuzzleHttp\Client(["base_uri" => "https://apily.pro/v1/"]);
$response = $client->post("chat/completions", [
"headers" => ["Authorization" => "Bearer apily_your-api-key"],
"json" => [
"model" => "gpt-5.6-sol",
"messages" => [["role" => "user", "content" => "Hello?"]],
],
]);
$data = json_decode($response->getBody(), true);
echo $data["choices"][0]["message"]["content"];