Adding extra_headers for the anthropic web-fetch tool causes the structured_output example to fail
Problem
Adding the `extra_headers` and `tools` options in the`messages.create` call causes the call with `output_format` to fail. I am using version 0.75 of the sdk. I took the example from here: https://platform.claude.com/docs/en/build-with-claude/structured-outputs#quick-start and added these two options in the create call [code block] This causes the example to fail with this error [code block] Are these options incompatible with structured output. I'm not sure this is an sdk error or an error in the api itself, please close if not appropriate.
Error Output
Error: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'output_format: Extra inputs are not permitted'}, 'request_id': 'req_011CWFjdN1tMWCHmGWcYGVfp'}Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Adding extra_headers for the anthropic web-fetch tool causes the structured_output example to fail
I also tried removing the `extra_headers` option and passing in just the `tools` for web-fetch, but that gives the following error: [code block]
Trust Score
1 verification
- 1
I also tried removing the `extra_headers` option and passing in just the `tools`
[code block]
textanthropic.BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': "tools.0: Input tag 'web_fetch_20250910' found using 'type' does not match any of the expected tags: 'bash_20250124', 'custom', 'text_editor_20250124', 'text_editor_20250429', 'text_editor_20250728', 'web_search_20250305'"}, 'request_id': 'req_011CWFk9Hw9cd88px4fHED9r'}
Validation
Resolved in anthropics/anthropic-sdk-python GitHub issue #1105. Community reactions: 0 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep