npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-sdk-model-picker

v1.2.1

Published

NPM library for creating AI model pickers in a standardized fashion based on Vercel AI SDK

Readme

ai-sdk-model-picker

NPM library for creating AI model pickers in a standardized fashion based on Vercel AI SDK.

A project vibe coded by Eric Burel at LBKE, a French training organisation (🇫🇷) with Claude Code.

Features

  • ✅ Support for official Vercel AI SDK providers
  • ✅ List available providers and their models
  • ✅ Dynamic model filtering with flexible options
  • ✅ Dynamic importing of AI SDK provider packages, using JavaScript import()
  • ✅ API key name resolution for each provider
  • ✅ Provider name synonyms support (e.g., "mistralai" → "mistral")
  • ✅ TypeScript support with comprehensive type definitions
  • ✅ Works in both Node.js and browser environments

⚠️ Providers list is maintained manually, please contribute!

Installation

First, install the dependencies for the providers you'll want to support. This package helps picking a provider and loading the right package, but won't install the dependencies for you in order to streamline your JS bundle.

npm install ai 
# Pick the providers you want to support
npm install @ai-sdk/mistral @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/groq @ai-sdk/google

💡 Want more providers? Contribute to the providers list!

npm install ai-sdk-model-picker

Usage

Basic Usage

import { providers, mistralModels, listProviderModels, findModels, loadModel, getApiKeyName } from "ai-sdk-model-picker"

// List all available providers
console.log(providers)
// Output: [{name: "openai", packageName: "@ai-sdk/openai", apiKeyName: "OPENAI_API_KEY"}, ...]

// Get models for Mistral provider
console.log(mistralModels)
// Output: [{name: "mistral-large-latest", type: "language", capabilities: {...}}, ...]

// List models for a specific provider
console.log(listProviderModels({provider: "mistralai"}))
// Output: {provider: "mistralai", models: [{name:"mistral-large-latest", ...}]}

// List models for multiple providers or run a free search (outputs an array of providers + models)
console.log(findModels({providers: ["mistralai", "openai"]}))
// Output: [{provider: "mistralai", models: [{name:"mistral-large-latest", ...}]}]

// List models excluding certain providers/models
console.log(findModels({
  excludedProviders: ["xai"], 
  excludedModels: ["mistralai/codestral-latest"]
}))

// Get API key name for a provider
console.log(getApiKeyName("mistralai"))
// Output: "MISTRAL_API_KEY"

// Load a model dynamically (triggers dynamic import of the provider package)
const modelResult = await loadModel("mistralai/mistral-large-latest")
// This will:
// 1. Dynamically import @ai-sdk/mistral
// 2. Create the model instance: mistral("mistral-large-latest")
// 3. Return {model: <model_instance>, provider: "mistralai", modelName: "mistral-large-latest"}

Advanced Filtering

import { findModels } from "ai-sdk-model-picker"

// Filter by model type
const languageModels = findModels({ modelType: 'language' })
const embeddingModels = findModels({ modelType: 'embedding' })
const imageModels = findModels({ modelType: 'image' })

// Complex filtering example
const filteredModels = findModels({
  providers: ["openai", "anthropic", "mistralai"],
  excludedModels: ["gpt-3.5-turbo", "claude-3-haiku-20240307"],
  modelType: "language"
})

Using with Vercel AI SDK

import { loadModel, getApiKeyName } from "ai-sdk-model-picker"
import { generateText } from "ai"

// Set up environment variables
const provider = "openai"
const modelName = "gpt-4"
const apiKeyName = getApiKeyName(provider)
console.log(`Make sure to set ${apiKeyName} environment variable`)

// Load and use the model
const { model } = await loadModel(`${provider}/${modelName}`)

const { text } = await generateText({
  model: model,
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
})

console.log(text)

Provider Synonyms

The library supports provider name synonyms for better developer experience:

import { findModels, getApiKeyName } from "ai-sdk-model-picker"

// These are equivalent:
console.log(findModels({provider: "mistral"}))
console.log(findModels({provider: "mistralai"}))

// Both return "MISTRAL_API_KEY"
console.log(getApiKeyName("mistral"))
console.log(getApiKeyName("mistralai"))

Supported Providers

This library supports all official AI SDK providers:

| Provider | Package | API Key | Synonyms | |----------|---------|---------|-----------| | OpenAI | @ai-sdk/openai | OPENAI_API_KEY | - | | Anthropic | @ai-sdk/anthropic | ANTHROPIC_API_KEY | - | | Mistral AI | @ai-sdk/mistral | MISTRAL_API_KEY | mistral | | Groq | @ai-sdk/groq | GROQ_API_KEY | - | | xAI Grok | @ai-sdk/xai | XAI_API_KEY | - | | Google | @ai-sdk/google | GOOGLE_GENERATIVE_AI_API_KEY | - |

Model Types

Models are categorized by type:

  • language: Text generation models (GPT-4, Claude, etc.)
  • embedding: Text embedding models
  • image: Image generation models (DALL-E, etc.)
  • transcription: Audio transcription models (Whisper)
  • speech: Text-to-speech models

API Reference

providers: Provider[]

Array of all available providers with their basic information.

interface Provider {
  name: string;
  packageName: string;
  apiKeyName: string;
  synonyms?: string[];
}

mistralModels: Model[]

Convenience export for Mistral AI models.

findModels(options?: findModelsOptions): Array<{provider: string, models: Model[]}>

List models with flexible filtering options.

interface findModelsOptions {
  provider?: string;           // Single provider name
  providers?: string[];        // Multiple provider names
  excludedProviders?: string[]; // Providers to exclude
  excludedModels?: string[];   // Models to exclude (format: "provider/model" or just "model")
  modelType?: 'language' | 'embedding' | 'image' | 'transcription' | 'speech';
}

loadModel(modelId: string): Promise<LoadModelResult>

Dynamically load a model from its provider package.

interface LoadModelResult {
  model: any;      // The loaded model instance
  provider: string; // Provider name
  modelName: string; // Model name
}

Model ID Format: "provider/model" (e.g., "openai/gpt-4", "mistralai/mistral-large-latest")

getApiKeyName(providerName: string): string

Get the environment variable name for a provider's API key.

Error Handling

The library provides descriptive error messages for common issues:

try {
  const model = await loadModel("invalid/model")
} catch (error) {
  console.error(error.message)
  // "Provider 'invalid' not found"
}

try {
  const apiKey = getApiKeyName("nonexistent")
} catch (error) {
  console.error(error.message)
  // "Provider 'nonexistent' not found"
}

Contributing

Contributions are welcome! The provider data is maintained in src/data/providers.ts. To add support for new providers:

  1. Add the provider data to PROVIDERS_DATA
  2. Add any synonyms to PROVIDER_SYNONYMS
  3. Update the README documentation
  4. Add tests for the new provider

You can test the "basic-demo.html" example using http-server. Currently, you'll need to manually copy the built "index.mjs" file in the examples folder.

License

MIT


Based on research from ai-sdk.dev/providers/ai-sdk-providers