Guide for adding first-party AI provider packages to the AI SDK. Use when creating a provider package under packages/ to integrate an external AI service.
62
75%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./skills/add-provider-package/SKILL.mdAdd a complete first-party @ai-sdk/<provider> package that follows the current provider interfaces, repository conventions, security requirements, and release process.
Before implementing anything, read:
Use PR #18595 as a recent end-to-end example, but choose the current provider package whose API shape and model types most closely resemble the new provider as the implementation reference.
Third parties can publish provider packages outside this repository. A new first-party @ai-sdk/<provider> package requires prior discussion in an issue. Confirm that agreement exists before implementing the package.
Before designing model classes, look for an official, versioned OpenAPI or Swagger specification in the provider's documentation or repositories. Prefer first-party specifications and record the source URL plus its version, publication date, or commit in the implementation notes or pull request.
Use the specification and official documentation to identify:
Treat an OpenAPI specification as implementation evidence, not unquestioned truth. Specifications are often incomplete for server-sent events, streaming deltas, polymorphic content, tool calls, nullable fields, and errors. Do not add a generated client or generated production types by default. Implement minimal hand-written types and Zod schemas, then verify them against official documentation and captured API responses.
If no official specification exists, derive the contract from official documentation and real response fixtures, and note that limitation in the pull request.
Determine which AI SDK model interfaces the provider supports, such as LanguageModelV4, EmbeddingModelV4, ImageModelV4, SpeechModelV4, TranscriptionModelV4, RerankingModelV4, or Experimental_VideoModelV4.
Before introducing a dependency, public API pattern, or new abstraction, read contributing/decisions/README.md and relevant accepted ADRs. Prefer existing provider utilities and implementation patterns.
Create packages/<provider>/ by adapting a current, comparable provider package. A typical package contains:
packages/<provider>/
├── src/
│ ├── index.ts
│ ├── version.ts
│ ├── <provider>-provider.ts
│ ├── <provider>-provider.test.ts
│ ├── <provider>-<model-type>-model.ts
│ ├── <provider>-<model-type>-model.test.ts
│ └── <provider>-<model-type>-options.ts
├── CHANGELOG.md
├── README.md
├── package.json
├── tsconfig.json
├── tsconfig.build.json
├── tsup.config.ts
├── turbo.json
├── vitest.node.config.js
└── vitest.edge.config.jsPreserve current package conventions rather than recreating configuration from memory:
2.0.0, with no prerelease suffix.CHANGELOG.md with an initial # @ai-sdk/<provider> heading.tsup package-version injection pattern../node_modules/@vercel/ai-tsconfig/ts-library.json, enable a composite project, and add package references for workspace dependencies.files, documentation prepack, repository, bugs, engines, and public provenance publishing metadata.workspace:* for AI SDK workspace dependencies. Add @ai-sdk/test-server only when tests use it.zod/v4 for new implementation schemas.Run pnpm update-references after adding or changing workspace dependencies.
Follow the current provider factory pattern:
ProviderV4.create<Provider>(settings) and a default provider instance.provider.specificationVersion = 'v4'.ProviderV4, such as languageModel, embeddingModel, and imageModel.chat, embedding, or image only when they improve the provider's API.NoSuchModelError from unsupported required model factories.apiKey, baseURL, headers, and a custom fetch implementation.loadApiKey or the appropriate shared utility, normalize configurable base URLs, and include the package version in the user-agent suffix.VERSION from src/index.ts.Implement each supported model using the appropriate interface from @ai-sdk/provider and shared utilities from @ai-sdk/provider-utils.
Provider option types and schemas must follow the repository naming and export rules. User-facing option fields should use .optional() unless null is meaningful. Response schemas should be minimal, tolerate unused provider fields, and use .nullish() where the API may omit or return null.
All model classes must implement the workflow serialization contract described in Provider development notes:
WORKFLOW_SERIALIZE and WORKFLOW_DESERIALIZE static methodsserializeModel, serializeModelOptions, or the matching existing patternJSON.parse in production code. Use parseJSON or safeParseJSON from @ai-sdk/provider-utils.createJsonResponseHandler and createJsonErrorResponseHandler.AISDKError subclass only when the package needs a new public SDK error type; ordinary provider HTTP failures should use the shared API error handling.validateUrl explicitly on every getFromApi call.validateUrl: true when the URL host or scheme comes from a provider response, and false when it is derived from a developer-configured base URL.trustedOrigin for legitimate response URLs that may point to a configured private or self-hosted endpoint.credentialedOrigin when credentials may be sent on the first hop, so they are withheld from off-origin URLs and redirects.Read Secure URL handling before implementing any polling or provider-supplied download URL flow.
Add focused tests for:
Use real provider responses as fixtures when practical. Read the capture API response fixture skill before capturing them. Trim oversized fixtures only when doing so does not change their semantics.
Read the AI Functions example skill before adding examples.
For each supported model type, put the entry example at:
examples/ai-functions/src/<function>/<provider>/basic.tsPut additional examples in the same provider directory with descriptive kebab-case.ts names. Do not create flat provider files such as src/generate-text/<provider>.ts.
Also update the relevant repository integration points:
@ai-sdk/<provider> to examples/ai-functions/package.jsonexamples/ai-functions/tsconfig.jsonexamples/ai-functions/.env.exampleturbo.json environment configuration when neededpnpm update-references to update root and package TypeScript referencesRun representative examples against the real API and confirm both non-streaming and streaming behavior when supported.
README.md with installation, authentication, configuration, supported models, and basic usage.content/providers/01-ai-sdk-providers/<last number + 10>-<provider>.mdx with setup, model capabilities, provider options, and examples.Create a major changeset for the new provider package. The repository package remains at plain 2.0.0; do not add -beta, -canary, or another prerelease suffix.
Before the first automated release, coordinate with the Vercel IT team to bootstrap an empty @ai-sdk/<provider> package on npm at 0.0.0 and configure its Trusted Publisher. Follow Bootstrapping a new @ai-sdk/* package. The temporary npm bootstrap version is separate from the repository package version.
When main is in prerelease mode, do not backport the new package to a stable vX.Y branch.
Run, at minimum:
pnpm --filter @ai-sdk/<provider> build
pnpm --filter @ai-sdk/<provider> test
pnpm --filter @ai-sdk/<provider> type-check
pnpm type-check:full
pnpm checkAlso run the new examples with the required provider credentials. Run the root build when changes to shared packages or build configuration make it relevant.
2.0.0ProviderV4If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.