add-provider-package▌
vercel/ai · updated Apr 8, 2026
MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.
This guide covers the process of creating a new @ai-sdk/<provider> package to integrate an AI service into the AI SDK.
Adding a New Provider Package
This guide covers the process of creating a new @ai-sdk/<provider> package to integrate an AI service into the AI SDK.
First-Party vs Third-Party Providers
- Third-party packages: Any provider can create a third-party package. We're happy to link to it from our documentation.
- First-party
@ai-sdk/<provider>packages: If you prefer a first-party package, please create an issue first to discuss.
Reference Example
See https://github.com/vercel/ai/pull/8136/files for a complete example of adding a new provider.
Provider Architecture
The AI SDK uses a layered provider architecture following the adapter pattern:
- Specifications (
@ai-sdk/provider): Defines interfaces likeLanguageModelV4,EmbeddingModelV4, etc. - Utilities (
@ai-sdk/provider-utils): Shared code for implementing providers - Providers (
@ai-sdk/<provider>): Concrete implementations for each AI service - Core (
ai): High-level functions likegenerateText,streamText,generateObject
Step-by-Step Guide
1. Create Package Structure
Create a new folder packages/<provider> with the following structure:
packages/<provider>/
├── src/
│ ├── index.ts # Main exports
│ ├── version.ts # Package version
│ ├── <provider>-provider.ts # Provider implementation
│ ├── <provider>-provider.test.ts
│ ├── <provider>-*-options.ts # Model-specific options
│ └── <provider>-*-model.ts # Model implementations (e.g., language, embedding, image)
├── package.json
├── tsconfig.json
├── tsconfig.build.json
├── tsup.config.ts
├── turbo.json
├── vitest.node.config.js
├── vitest.edge.config.js
└── README.md
Do not create a CHANGELOG.md file. It will be auto-generated.
2. Configure package.json
Set up your package.json with:
"name": "@ai-sdk/<provider>""version": "0.0.0"(initial version, will be updated by changeset)"license": "Apache-2.0""sideEffects": false- Dependencies on
@ai-sdk/providerand@ai-sdk/provider-utils(useworkspace:*) - Dev dependencies:
@ai-sdk/test-server,@types/node,@vercel/ai-tsconfig,tsup,typescript,zod "engines": { "node": ">=18" }- Peer dependency on
zod(both v3 and v4):"zod": "^3.25.76 || ^4.1.8"
Example exports configuration:
{
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
}
}
3. Create TypeScript Configurations
tsconfig.json:
{
"extends": "@vercel/ai-tsconfig/base.json",
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "dist"]
}
tsconfig.build.json:
{
"extends": "./tsconfig.json",
"exclude": [
"**/*.test.ts",
"**/*.test-d.ts",
"**/__snapshots__",
"**/__fixtures__"
]
}
4. Configure Build Tool (tsup)
Create tsup.config.ts:
import { defineConfig } from 'tsup';
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
sourcemap: true,
clean: true,
});
5. Configure Test Runners
Create both vitest.node.config.js and vitest.edge.config.js (copy from existing provider like anthropic).
6. Implement Provider
Provider implementation pattern:
// <provider>-provider.ts
import { NoSuchModelError } from '@ai-sdk/provider';
import { loadApiKey } from '@ai-sdk/provider-utils';
export interface ProviderSettings {
apiKey?: string;
baseURL?: string;
// provider-specific settings
}
export class ProviderInstance {
readonly apiKey?: string;
readonly baseURL?: string;
constructor(options: ProviderSettings = {}) {
this.apiKey = options.apiKey;
this.baseURL = options.baseURL;
}
private get baseConfig() {
return {
apiKey: () =>
loadApiKey({
apiKey: this.apiKey,
environmentVariableName: 'PROVIDER_API_KEY',
description: 'Provider API key',
}),
baseURL: this.baseURL ?? 'https://api.provider.com',
};
}
languageModel(modelId: string) {
return new ProviderLanguageModel(modelId, this.baseConfig);
}
// Shorter alias
chat(modelId: string) {
return this.languageModel(modelId);
}
}
// Export default instance
export const providerName = new ProviderInstance();
7. Implement Model Classes
Each model type (language, embedding, image, etc.) should implement the appropriate interface from @ai-sdk/provider:
LanguageModelV4for text generation modelsEmbeddingModelV4for embedding modelsImageModelV4for image generation models- etc.
Schema guidelines:
Provider Options (user-facing):
- Use
.optional()unlessnullis meaningful - Be as restrictive as possible for future flexibility
Response Schemas (API responses):
- Use
.nullish()instead of.optional() - Keep minimal - only include properties you need
- Allow flexibility for provider API changes
8. Create README.md
Include:
- Brief description linking to documentation
- Installation instructions
- Basic usage example
- Link to full documentation
9. Write Tests
- Unit tests for provider logic
- API response parsing tests using fixtures in
__fixtures__subdirectory - Both Node.js and Edge runtime tests
See capture-api-response-test-fixture skill for capturing real API responses for testing.
10. Add Examples
Create examples in examples/ai-functions/src/ for each model type the provider supports:
generate-text/<provider>.ts- Basic text generationstream-text/<provider>.ts- Streaming textgenerate-object/<provider>.ts- Structured output (if supported)stream-object/<provider>.ts- Streaming structured output (if supported)embed/<provider>.ts- Embeddings (if supported)generate-image/<provider>.ts- Image generation (if supported)- etc.
Add feature-specific examples as needed (e.g., <provider>-tool-call.ts, <provider>-cache-control.ts).
11. Add Documentation
Create documentation in content/providers/01-ai-sdk-providers/<last number + 10>-<provider>.mdx
Include:
- Setup instructions
- Available models
- Model capabilities
- Provider-specific options
- Usage examples
- API configuration
12. Create Changeset
Run pnpm changeset and:
- Select the new provider package
- Choose
majorversion (for new packages starting at 0.0.0) - Describe what the package provides
13. Update References
Run pnpm update-references from the workspace root to update tsconfig references.
14. Build and Test
# From workspace root
pnpm build
# From provider package
cd packages/<provider>
pnpm test # Run all tests
pnpm test:node # Run Node.js tests
pnpm test:edge # Run Edge tests
pnpm type-check # Type checking
# From workspace root
pnpm type-check:full # Full type check including examples
15. Run Examples
Test your examples:
cd examples/ai-functions
pnpm tsx src/generate-text/<provider>.ts
pnpm tsx src/stream-text/<provider>.ts
Provider Method Naming
- Full names:
languageModel(id),imageModel(id),embeddingModel(id)(required) - Short aliases:
.chat(id),.image(id),.embedding(id)(for DX)
File Naming Conventions
- Source files:
kebab-case.ts - Test files:
kebab-case.test.ts - Type test files:
kebab-case.test-d.ts - Provider classes:
<Provider>Provider,<Provider>LanguageModel, etc.
Security Best Practices
- Never use
JSON.parsedirectly - useparseJSONorsafeParseJSONfrom@ai-sdk/provider-utils - Load API keys securely using
loadApiKeyfrom@ai-sdk/provider-utils - Validate all API responses against schemas
Error Handling
Errors should extend AISDKError from @ai-sdk/provider and use a marker pattern:
import { AISDKError } from '@ai-sdk/provider';
const name how to use add-provider-packageHow to use add-provider-package on Cursor
AI-first code editor with Composer
1Prerequisites
Before installing skills in Cursor, ensure your development environment meets these requirements:
- ›Cursor installed and configured on your development machine
- ›Node.js version 16.0+ with npm package manager (verify with
node --version) - ›Active project directory or workspace where you want to add add-provider-package
2Execute installation command
Execute the skills CLI command in your project's root directory to begin installation:
$npx skills add https://github.com/vercel/ai --skill add-provider-packageThe skills CLI fetches add-provider-package from GitHub repository vercel/ai and configures it for Cursor.
3Select Cursor when prompted
The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:
◆ Which agents do you want to install to?││ ── Universal (.agents/skills) ── always included ────│ • Amp│ • Antigravity│ • Cline│ • Codex│ ●Cursor(selected)│ • Cursor│ • Windsurf4Verify installation
Confirm successful installation by checking the skill directory location:
.cursor/skills/add-provider-packageReload or restart Cursor to activate add-provider-package. Access the skill through slash commands (e.g., /add-provider-package) or your agent's skill management interface.
⚠Security & Verification Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.
Additional Resources
List & Monetize Your Skill
Submit your Claude Code skill and start earning
GET_STARTED →Use Cases▌
User Story & Requirements Generation
Create detailed user stories, acceptance criteria, and feature specs
Example
Generate user stories for 'password reset feature' with acceptance criteria, edge cases, and test scenarios
✓Reduce spec writing time by 50%, ensure comprehensive coverage
Competitive Analysis
Research competitors, compare features, identify gaps
Example
Analyze 5 competitor products, create feature comparison matrix, suggest differentiation opportunities
✓Complete competitive research in 2 hours instead of 2 days
Roadmap Prioritization
Evaluate features using frameworks (RICE, ICE, Kano) and create prioritized backlogs
Example
Score 20 feature ideas using RICE framework, generate prioritized roadmap with rationale
✓Make data-driven prioritization decisions faster
Stakeholder Communication
Draft PRDs, status updates, and stakeholder presentations
Example
Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement
✓Save 3-5 hours/week on communication overhead
Implementation Guide▌
Prerequisites
- ›Claude Desktop or compatible AI client
- ›Access to product documentation and roadmap tools (Jira, Notion, etc.)
- ›Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
- ›Stakeholder contact information and communication channels
Time Estimate
30-60 minutes to see productivity improvements
Installation Steps
- 1.Install product management skill
- 2.Start with user story generation for known feature
- 3.Progress to competitive analysis: research 2-3 competitors
- 4.Use for roadmap prioritization: apply RICE/ICE scoring
- 5.Draft stakeholder communications and refine based on feedback
- 6.Build template library for recurring PM tasks
- 7.Share effective prompts with product team
Common Pitfalls
- ⚠Not validating competitive research—verify facts before sharing
- ⚠Accepting user stories without involving engineering team
- ⚠Over-relying on frameworks without qualitative judgment
- ⚠Not customizing outputs to company culture and communication style
- ⚠Skipping stakeholder validation of generated requirements
Best Practices▌
✓ Do
- +Validate research and competitive analysis with real data
- +Collaborate with engineering when generating technical requirements
- +Customize frameworks and templates to your company context
- +Use skill for first drafts, refine with stakeholder input
- +Document successful prompt patterns for PM tasks
- +Combine AI efficiency with human judgment and intuition
✗ Don't
- −Don't publish competitive analysis without fact-checking
- −Don't finalize user stories without engineering review
- −Don't make prioritization decisions solely on AI scoring
- −Don't skip customer validation of generated requirements
- −Don't ignore company-specific context and culture
💡 Pro Tips
- ★Provide context: company goals, constraints, customer feedback
- ★Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
- ★Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
- ★Use skill for 70% generation + 30% customization to company needs
When to Use This▌
✓ Use When
Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.
✗ Avoid When
Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.
Learning Path▌
- 1Basic: user stories, feature specs, status updates
- 2Intermediate: competitive analysis, prioritization frameworks, PRDs
- 3Advanced: product strategy, go-to-market planning, OKR setting
- 4Expert: product vision, market positioning, business model innovation
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
general reviewsRatings
4.6★★★★★42 reviews- ★★★★★Pratham Ware· Dec 28, 2024
Useful defaults in add-provider-package — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Hassan Rao· Dec 28, 2024
add-provider-package has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Hassan Reddy· Dec 24, 2024
add-provider-package fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Hassan Sethi· Dec 20, 2024
I recommend add-provider-package for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Sakshi Patil· Nov 19, 2024
add-provider-package has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Kaira Diallo· Nov 19, 2024
Useful defaults in add-provider-package — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Jin Chawla· Nov 15, 2024
add-provider-package is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
- ★★★★★Daniel Jackson· Nov 11, 2024
Solid pick for teams standardizing on skills: add-provider-package is focused, and the summary matches what you get after install.
- ★★★★★Chaitanya Patil· Oct 10, 2024
Solid pick for teams standardizing on skills: add-provider-package is focused, and the summary matches what you get after install.
- ★★★★★Kaira Smith· Oct 10, 2024
I recommend add-provider-package for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
showing 1-10 of 42
1 / 5