Official PHP SDK for Hexa AI - Lightning-Fast AI API

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

pkg:composer/hexgenerative/ai

1.0.0 2026-01-14 01:31 UTC

This package is auto-updated.

Last update: 2026-01-14 01:40:06 UTC


README

Official PHP client for Hexa AI API.

Installation

composer require hexgenerative/ai

Quick Start

<?php
require_once 'vendor/autoload.php';

use HexaGenerative\HexaAI;

$client = new HexaAI('hgx-your-api-key');

$response = $client->chat->completions->create([
    'model' => 'hexa-pro',
    'messages' => [
        ['role' => 'user', 'content' => 'Hello, who are you?']
    ]
]);

echo $response->getContent();

Available Models

Model Description
hexa-instant Fastest responses
hexa-balanced General purpose
hexa-reasoning Complex analysis
hexa-advanced Coding tasks
hexa-pro Premium quality

Smart Routing

// By task type
$response = $client->chat->completions->create([
    'task' => 'coding',
    'messages' => [
        ['role' => 'user', 'content' => 'Write a PHP function']
    ]
]);

// By optimization
$response = $client->chat->completions->create([
    'optimize_for' => 'speed',
    'messages' => [
        ['role' => 'user', 'content' => 'Quick answer please']
    ]
]);

Error Handling

use HexaGenerative\HexaAI;
use HexaGenerative\HexaAIException;

try {
    $response = $client->chat->completions->create([
        'model' => 'hexa-pro',
        'messages' => [['role' => 'user', 'content' => 'Hello']]
    ]);
} catch (HexaAIException $e) {
    echo "Error: " . $e->getMessage();
    echo "Status: " . $e->getStatusCode();
}

License

MIT