Skip to content

Does this support Grok’s Structured Outputs? #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bleuren opened this issue Mar 26, 2025 · 0 comments
Open

Does this support Grok’s Structured Outputs? #3

bleuren opened this issue Mar 26, 2025 · 0 comments

Comments

@bleuren
Copy link

bleuren commented Mar 26, 2025

First, thank you for developing this library. I am wondering if this package supports Grok's Structured Outputs feature.

For instance, when using openai-php/laravel, I can utilize the Structured Outputs feature as follows:

$jsonSchema = [
    'name' => 'scores',
    'schema' => [
        'type' => 'object',
        'properties' => [
            'score1' => ['type' => 'number'],
            'score2' => ['type' => 'number'],
        ],
        'required' => ['score1', 'score2'],
        'additionalProperties' => false,
    ],
    'strict' => true,
];

$response = OpenAI::chat()->create([
    'model' => 'gpt-4o-mini',
    'messages' => [
        ['role' => 'system', 'content' => $prompt],
    ],
    'response_format' => [
        'type' => 'json_schema',
        'json_schema' => $jsonSchema,
    ],
]);

If this package supports Structured Outputs, could you please provide guidance on how to implement it? If not, are there alternative methods to achieve similar functionality? Thank you!

Related Links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant