Anthropic does not natively support aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/anthropic/llms.txt
Use this file to discover all available pages before exploring further.
json_schema response format the way some other providers do. The PHP AI SDK adapts this capability by injecting a hidden structured_output tool into every request that uses .output(), then forcing Claude to call it. The tool’s input — validated against your schema — is decoded and returned as the structured result.
Basic Structured Output
Call.output() with a Schema::object() describing the shape you expect. Access the decoded array via $result->output or the JSON string via $result->text.
How It Works
When.output() is present, the request builder:
- Constructs a hidden tool named
structured_outputwhoseinput_schemais derived from yourSchema::object(). - Appends it to
body['tools']. - Sets
tool_choiceto{ "type": "tool", "name": "structured_output" }, forcing Claude to call exactly that tool.
tool_use block with name === "structured_output", JSON-encodes its input field, and wraps it in a TextPart. This means $result->text is the JSON string and $result->output is the decoded array.
The injected tool definition looks like this in the request body:
Combining with User Tools
When you attach both.tools() and .output() in the same request, the SDK merges them rather than replacing your tools. User-defined tools appear first, followed by structured_output. The tool_choice remains forced to structured_output.
tools array sent to the API will be ["weather", "structured_output"] and tool_choice will be { "type": "tool", "name": "structured_output" }.