-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add support for OpenAI verbosity parameter in Responses API #2493
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
Open
ryx2
wants to merge
6
commits into
pydantic:main
Choose a base branch
from
ryx2:feat/openai-verbosity-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,183
−2,967
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implements the `openai_text_verbosity` setting for OpenAI Responses API models, allowing users to control response verbosity with 'low', 'medium', or 'high' values. The verbosity parameter is added to the text configuration when making requests to the OpenAI Responses API, providing better control over response length. Fixes pydantic#2478 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
DouweM
requested changes
Aug 12, 2025
- Move verbosity code below the 'trick' to fix tests - Change verbosity logic to use elif to prevent JSON format conflicts - Add VCR cassette test with @pytest.mark.vcr() decorator - Update test to use assert result.output == snapshot() 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
🎯 **Key Achievements:** - ✅ Fixed verbosity implementation to match OpenAI documentation format - ✅ Successfully tested GPT-5 with 'low' verbosity setting - ✅ Updated OpenAI package to 1.99.9 for latest features - ✅ Implemented all of DouweM's requested changes 🔧 **Technical Changes:** - Fixed verbosity text format: `{'format': {'type': 'text'}, 'verbosity': verbosity}` - Moved verbosity logic below JSON 'trick' (DouweM feedback) - Changed to `elif` to prevent JSON format conflicts (DouweM feedback) - Added VCR test with `@pytest.mark.vcr()` decorator (DouweM feedback) - Updated test to use `assert result.output == snapshot()` (DouweM feedback) 🧪 **Test Results:** - GPT-5 + low verbosity: ✅ WORKING - Test passes with proper quantum computing explanation - VCR cassette captures successful API interaction The implementation now correctly follows OpenAI's documentation pattern for verbosity with GPT-5. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Resolved uv.lock conflict by regenerating lock file - Updated with latest changes from main branch - Preserved our working GPT-5 verbosity implementation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
✅ **VCR Test Successfully Created:** - Added test_openai_responses_verbosity() with @pytest.mark.vcr() - Tests GPT-5 with 'low' verbosity setting - Uses snapshot() for deterministic testing - VCR cassette shows correct request format 🔧 **Test Details:** - **Request:** 'What is 2+2?' with verbosity='low' - **Response:** '4' (demonstrates low verbosity working) - **Format:** {'format': {'type': 'text'}, 'verbosity': 'low'} 📦 **Dependencies:** - Updated uv.lock with OpenAI 1.99.9 and other resolved dependencies Addresses DouweM's feedback about missing VCR cassette. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Allow verbosity parameter to be combined with JSON object and JSON schema formats as per OpenAI documentation. Changed conditional from elif to if and added logic to append verbosity to existing text configuration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
@DouweM cool to upgrade openai to 1.99.9? |
@DouweM why are these unrelated tests failing in CI? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
openai_text_verbosity
setting for OpenAI Responses API modelsTest plan
Implementation Details
openai_text_verbosity: Literal['low', 'medium', 'high']
toOpenAIResponsesModelSettings
_responses_create
method to include verbosity in text config when specifiedThis addresses issue #2478 and provides the functionality requested in the GitHub issue with proper error handling and documentation.
🤖 Generated with Claude Code