The provider system implements a unified abstraction layer for 30+ LLM providers including OpenAI, Anthropic, Google Gemini, AWS Bedrock, Azure, and self-hosted options like Ollama and vLLM. All providers implement the ProviderConfig interface and expose an executeRequest() method. The executeProviderRequest() dispatcher function routes requests to the appropriate provider implementation based on ProviderId.
Core Components:
ProviderConfig interface - Standard provider contract apps/sim/providers/types.ts40-51executeProviderRequest() - Central dispatcher apps/sim/providers/index.ts34PROVIDER_DEFINITIONS - Model metadata registry apps/sim/providers/models.ts73-450getProviderFromModel() - Model-to-provider resolution apps/sim/providers/utils.ts214-248Related Pages:
Sources: apps/sim/providers/index.ts apps/sim/providers/types.ts40-51 apps/sim/providers/models.ts73-450 apps/sim/providers/utils.ts214-248
All provider requests route through executeProviderRequest() which selects the appropriate provider implementation based on ProviderId. Block handlers call this function directly or via a proxy.
Provider System Architecture Diagram
Sources: apps/sim/executor/handlers/agent/agent-handler.ts49-113 apps/sim/executor/handlers/router/router-handler.ts76-112 apps/sim/executor/handlers/evaluator/evaluator-handler.ts109-140 apps/sim/providers/utils.ts214-248 apps/sim/providers/index.ts34
All providers implement the ProviderConfig interface, which defines the contract for LLM provider implementations:
Key Method: executeRequest()
The executeRequest() method is the core abstraction. It accepts a normalized ProviderRequest object and returns one of three types:
ProviderResponse - Synchronous completion with full response apps/sim/providers/types.ts73-102ReadableStream<any> - Legacy streaming pattern (deprecated)StreamingExecution - Current streaming pattern with metadata wrapper apps/sim/executor/types.tsSources: apps/sim/providers/types.ts40-51 apps/sim/providers/types.ts73-102
The PROVIDER_DEFINITIONS object in apps/sim/providers/models.ts is the single source of truth for all provider and model metadata. It maps ProviderId to ProviderDefinition which contains model lists, pricing, and capabilities.
PROVIDER_DEFINITIONS Structure Diagram
Sources: apps/sim/providers/models.ts73-100 apps/sim/providers/models.ts54-71 apps/sim/providers/models.ts29-52 apps/sim/providers/types.ts20-25
The providers/utils.ts module provides utility functions for querying PROVIDER_DEFINITIONS:
| Function | Location | Return Type | Purpose |
|---|---|---|---|
getProviderFromModel(model) | apps/sim/providers/utils.ts214-248 | ProviderId | Maps model name to provider ID via exact match or RegExp pattern |
getProviderModels(providerId) | apps/sim/providers/utils.ts269-271 | string[] | Returns all model IDs for a provider |
supportsTemperature(model) | apps/sim/providers/utils.ts316-335 | boolean | Checks if model supports temperature parameter |
calculateCost(model, in, out) | apps/sim/providers/utils.ts605-651 | CostObject | Calculates cost in USD based on token usage |
Sources: apps/sim/providers/utils.ts214-271 apps/sim/providers/utils.ts605-651 apps/sim/providers/models.ts1-50
Provider requests follow a consistent flow from block handlers to provider implementations.
Provider Request Execution Sequence
Sources: apps/sim/executor/handlers/agent/agent-handler.ts49-113 apps/sim/providers/index.ts34 apps/sim/providers/utils.ts605-651
The ProviderRequest interface apps/sim/providers/types.ts140-182 normalizes all provider-specific parameters into a common format:
Key Fields:
model: string - Model identifier (e.g., "gpt-4o", "claude-3-5-sonnet")messages?: Message[] - Conversation history with role and contenttools?: ProviderToolConfig[] - Tools available for function callingtemperature?: number - Sampling temperatureresponseFormat?: {name, schema, strict} - JSON schema for structured outputstream?: boolean - Enable streaming responsesreasoningEffort?: string - For models like OpenAI o1/o3 apps/sim/providers/types.ts174thinkingLevel?: string - For models with explicit thinking capabilities apps/sim/providers/types.ts176The ProviderResponse interface apps/sim/providers/types.ts73-102 standardizes outputs:
Key Fields:
content: string - Generated text contentmodel: string - Actual model usedtokens?: {input, output, total} - Token usagetoolCalls?: FunctionCallResponse[] - Tool calls made by the modelcost?: {input, output, total, pricing} - Cost breakdownSources: apps/sim/providers/types.ts140-182 apps/sim/providers/types.ts73-102
Each provider implements the ProviderConfig interface with an executeRequest function.
| Provider | Entry Point | Core API | Notes |
|---|---|---|---|
| OpenAI | providers/openai/index.ts | Chat Completions | Supports o1/o3 reasoning effort apps/sim/providers/models.ts263-278 |
| Anthropic | providers/anthropic/index.ts | Messages API | Supports Computer Use and Thinking apps/sim/providers/models.ts365-375 |
| Google / Vertex | providers/vertex/index.ts | Vertex AI API | Shared core logic for Gemini apps/sim/providers/vertex/index.ts15-39 |
| Ollama | providers/ollama/index.ts | OpenAI-compatible | Local models, auto-discovery via updateOllamaModels apps/sim/providers/utils.ts152-155 |
| OpenRouter | providers/openrouter/index.ts | Unified API | Access to hundreds of models apps/sim/providers/utils.ts163-167 |
| DeepSeek | providers/deepseek/index.ts | DeepSeek API | Native support for V3 and R1 apps/sim/providers/models.ts515-535 |
Common Implementation Patterns:
ProviderRequest to provider-specific SDK payload.prepareToolsWithUsageControl() for function calling apps/sim/providers/utils.ts34-39new Anthropic(...)).calculateCost() apps/sim/providers/utils.ts605Sources: apps/sim/providers/anthropic/index.ts10-34 apps/sim/providers/utils.ts34-43 apps/sim/providers/models.ts73-450
The provider system implements a unified tool calling interface. The AgentBlockHandler handles the resolution of tools before passing them to the provider.
Sources: apps/sim/executor/handlers/agent/agent-handler.ts178-220 apps/sim/providers/utils.ts34-43 apps/sim/providers/index.ts34
The system tracks cost per execution based on token counts defined in PROVIDER_DEFINITIONS.
calculateCost(model, in, out) apps/sim/providers/utils.ts605ModelPricing in model definitions apps/sim/providers/models.ts56-59dollarsToCredits() apps/sim/providers/utils.ts5ExecutionContext apps/sim/executor/types.tsSources: apps/sim/providers/utils.ts605-651 apps/sim/providers/models.ts56-59 apps/sim/providers/utils.ts5
The system supports API keys, OAuth tokens, and server-side rotating keys.
| Provider | Credential Source | Key Function |
|---|---|---|
| Standard | getApiKey(provider, model, userKey) | apps/sim/providers/utils.ts709 |
| Vertex AI | Vertex specific credential resolution | apps/sim/executor/utils/vertex-credential.ts |
| Ollama | Local (returns "empty") | apps/sim/providers/utils.ts152 |
| Hosted | getRotatingApiKey(provider) | apps/sim/providers/utils.test.ts47 |
Sources: apps/sim/providers/utils.ts709-758 apps/sim/providers/utils.test.ts50-171 apps/sim/executor/handlers/agent/agent-handler.ts33
Refresh this wiki