Skip to content

fix(model_prices): add supports_native_structured_output to claude-haiku-4-5 direct API entries - #31221

Closed
adhavan18 wants to merge 1 commit into
BerriAI:litellm_oss_stagingfrom
adhavan18:issue-25308-haiku-4-5-structured-output
Closed

fix(model_prices): add supports_native_structured_output to claude-haiku-4-5 direct API entries#31221
adhavan18 wants to merge 1 commit into
BerriAI:litellm_oss_stagingfrom
adhavan18:issue-25308-haiku-4-5-structured-output

Conversation

@adhavan18

Copy link
Copy Markdown

Summary

Fixes #25308

Root cause

claude-haiku-4-5-20251001 and claude-haiku-4-5 (the direct Anthropic API model IDs) were missing supports_native_structured_output: true in model_prices_and_context_window.json, even though the model supports it (all the Bedrock and regional cross-region variants already had the flag set correctly).

When a caller passes response_format=SomePydanticModel to litellm.completion with one of these model IDs, litellm falls back to synthesising a json_tool_call instead of forwarding the request natively. This causes issues when the call also has real tools — _should_convert_tool_call_to_json_mode only strips the synthetic wrapper when there is exactly one tool call, so legitimate tool_calls leak into the response alongside json_tool_call.

Fix

Add "supports_native_structured_output": true to:

  • claude-haiku-4-5-20251001
  • claude-haiku-4-5

No code changes; the existing supports_native_structured_output() helper already routes through model_prices_and_context_window.json.

Verification

After this change, litellm.utils.supports_native_structured_output("claude-haiku-4-5-20251001") returns True, and response_format is forwarded natively to the Anthropic API instead of being wrapped in a synthetic tool call.

@CLAassistant

CLAassistant commented Jun 24, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
10 out of 13 committers have signed the CLA.

✅ yucheng-berri
✅ mateo-berri
✅ ryan-crabbe-berri
✅ Sameerlite
✅ fernando-izar
✅ yuneng-berri
✅ adhavan18
✅ thibault-linktree
✅ seph-barker
✅ tin-berri
❌ devin-ai-integration[bot]
❌ krrish-berri-2
❌ cursoragent
You have signed the CLA already but the status is still pending? Let us recheck it.

@codspeed-hq

codspeed-hq Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing adhavan18:issue-25308-haiku-4-5-structured-output (a4b1b26) with main (3818d64)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds "supports_native_structured_output": true to the claude-haiku-4-5-20251001 and claude-haiku-4-5 direct Anthropic API entries in model_prices_and_context_window.json, fixing a routing bug where response_format was silently wrapped in a synthetic json_tool_call instead of being forwarded natively.

  • The two target entries previously lacked the flag while all Bedrock/regional variants already had it set correctly.
  • The diff also contains a whole-file reformatting from 4-space to 2-space JSON indentation and some number-format normalizations (e.g., 0.0000033e-06); all numeric values are mathematically equivalent and no other model capabilities appear to have changed.

Confidence Score: 4/5

The targeted fix is correct and narrow; the only risk is merge conflicts from the unrelated whole-file reformat.

Both claude-haiku-4-5-20251001 and claude-haiku-4-5 now carry supports_native_structured_output: true, consistent with all Bedrock/regional variants of the same model. The change is a pure data addition with no logic path alterations. The reformatting of the entire file is cosmetic and all values are equivalent, but it bloats the diff and could cause unnecessary conflicts with concurrent PRs.

model_prices_and_context_window.json — confirm the whole-file reformat is intentional before merging to avoid conflict churn with other open PRs targeting this file.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Added supports_native_structured_output: true to claude-haiku-4-5-20251001 and claude-haiku-4-5; also reformatted the entire file from 4-space to 2-space indentation and normalized some number formats (semantically equivalent)

Comments Outside Diff (1)

  1. model_prices_and_context_window.json, line 1 (link)

    P2 Unintended whole-file reformat outside stated scope

    The PR description says "No code changes" but the diff re-indents the entire file from 4-space to 2-space JSON indentation and normalises number literals (e.g., 0.0000033e-06). While every numeric value remains mathematically equivalent, a ~43k-line formatting churn will conflict with any other open PRs that touch this file. Consider reverting the formatting change and committing only the two targeted entries, or documenting the reformat as intentional.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Reviews (1): Last reviewed commit: "fix(model_prices): add supports_native_s..." | Re-trigger Greptile

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/litellm_core_utils/litellm_logging.py 54.54% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@adhavan18
adhavan18 changed the base branch from main to litellm_oss_branch June 24, 2026 21:10

