A01_Basics
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
<?php
require 'examples/boot.php';
use Cognesy\Instructor\StructuredOutput;
class UserDetail
{
public int $age;
public string $firstName;
public ?string $lastName;
}
$user = StructuredOutput::using('openai')
->withMessages('Jason is 25 years old.')
->withResponseClass(UserDetail::class)
->get();
dump($user);
assert(!isset($user->lastName) || $user->lastName === '');
?>