Providers
Providers
Section titled “Providers”UPP supports ten AI providers out of the box. Each provider is a separate import that can be used with llm(), embedding(), or image().
Provider Capabilities
Section titled “Provider Capabilities”| Provider | LLM | Embedding | Image | Notes |
|---|---|---|---|---|
| Anthropic | ✓ | Claude models, extended thinking, computer use | ||
| OpenAI | ✓ | ✓ | ✓ | GPT-4, embeddings, DALL-E |
| ✓ | ✓ | ✓ | Gemini models, Imagen | |
| xAI | ✓ | ✓ | Grok models | |
| Ollama | ✓ | ✓ | Local models | |
| OpenRouter | ✓ | ✓ | ✓ | Multi-provider gateway |
| Groq | ✓ | Fast inference with Llama, Gemma, Mixtral | ||
| Cerebras | ✓ | Ultra-fast inference with Llama, Qwen | ||
| Responses | ✓ | OpenResponses-compatible endpoints | ||
| Proxy | ✓ | ✓ | ✓ | Custom API endpoints |
Anthropic
Section titled “Anthropic”Claude models with advanced features like extended thinking and structured outputs.
import { llm } from '@providerprotocol/ai';import { anthropic } from '@providerprotocol/ai/anthropic';
const claude = llm({ model: anthropic('claude-sonnet-4-20250514'), system: 'You are a helpful assistant.', params: { max_tokens: 4096, temperature: 0.7, },});
const turn = await claude.generate('Explain quantum computing');Available models: claude-sonnet-4-20250514, claude-opus-4-20250514, claude-3-5-haiku-20241022
Beta Features
Section titled “Beta Features”Anthropic offers beta features via the betas option:
import { anthropic, betas } from '@providerprotocol/ai/anthropic';
const claude = llm({ model: anthropic('claude-sonnet-4-20250514', { betas: [betas.structuredOutputs], }),});OpenAI
Section titled “OpenAI”GPT models with two API modes: Responses (modern) and Completions (legacy).
import { llm, embedding, image } from '@providerprotocol/ai';import { openai } from '@providerprotocol/ai/openai';
// LLMconst gpt = llm({ model: openai('gpt-4o') });
// Embeddingsconst embedder = embedding({ model: openai('text-embedding-3-large'), params: { dimensions: 1536 },});
// Image generationconst dalle = image({ model: openai('dall-e-3'), params: { size: '1024x1024', quality: 'hd' },});API Modes
Section titled “API Modes”OpenAI supports two LLM APIs:
// Modern Responses API (default, recommended)const modern = llm({ model: openai('gpt-4o') });
// Legacy Chat Completions APIconst legacy = llm({ model: openai('gpt-4o', { api: 'completions' }) });LLM models: gpt-4o, gpt-4o-mini, gpt-4-turbo, o1, o1-mini, o3-mini
Embedding models: text-embedding-3-small, text-embedding-3-large
Image models: dall-e-3, dall-e-2
Gemini models with multimodal capabilities.
import { llm, embedding, image } from '@providerprotocol/ai';import { google } from '@providerprotocol/ai/google';
// LLMconst gemini = llm({ model: google('gemini-2.0-flash') });
// Embeddingsconst embedder = embedding({ model: google('text-embedding-004'),});
// Image generationconst imagen = image({ model: google('imagen-3.0-generate-001'),});LLM models: gemini-2.0-flash, gemini-1.5-pro, gemini-1.5-flash
Embedding models: text-embedding-004
Grok models with multiple API modes.
import { llm, image } from '@providerprotocol/ai';import { xai } from '@providerprotocol/ai/xai';
// LLMconst grok = llm({ model: xai('grok-2') });
// Image generationconst aurora = image({ model: xai('grok-2-image') });API Modes
Section titled “API Modes”xAI supports multiple API modes:
// Default modeconst grok = llm({ model: xai('grok-2') });
// Explicit mode selectionconst grokOpenAI = llm({ model: xai('grok-2', { api: 'openai' }) });LLM models: grok-2, grok-2-mini, grok-beta
Ollama
Section titled “Ollama”Run models locally with Ollama.
import { llm, embedding } from '@providerprotocol/ai';import { ollama } from '@providerprotocol/ai/ollama';
// LLMconst local = llm({ model: ollama('llama3.2'), config: { baseUrl: 'http://localhost:11434', // Default },});
// Embeddingsconst embedder = embedding({ model: ollama('nomic-embed-text'),});Popular models: llama3.2, llama3.1, mistral, codellama, nomic-embed-text
OpenRouter
Section titled “OpenRouter”Access multiple providers through a single API.
import { llm, embedding } from '@providerprotocol/ai';import { openrouter } from '@providerprotocol/ai/openrouter';
// Use any model available on OpenRouterconst model = llm({ model: openrouter('anthropic/claude-sonnet-4'), config: { headers: { 'HTTP-Referer': 'https://myapp.com', 'X-Title': 'My Application', }, },});OpenRouter provides access to models from many providers with a unified API and billing.
Fast inference with Llama, Gemma, and Mixtral models.
import { llm } from '@providerprotocol/ai';import { groq } from '@providerprotocol/ai/groq';
const model = llm({ model: groq('llama-3.3-70b-versatile'), params: { max_tokens: 1000 },});
const turn = await model.generate('Hello!');With Web Search
Section titled “With Web Search”Enable real-time web search:
const searchModel = llm({ model: groq('llama-3.3-70b-versatile'), params: { search_settings: { mode: 'auto' }, },});
const turn = await searchModel.generate('What are the latest AI news today?');With RAG Documents
Section titled “With RAG Documents”Provide context documents with optional citations:
const ragModel = llm({ model: groq('llama-3.3-70b-versatile'), params: { documents: [ { title: 'Company Policy', content: 'Employees get 20 vacation days...' }, { title: 'Benefits Guide', content: 'Health insurance covers...' }, ], citation_options: { include: true }, },});
const turn = await ragModel.generate('How many vacation days do employees get?');Capabilities: Streaming, tool calling, structured output, image input (Llama 4 preview), web search, RAG with citations.
Popular models: llama-3.3-70b-versatile, llama-3.1-8b-instant, gemma2-9b-it, mixtral-8x7b-32768
Cerebras
Section titled “Cerebras”Ultra-fast inference with Llama, Qwen, and GPT-OSS models.
import { llm } from '@providerprotocol/ai';import { cerebras } from '@providerprotocol/ai/cerebras';
const model = llm({ model: cerebras('llama-3.3-70b'), params: { max_completion_tokens: 1000 },});
const turn = await model.generate('Hello!');With Reasoning (GPT-OSS)
Section titled “With Reasoning (GPT-OSS)”const model = llm({ model: cerebras('gpt-oss-120b'), params: { reasoning_effort: 'high', reasoning_format: 'parsed', },});Capabilities: Streaming, tool calling, structured output, reasoning parameters.
Popular models: llama-3.3-70b, llama-3.1-8b, qwen-3-32b, gpt-oss-120b
Responses
Section titled “Responses”Connect to any OpenResponses-compatible endpoint. This provider implements the OpenResponses specification for interoperable LLM interfaces.
import { llm } from '@providerprotocol/ai';import { responses } from '@providerprotocol/ai/responses';
// Connect to OpenAI using the OpenResponses specconst model = llm({ model: responses('gpt-4o', { host: 'https://api.openai.com/v1', apiKeyEnv: 'OPENAI_API_KEY', }), params: { max_output_tokens: 1000, },});
const turn = await model.generate('Hello!');Configuration
Section titled “Configuration”interface ResponsesProviderOptions { host: string; // Required: Base URL of the OpenResponses server apiKeyEnv?: string; // Optional: Env var name (default: 'OPENRESPONSES_API_KEY')}Use Cases
Section titled “Use Cases”The responses provider works with any OpenResponses-compatible endpoint:
// OpenAIresponses('gpt-4o', { host: 'https://api.openai.com/v1', apiKeyEnv: 'OPENAI_API_KEY' })
// OpenRouterresponses('anthropic/claude-sonnet-4', { host: 'https://openrouter.ai/api/v1', apiKeyEnv: 'OPENROUTER_API_KEY' })
// Self-hosted serverresponses('my-model', { host: 'https://my-server.example.com/v1' })Proxy Provider
Section titled “Proxy Provider”Connect to custom API endpoints or build your own AI gateway.
import { llm } from '@providerprotocol/ai';import { proxy } from '@providerprotocol/ai/proxy';
const custom = llm({ model: proxy('https://my-api.example.com/ai'), config: { headers: { 'Authorization': 'Bearer my-platform-token', }, },});The proxy provider is useful for:
- Building API gateways with custom authentication
- Adding usage tracking and billing
- Proxying requests through corporate firewalls
Provider Parameters
Section titled “Provider Parameters”Each provider exports typed parameters for type-safe configuration:
import { llm } from '@providerprotocol/ai';import { anthropic } from '@providerprotocol/ai/anthropic';import type { AnthropicLLMParams } from '@providerprotocol/ai/anthropic';
const claude = llm({ model: anthropic('claude-sonnet-4-20250514'), params: { max_tokens: 4096, temperature: 0.7, top_p: 0.9, } satisfies AnthropicLLMParams,});| Provider | LLM Params | Embedding Params | Image Params |
|---|---|---|---|
| Anthropic | AnthropicLLMParams | - | - |
| OpenAI | OpenAILLMParams | OpenAIEmbedParams | OpenAIImageParams |
GoogleLLMParams | GoogleEmbedParams | GoogleImageParams | |
| xAI | XAILLMParams | - | XAIImageParams |
| Ollama | OllamaLLMParams | OllamaEmbedParams | - |
| Groq | GroqLLMParams | - | - |
| Cerebras | CerebrasLLMParams | - | - |
| Responses | ResponsesParams | - | - |
Environment Variables
Section titled “Environment Variables”UPP automatically reads API keys from environment variables:
ANTHROPIC_API_KEY=sk-ant-...OPENAI_API_KEY=sk-...GOOGLE_API_KEY=...XAI_API_KEY=...OPENROUTER_API_KEY=...GROQ_API_KEY=...CEREBRAS_API_KEY=...OPENRESPONSES_API_KEY=... # For responses provider (or use apiKeyEnv option)You can also provide keys explicitly in the config:
const claude = llm({ model: anthropic('claude-sonnet-4-20250514'), config: { apiKey: process.env.MY_CUSTOM_KEY, },});See the Configuration guide for advanced key management options.
Using Multiple Providers
Section titled “Using Multiple Providers”import { llm } from '@providerprotocol/ai';import { anthropic } from '@providerprotocol/ai/anthropic';import { openai } from '@providerprotocol/ai/openai';import { google } from '@providerprotocol/ai/google';
const claude = llm({ model: anthropic('claude-sonnet-4-20250514') });const gpt = llm({ model: openai('gpt-4o') });const gemini = llm({ model: google('gemini-2.0-flash') });import { embedding } from '@providerprotocol/ai';import { openai } from '@providerprotocol/ai/openai';import { google } from '@providerprotocol/ai/google';import { ollama } from '@providerprotocol/ai/ollama';
const openaiEmbed = embedding({ model: openai('text-embedding-3-small') });const googleEmbed = embedding({ model: google('text-embedding-004') });const localEmbed = embedding({ model: ollama('nomic-embed-text') });import { image } from '@providerprotocol/ai';import { openai } from '@providerprotocol/ai/openai';import { google } from '@providerprotocol/ai/google';import { xai } from '@providerprotocol/ai/xai';
const dalle = image({ model: openai('dall-e-3') });const imagen = image({ model: google('imagen-3.0-generate-001') });const aurora = image({ model: xai('grok-2-image') });