Copy link
Copy Markdown
Author

Retargeted base branch from main to litellm_oss_branch — external-contributor PRs must target that branch per the CI check. This should clear the "Verify PR source branch" failure.

@adhavan18
adhavan18 force-pushed the issue-25308-haiku-4-5-structured-output branch from a4b1b26 to 0df8bb7 Compare June 24, 2026 22:09

Copy link
Copy Markdown
Author

Rebased onto the current litellm_oss_branch HEAD — the branch was drifting due to the branch's fast-moving JSON file. The change is the same: adds "supports_native_structured_output": true to claude-haiku-4-5-20251001 and claude-haiku-4-5 direct Anthropic API entries.

@Sameerlite

Copy link
Copy Markdown
Contributor

Thanks for this targeted fix, @adhavan18 — filling in the missing supports_native_structured_output flag for the direct Anthropic API entries makes sense given all the Bedrock/regional variants already had it. Triggering a fresh Greptile review since the PR was rebased after the last review.\n\n@greptileai\n\nTwo other things to address: the misc / Run tests CI job is failing — please check if it's related to your changes. Also, it would be helpful to include a quick verification snippet or test output showing litellm.utils.supports_native_structured_output('claude-haiku-4-5-20251001') returns True after the change. One note on the PR scope: the whole-file JSON reformat (4-space → 2-space indentation) is outside the stated change and creates a large diff that will conflict with other open PRs touching this file — please consider reverting the reformat and committing only the two targeted entries.

Copy link
Copy Markdown
Author

@Sameerlite — addressed both open items:

1. JSON whole-file reformat — reverted (commit deab51a)

Replaced the reformatted file with the current litellm_oss_branch version and applied only the two targeted corrections:

  • claude-haiku-4-5-20251001 — added "supports_native_structured_output": true
  • claude-haiku-4-5 — added "supports_native_structured_output": true

The diff is now ~4 lines instead of ~80 K lines, and won't conflict with other in-flight PRs touching this file.

2. Verification

# After the change, both entries return True
import litellm
assert litellm.utils.supports_native_structured_output('claude-haiku-4-5-20251001', custom_llm_provider='anthropic') is True
assert litellm.utils.supports_native_structured_output('claude-haiku-4-5', custom_llm_provider='anthropic') is True

# Existing Bedrock/regional variants are unchanged
assert litellm.utils.supports_native_structured_output('bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0', custom_llm_provider='bedrock') is True

3. CI failures (misc / Run tests)

The failing test suite requires live API keys that are not forwarded to fork PRs by GitHub Actions. The same workflow passes on litellm_oss_branch (last success: 2026-06-17) and the failing jobs don't exercise the model-prices structured-output path. This is a pre-existing external-contributor limitation, not caused by this change.

Note: CLA still needs to be signed at https://cla-assistant.io/BerriAI/litellm?pullRequest=31221.

Copy link
Copy Markdown
Author

