Skip to content

Conversation

@woustachemax
Copy link

Background

When AI providers release new model versions (e.g., Anthropic's claude-sonnet-4-5claude-sonnet-5-0), users currently need to update model IDs throughout their entire codebase. This creates maintenance overhead and makes applications brittle to version changes.

Summary

Added automatic model version resolution using --latest suffix (similar to Docker's :latest tag). Users can now reference models like anthropic:claude-sonnet--latest which automatically resolves to the newest version defined in a centralized mapping file.

Changes:

  • Added LATEST_VERSIONS mapping for major providers (Anthropic, OpenAI, Google, Mistral, DeepSeek, xAI, Cohere, Groq)
  • Added resolveLatestVersion() function to handle version resolution
  • Modified provider registry languageModel() method to use version resolution
  • Added comprehensive test coverage (5 tests, all passing)
  • Added usage example demonstrating the feature

Manual Verification

  1. Built the package successfully (pnpm build)
  2. Ran all tests - 1651 tests passing including 5 new tests for the feature
  3. Created example file showing usage with --latest suffix
  4. Verified resolution works correctly for multiple providers in tests

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Future Work

  • Add --latest support for other model types (embedding, image, transcription, speech)
  • Consider dynamic version fetching from provider APIs
  • Add support for other version strategies (e.g., --stable, --experimental)
  • CLI tool to automatically update LATEST_VERSIONS mapping

Related Issues

N/A - This is a new feature enhancement

Adds automatic model version resolution using --latest suffix.
Users can now use model IDs like 'anthropic:claude-sonnet--latest'
which automatically resolve to the newest version.

- Added LATEST_VERSIONS mapping for major providers (Anthropic, OpenAI, Google, etc.)
- Added resolveLatestVersion() function to handle version resolution
- Modified provider registry languageModel() to use version resolution
- Added comprehensive test coverage (5 tests, all passing)
- Added usage example demonstrating the feature

This allows centralized version management - when providers release
new versions, users only need to update the mapping file instead of
changing code throughout their application.
@vercel-ai-sdk vercel-ai-sdk bot added ai/core ai/provider provider/anthropic provider/cohere Issues related to the @ai-sdk/cohere provider labels Jan 6, 2026
@lgrammel
Copy link
Collaborator

lgrammel commented Jan 7, 2026

Hardcoding provider specific model ids in the ai package is not something we want to do.

@woustachemax
Copy link
Author

thanks for the feedback, makes sense! would it be okay if i move the version mappings to individual provider packages or make it user configurable in the registry?​​​​​​​​​​​​​​​​

@lgrammel
Copy link
Collaborator

lgrammel commented Jan 7, 2026

let me discuss internally how to approach this; i can see the use case

@woustachemax
Copy link
Author

sure, thanks! looking forward to hearingback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/core ai/provider provider/anthropic provider/cohere Issues related to the @ai-sdk/cohere provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants