Skip to content

Force structured output #857

@WindowsNT

Description

@WindowsNT

The model descriptions contain a json field structured_outputs, which is set to true for many models.

                "id": "claude-sonnet-4.6",
                "name": "Claude Sonnet 4.6",
                "capabilities": {
                    "family": "claude-sonnet-4.6",
                    "limits": {
                        "max_context_window_tokens": 200000,
                        "max_non_streaming_output_tokens": 16000,
                        "max_output_tokens": 32000,
                        "max_prompt_tokens": 128000,
                        "vision": {
                            "max_prompt_image_size": 3145728,
                            "max_prompt_images": 5,
                            "supported_media_types": [
                                "image/jpeg",
                                "image/png",
                                "image/webp"
                            ]
                        }
                    },
                    "object": "model_capabilities",
                    "supports": {
                        "adaptive_thinking": true,
                        "max_thinking_budget": 32000,
                        "min_thinking_budget": 1024,
                        "parallel_tool_calls": true,
                        "reasoning_effort": [
                            "low",
                            "medium",
                            "high"
                        ],
                        "streaming": true,
                        "structured_outputs": true,
                        "tool_calls": true,
                        "vision": true,
                        "reasoningEffort": true
                    },
                    "tokenizer": "o200k_base",
                    "type": "chat"

It works when I tell the model in the prompt, for example "return only json in this format ...", but is there a way to enforce it in the session creation or in some other more enforcing way to ensure I will get it exactly as needed?

Like

{"id":"9","jsonrpc":"2.0","method":"session.send","params":{"prompt":"Hello","sessionId":"...","structured_output": 
{....}
}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions