Skip to content

LLM Providers

Amplify supports 22+ LLM providers through a plugin registry architecture. Every provider extends the BaseProvider abstract class and is auto-discovered by the LLMManager singleton.

Provider overview

Amplify's provider system is designed for maximum flexibility — you can swap between providers freely, add custom OpenAI-compatible endpoints, and use both cloud and local models simultaneously.

Providers are classified into three categories:

CategoryProvidersKey feature
Cloud (API key)OpenAI, Anthropic, Google, Deepseek, Groq, Mistral, Cohere, Together, xAI, Perplexity, Moonshot, Z.ai, HuggingFace, Hyperbolic, Fireworks, Cerebras, Github, OpenRouter, AmazonBedrockRemote API with per-request billing
Local (baseUrl)Ollama, LMStudio, OpenAILikeSelf-hosted models, no API key needed
Routing/MetaOpenRouterAggregates multiple providers, shows pricing

All 22 registered providers

#ProviderAPI Key Env VarBase URL Env VarDynamic Models?SDK
1AnthropicANTHROPIC_API_KEYYes@ai-sdk/anthropic
2AmazonBedrockAWS_BEDROCK_CONFIG (JSON)No@ai-sdk/amazon-bedrock
3CerebrasCEREBRAS_API_KEYYes@ai-sdk/cerebras
4CohereCOHERE_API_KEYNo@ai-sdk/cohere
5DeepseekDEEPSEEK_API_KEYYes@ai-sdk/deepseek
6FireworksFIREWORKS_API_KEYYes@ai-sdk/fireworks
7GithubGITHUB_API_KEYYes@ai-sdk/openai (models.github.ai)
8GoogleGOOGLE_GENERATIVE_AI_API_KEYYes@ai-sdk/google
9GroqGROQ_API_KEYYes@ai-sdk/openai (api.groq.com)
10HuggingFaceHuggingFace_API_KEYNo@ai-sdk/openai
11HyperbolicHYPERBOLIC_API_KEYYes@ai-sdk/openai
12LMStudioLMSTUDIO_API_BASE_URLYes@ai-sdk/openai
13MistralMISTRAL_API_KEYNo@ai-sdk/mistral
14MoonshotMOONSHOT_API_KEYYes@ai-sdk/openai
15OllamaOLLAMA_API_BASE_URLYesollama-ai-sdk
16OpenAIOPENAI_API_KEYYes@ai-sdk/openai
17OpenAILikeOPENAI_LIKE_API_KEYOPENAI_LIKE_API_BASE_URLYes@ai-sdk/openai
18OpenRouterOPEN_ROUTER_API_KEYYes (public)@openrouter/ai-sdk-provider
19PerplexityPERPLEXITY_API_KEYNo@ai-sdk/openai
20TogetherTOGETHER_API_KEYTOGETHER_API_BASE_URLYesgetOpenAILikeModel
21xAIXAI_API_KEYNo@ai-sdk/openai
22Z.aiZAI_API_KEYZAI_BASE_URLYes@ai-sdk/openai + custom retry

BaseProvider architecture

Every provider extends the BaseProvider abstract class which provides:

Required abstract fields:

  • name: string — Unique provider identifier (e.g., "OpenAI", "Anthropic")
  • staticModels: ModelInfo[] — Hardcoded fallback model list
  • config: ProviderConfig{ baseUrlKey?, baseUrl?, apiTokenKey? }

Required abstract method:

  • getModelInstance(options) — Returns an AI SDK LanguageModel instance

Optional fields:

  • getDynamicModels() — Fetches live model list from provider API at runtime
  • getApiKeyLink — URL for obtaining an API key
  • labelForGetApiKey — Label text for the "Get API Key" button
  • icon — Provider icon SVG

Helper methods from BaseProvider:

  • getProviderBaseUrlAndKey() — Resolves API key via the priority chain
  • resolveDockerUrl() — Rewrites localhost → host.docker.internal for Docker
  • createTimeoutSignal() — 5s timeout for model fetch API calls
  • getModelsFromCache() / storeDynamicModels() — Caching keyed by apiKeys+settings+env
  • API key resolution priority chain

    When a provider needs an API key, it resolves through this priority chain:

    1. providerSettings.baseUrl — From UI settings (cookie providers)
    2. serverEnv[baseUrlKey] — Cloudflare environment bindings
    3. process.env[baseUrlKey] — Node.js environment variables (.env.local)
    4. LLMManager.env[baseUrlKey] — Vite-parsed env vars
    5. config.baseUrl — Hardcoded default per provider

    This means you can configure providers at any level — env vars for server-side defaults, cookies for per-browser customization.

Custom providers

You can add custom OpenAI-compatible endpoints via the "Add Provider" popup in the model selector.

CustomProvider interface:

typescript
interface CustomProvider {
  id: string;         // UUID
  name: string;       // User-chosen display name
  baseUrl: string;    // OpenAI-compatible endpoint URL
  apiKey: string;     // Bearer token
  createdAt: string;  // ISO timestamp
}

Custom providers are stored in localStorage key amplify_custom_providers with cross-tab sync via the storage event listener. Unlike built-in providers, custom provider API keys are NOT stored in cookies.

The AddProviderPopup has two modes:

  • "Pick" mode : Select an existing built-in provider to configure
  • "Custom" mode : Add any OpenAI-compatible endpoint with a test-connection feature
Test connection

The custom provider popup includes a test connection button that sends a request to the endpoint to verify it's accessible and returns model information. This helps catch misconfigured base URLs before you start chatting.

Model Selector UI

The ModelSelector component (app/components/chat/ModelSelector.tsx) provides:

  • Fuzzy search : Levenshtein distance matching (threshold 0.6 similarity)
  • Grouped display : Cloud providers first, then local providers (Ollama, LMStudio, OpenAILike)
  • Custom providers : Dedicated "Custom" group section
  • Free model filter : Toggle to show only free-tier models
  • Local status detection : Shows connectivity status for local providers
  • Inline API key popup : Add/manage keys without leaving the selector
  • Context window display : Shows sizes like "128K", "1.0M"
  • Keyboard navigation : Arrow keys, enter, escape support

Dynamic model fetching

Providers with getDynamicModels() fetch live model lists from provider-specific API endpoints:

ProviderAPI EndpointSpecial
OpenAI/v1/modelsFilters gpt-*, o*, chatgpt-*
Anthropic/v1/modelsRequires anthropic-version: 2023-06-01 header
Google/v1beta/modelsExcludes exp models; caps at 2M tokens
Ollama/api/tagsDocker URL rewrite; 5s timeout
LMStudio/v1/modelsDocker URL rewrite; 5s timeout
OpenRouter/api/v1/modelsPublic (no auth needed); shows pricing
Z.ai/modelsJWT auth mode; retry-aware fetch with exponential backoff

Dynamic models are cached keyed by JSON(apiKeys+settings+relevantEnv). When API keys change, the cache invalidates and models are re-fetched.

Learn about model configuration