Overview

Instructor PHP provides a way to debug HTTP calls made to LLM APIs via Debug::setEnabled() method. Debug::setEnabled() works globally, it turns on dumping all HTTP requests and responses to the console.

Example

<?php
require 'examples/boot.php';

use Cognesy\Polyglot\LLM\Inference;
use Cognesy\Utils\Debug\Debug;

Debug::setEnabled();

$response = (new Inference)
    ->create(
        messages: [['role' => 'user', 'content' => 'What is the capital of Brasil']],
        options: ['max_tokens' => 128]
    )
    ->toText();

echo "USER: What is capital of Brasil\n";
echo "ASSISTANT: $response\n";
?>