You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to receive the response in a structured format, you can specify the `response_format` property in the `ChatData` object.
396
-
And also setting `require_parameters`to **true** in provider preferences (in `ProviderPreferencesData` DTO object) is advised for structured output.
395
+
If you want to receive the response in a structured format, you can specify the `type` property for `response_format` (ResponseFormatData) as `json_object` in the `ChatData` object.
396
+
Additionally, it's recommended to set the `require_parameters` property for `provider` (ProviderPreferencesData) to `true` in the `ChatData` object.
397
397
398
398
(Please also refer to [OpenRouter Document Structured Output](https://openrouter.ai/docs/structured-outputs) for models supporting structured output, also more details)
399
399
```php
@@ -408,16 +408,16 @@ $chatData = new ChatData([
408
408
'response_format' => new ResponseFormatData([
409
409
'type' => 'json_object',
410
410
]),
411
-
'provider' => new ProviderPreferencesData([
411
+
'provider' => new ProviderPreferencesData([
412
412
'require_parameters' => true,
413
413
]),
414
414
]);
415
415
```
416
416
417
-
You can also specify the `response_format`property as `json_schema` to receive the response in a specified schema format (set `'strict' => true` in `json_schema` array for strict schema):
417
+
You can also specify the `response_format` as `json_schema` to receive the response in a specified schema format (Advisable to set `'strict' => true` in `json_schema` array for strict schema):
418
418
```php
419
419
$chatData = new ChatData([
420
-
'messages' => [
420
+
'messages' => [
421
421
new MessageData([
422
422
'role' => RoleType::USER,
423
423
'content' => 'Tell me a story about a rogue AI that falls in love with its creator.',
0 commit comments