contributing/pre-release-cycle.md
This guide explains how to start and end a pre-release (beta) cycle for a new major version of the AI SDK.
Every major release of the AI SDK introduces a new provider specification version (e.g. V3 to V4). Evolving the spec is the reason we do major releases — it lets us make breaking changes to the provider interface while giving provider authors a clear migration target.
A pre-release cycle lets us develop the next major version on main while keeping the current stable version available for patches. During the cycle:
main publishes beta releases (e.g. [email protected])release-v6.0) receives backported patches and publishes stable releasesCreate a branch from the current main HEAD so the current stable version can continue receiving patches:
git checkout main
git pull origin main
git checkout -b release-v<current-major>.0 # e.g. release-v6.0
git push origin release-v<current-major>.0
The release workflow already runs on release-v* branches, so no workflow changes are needed.
On the new maintenance branch, update the ci:release script in the root package.json to publish with a version-specific npm dist-tag. This prevents maintenance releases from taking over the latest tag on npm:
- "ci:release": "turbo clean && turbo build && changeset publish",
+ "ci:release": "turbo clean && turbo build && changeset publish --tag ai-v<current-major>",
For example, for release-v6.0 use --tag ai-v6. Commit and push the change directly to the maintenance branch.
mainSwitch back to main and enter changeset pre-release mode:
git checkout main
pnpm changeset pre enter beta
This modifies .changeset/pre.json. The initialVersions field should only contain packages from packages/*/package.json files — remove any other entries (e.g. @example/*, tools/*, or nested test packages). Commit and push the change (or open a PR).
Create a changeset that bumps every published package to the next major version:
pnpm changeset
Select all packages from packages/*/package.json (skip @example/*, tools/*, and any other non-packages/ entries — they are private and not published) and choose major for each. Write a summary like:
Start v7 pre-release
Commit the generated .changeset/*.md file.
Every major release introduces a new provider specification version (e.g. V3 to V4). You must create a new version directory for every spec directory under packages/provider/src/ that contains a versioned subdirectory. To find them, run:
ls -d packages/provider/src/*/v3
As of writing, the directories are: embedding-model, embedding-model-middleware, image-model, image-model-middleware, language-model, language-model-middleware, provider, reranking-model, shared, speech-model, transcription-model, video-model.
For each directory:
v3/) to a new version directory (e.g. v4/).language-model-v3.ts → language-model-v4.ts).V3 → V4, v3 → v4 in type names, imports, and the specificationVersion literal).export * from './v4/index'; to the parent index.ts (before the v3 export).provider v4 spec imports other model types, ensure it imports from the new v4 paths (not v3).Verify by running pnpm build in packages/provider — all new types should appear in the built .d.ts output.
Create V4 counterparts for every mock file in packages/ai/src/test/ (e.g. mock-language-model-v3.ts → mock-language-model-v4.ts). Update packages/ai/test/index.ts to export the new V4 mocks.
packages/ai for the new spec versionThe core packages/ai package needs adapter functions, updated public APIs, and test updates to support the new spec version alongside older ones.
Create V4 adapter files in packages/ai/src/model/ for each model type. These use a Proxy to convert V3 models to V4 by overriding specificationVersion:
as-language-model-v4.tsas-embedding-model-v4.tsas-image-model-v4.tsas-speech-model-v4.tsas-transcription-model-v4.tsas-reranking-model-v4.tsas-video-model-v4.tsas-provider-v4.ts (converts a V3 provider to V4 by wrapping all model factory methods)Each adapter checks specificationVersion and returns the model as-is if already V4, or wraps it in a Proxy otherwise.
Each adapter should have a corresponding test file (e.g. as-language-model-v4.test.ts) that verifies:
.toBe())specificationVersion changed to 'v4'Update the following files to accept V2 | V3 | V4 models at their public boundaries, converting to V4 internally using the adapters:
packages/ai/src/middleware/wrap-language-model.ts — accept LanguageModelV2 | V3 | V4packages/ai/src/middleware/wrap-image-model.ts — accept ImageModelV2 | V3 | V4packages/ai/src/middleware/wrap-embedding-model.ts — accept EmbeddingModelV3 | V4 (V2 is generic, not included; V3 kept for backward compatibility)packages/ai/src/registry/custom-provider.ts — accept V2/V3/V4 models in all model mapspackages/ai/src/registry/provider-registry.ts — accept ProviderV2 | V3 | V4, convert with asProviderV4packages/ai/src/types/language-model-middleware.ts — relax to accept both V3 and V4 middlewareas-language-model-v4.test.ts), verifying identity pass-through, V3→V4 conversion, and V2→V4 conversion.resolve-model.test.ts to test both V3→V4 conversion (using V3 mocks) and V4 pass-through (using V4 mocks) as separate test blocks.custom-provider.test.ts, provider-registry.test.ts, middleware tests). Use V4 mocks for any test that checks reference equality (.toBe()) on returned models.Run pnpm test in packages/ai and pnpm type-check:full from the workspace root to verify.
The documentation site lives in the ai-studio repository and uses a Git submodule pointing at this repository. During the pre-release cycle the site needs versioned branches and Vercel deployments for both stable and beta docs.
In the vercel/ai repository:
.github/workflows/update-sdk-submodule-v6.yml to track the release-v6.0 branch instead of main..github/workflows/update-sdk-submodule-v7.yml — this workflow fetches main, checks out the sdk/v7 branch in ai-studio, and pushes to origin sdk/v7.In the ai-studio repository:
sdk/v7 branch (the default branch stays sdk/v6 for now so the production site continues serving stable docs).sdk/v7 branch (e.g. v7.ai-sdk.dev).mainOpen a PR with all the changes from steps 3-7. Once merged, the first beta release (e.g. [email protected]) will be published automatically.
main.patch by default).To backport a fix from main to the maintenance branch, add the backport label to the merged PR. This creates a new PR targeting the maintenance branch automatically.
Patches merged into the maintenance branch trigger the release workflow and publish stable patch releases.
When the new major version is ready for stable release:
git checkout main
pnpm changeset pre exit
This removes .changeset/pre.json. Commit and push (or open a PR).
Once the exit-PR is merged, the next Version Packages PR will produce stable versions (e.g. [email protected]). Merge it to publish.
In the ai-studio repository, change the default branch from sdk/v6 to sdk/v7 so the production site serves the new major version. Update the Vercel production deployment accordingly.
The maintenance branch (e.g. release-v6.0) can remain for emergency patches but will no longer receive regular backports.