Skip to content

Conversation

@eparreno
Copy link

@eparreno eparreno commented Jan 20, 2026

Why

When using the google-vertex-anthropic provider, model IDs like claude-sonnet-4-5 fail to match pricing data because models.dev stores them with date suffixes like claude-sonnet-4-5@20250929. This causes the pricing lookup to fail silently, defaulting costs to 0, resulting in sessions always showing $0.00 pricing.

fixes #9565

What

Add fallback logic in the getModel() function that:

  • Only applies to google-vertex-anthropic provider (not google-vertex)
  • Searches for versioned models matching the unversioned ID pattern
  • Returns the latest version (reverse-sorted by date suffix)
  • Maintains backward compatibility with versioned IDs
  • Falls back to standard error handling if no match is found

The fix is transparent to users - no configuration changes needed. Sessions now compute accurate costs from the resolved versioned model IDs.

Testing

Added 3 comprehensive tests:

  1. Unversioned model ID resolves to latest versioned model with correct pricing
  2. Backward compatibility: versioned model IDs still work directly
  3. Provider-specific: fallback only applies to google-vertex-anthropic, not google-vertex

All 69 provider tests pass.

…to versioned ones

When using google-vertex-anthropic, model IDs like 'claude-sonnet-4-5' were
failing to match pricing data because models.dev stores them with date
suffixes like 'claude-sonnet-4-5@20250929'. This caused the pricing lookup
to fail silently, defaulting costs to 0.

Add fallback logic in getModel() that:
- Only applies to google-vertex-anthropic provider
- Searches for versioned models matching the unversioned ID pattern
- Returns the latest version (reverse-sorted by date)
- Maintains backward compatibility with versioned IDs
- Falls back to standard error handling if no match found

Fixes pricing computation so session costs are now calculated correctly
instead of always showing $0.00 for google-vertex-anthropic models.
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

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.

Incorrect model IDs for Vertex Anthropic

1 participant