Hi, I think the OpenRouter structured-output handler may be sending the wrong request shape.
OpenRouter’s structured output docs show strict schema output using:
{
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "...",
"strict": true,
"schema": {}
}
},
"structured_outputs": true
}
But Prism’s OpenRouter structured handler appears to send the schema under response_format while using type: "json_object".
That means OpenRouter treats it as normal JSON mode, not strict schema-constrained output. Some models still behave okay, but others return empty content, unstructured content, or schema-shaped but unreliable output.
Suggested fix:
'response_format' => [
'type' => 'json_schema',
'json_schema' => [
'name' => $request->schema()->name(),
'strict' => true,
'schema' => $request->schema()->toArray(),
],
],
'structured_outputs' => $request->providerOptions('structured_outputs') ?? true,
It may also be worth documenting that callers can pass:
'provider' => [
'require_parameters' => true,
],
for OpenRouter so it does not route the request to an endpoint that ignores unsupported structured-output parameters.
Relevant OpenRouter docs:
This seems separate from plain JSON mode. response_format carries the schema, while structured_outputs is a separate supported parameter/capability flag.
Hi, I think the OpenRouter structured-output handler may be sending the wrong request shape.
OpenRouter’s structured output docs show strict schema output using:
{ "response_format": { "type": "json_schema", "json_schema": { "name": "...", "strict": true, "schema": {} } }, "structured_outputs": true }But Prism’s OpenRouter structured handler appears to send the schema under
response_formatwhile usingtype: "json_object".That means OpenRouter treats it as normal JSON mode, not strict schema-constrained output. Some models still behave okay, but others return empty content, unstructured content, or schema-shaped but unreliable output.
Suggested fix:
It may also be worth documenting that callers can pass:
for OpenRouter so it does not route the request to an endpoint that ignores unsupported structured-output parameters.
Relevant OpenRouter docs:
This seems separate from plain JSON mode.
response_formatcarries the schema, whilestructured_outputsis a separate supported parameter/capability flag.