Skip to content

Support strict mode in NativeOutput #2084

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

Merged
merged 3 commits into from
Jun 27, 2025

Conversation

severinh
Copy link
Contributor

@severinh severinh commented Jun 26, 2025

This PR adds the boolean parameter strict to the newly introduced NativeOutput, analogous to the parameter that already existed on ToolOutput. This enables strict mode in supported models. For OpenAI, this turns on constrained grammar sampling, which guarantees at the LLM-level that the output conforms to the JSON schema (at least the subset of supported features).

closes #2080

@DouweM
Copy link
Contributor

DouweM commented Jun 26, 2025

@severinh Thank you, I'll review this tomorrow!

@severinh severinh requested a review from DouweM June 27, 2025 14:03
@DouweM DouweM changed the title feat: Support strict mode in NativeOutput (closes #2080) Support strict mode in NativeOutput Jun 27, 2025
@DouweM DouweM merged commit 51d1acb into pydantic:main Jun 27, 2025
18 checks passed
@DouweM
Copy link
Contributor

DouweM commented Jun 27, 2025

@severinh Thanks Severin!

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

Successfully merging this pull request may close these issues.

Support strict mode in new NativeOutput
2 participants