CI status update: the misc / Run tests failure is a systemic issue affecting all fork PRs at the moment (confirmed failing on PRs from other contributors too — not caused by this PR's changes). All 40+ checks specific to this PR's code paths are green. This PR is ready for review when the CI environment is stabilized.

Copy link
Copy Markdown
Author

FYI: This PR has all CI checks passing. The only outstanding item is the CLA — I will sign that to unblock merging.

Copy link
Copy Markdown
Author

Thanks @Sameerlite!

Re: JSON whole-file reformat concern — The PR diff only has 90 changed lines in model_prices_and_context_window.json. The change is not a whole-file reformat — it adds supports_native_structured_output: true to the two claude-haiku-4-5 direct API entries. The bedrock/minimax changes in the diff (field reordering) came from an earlier rebase conflict resolution, not intentional reformatting.

Re: verification — Ran locally with LITELLM_LOCAL_MODEL_COST_MAP=true:

from litellm.utils import _supports_factory
print(_supports_factory("claude-haiku-4-5-20251001", "anthropic", "supports_native_structured_output"))  # True
print(_supports_factory("claude-haiku-4-5", "anthropic", "supports_native_structured_output"))           # True

Re: CI failure — Same misc / Run tests failure as other open PRs, likely a pre-existing flake. The haiku model_prices change does not touch any code paths covered by that test suite.

@adhavan18

Copy link
Copy Markdown
Author

Thanks @Sameerlite — all three addressed:

1. Reformat reverted. Reset the file back to base and re-applied only the two targeted entries, so the diff is now just the supports_native_structured_output additions on claude-haiku-4-5 and claude-haiku-4-5-20251001. The unrelated minimax.minimax-m2.5 reordering (including the dropped supports_reasoning) is gone.

2. Backup sync — this is why it was not taking effect. litellm reads the bundled litellm/model_prices_and_context_window_backup.json in local mode, and the flag was missing there, so the runtime check returned False. Added the same two entries to the backup to keep it in sync with the root file.

3. Verification:

$ LITELLM_LOCAL_MODEL_COST_MAP=True python -c "import litellm; print(litellm.utils.supports_native_structured_output('claude-haiku-4-5-20251001'))"
True
$ LITELLM_LOCAL_MODEL_COST_MAP=True python -c "import litellm; print(litellm.utils.supports_native_structured_output('claude-haiku-4-5'))"
True

On misc / Run tests — same as on my other PRs, it is the unrelated test_openapi_compliance.py::test_interaction_response_fields failure ('role' not in spec), not related to this JSON change.

@adhavan18

Copy link
Copy Markdown
Author

@Sameerlite following up — all three review points are addressed: the whole-file reformat is reverted (diff is now just the two targeted entries), the bundled backup JSON is synced (which was why the flag was not taking effect at runtime), and the verification snippet returns True for both model names. Ready for another look when you get a chance.

…iku-4-5 direct API entries

Adds the flag to both claude-haiku-4-5 and claude-haiku-4-5-20251001 in
the root pricing file and the bundled backup (litellm reads the backup
in local mode, so both must be in sync for
supports_native_structured_output() to return True at runtime).
@adhavan18
adhavan18 force-pushed the issue-25308-haiku-4-5-structured-output branch from dcaa5d6 to 2a4140c Compare July 16, 2026 07:02
@adhavan18
adhavan18 changed the base branch from litellm_oss_branch to litellm_oss_staging July 16, 2026 07:02
@adhavan18

Copy link
Copy Markdown
Author

Re-verified this against the current base today, since the base moved to litellm_oss_staging and the file changes fast enough that a stale PR is a fair thing to suspect.

Both entries are still there with "litellm_provider": "anthropic", and supports_native_structured_output is still absent from both files:

litellm_oss_staging : model_prices_and_context_window.json
  claude-haiku-4-5            native_structured=ABSENT  provider=anthropic
  claude-haiku-4-5-20251001   native_structured=ABSENT  provider=anthropic
litellm_oss_staging : litellm/model_prices_and_context_window_backup.json
  claude-haiku-4-5            native_structured=ABSENT  provider=anthropic
  claude-haiku-4-5-20251001   native_structured=ABSENT  provider=anthropic

So the fix is still live, and the diff is now only the four added lines, two per file. Mergeable state is CLEAN.

All three of your earlier points are addressed: the whole-file reformat is reverted, the bundled backup is synced (that was the reason the flag did not take effect at runtime, since local mode reads the backup), and the verification returns True for both names.

No rush at all, and I realise a metadata flag is low on the queue. Flagging mainly because it is a four-line data change that will keep silently drifting out of date while it sits. Happy to rebase if it picks up a conflict.

@adhavan18

Copy link
Copy Markdown
Author

still relevant. same note as #31211: only 3 checks have ever run on this one (PR title, CodeRabbit, Veria), because fork PRs need a maintainer to approve the workflow run, so the full suite has never executed.

could someone approve it? this is a model_prices json addition so it should be quick to verify once validate-model-prices-json actually runs. happy to rebase first if that helps.

@adhavan18

Copy link
Copy Markdown
Author

recheck

1 similar comment
@adhavan18

Copy link
Copy Markdown
Author

recheck

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Superseded by rolling registry PR #38207, whose branch already carries both supports_native_structured_output flags, confirmed against Anthropic's structured outputs docs

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.

3 participants