effect/unstable/ai offer a unified interface that works across multiple providers while maintaining full type safety and Effect’s composable architecture.
Core Modules
The Effect AI framework consists of several key modules:- LanguageModel - Unified interface for text generation, structured output, and streaming
- Chat - Stateful conversation sessions with automatic history management
- Tool - Define tools that AI models can call to extend their capabilities
- Toolkit - Group tools together and implement handlers
- Prompt - Build and combine prompts with rich content types
- Response - Type-safe response parsing with text, tool calls, and metadata
Supported Providers
Effect AI currently supports the following providers through dedicated packages:- OpenAI -
@effect/ai-openai- GPT models, code interpreter, file search, web search - Anthropic -
@effect/ai-anthropic- Claude models, computer use, bash execution - OpenAI-compatible -
@effect/ai-openai-compat- Any OpenAI-compatible API - OpenRouter -
@effect/ai-openrouter- Access to multiple models through OpenRouter
Why Effect AI?
Provider-Agnostic Interface
Write your AI logic once and switch providers without changing your code:Type-Safe Tools and Structured Output
Define tools with schemas and get automatic validation:Effect Integration
Leverage Effect’s full ecosystem:- Error handling - Semantic errors with retry logic
- Telemetry - OpenTelemetry integration out of the box
- Streaming - First-class streaming support with
Stream - Concurrency - Control tool call execution with
concurrencyoptions - Resource management - Automatic cleanup with
Scope
Fallback Strategies
Build resilient AI applications withExecutionPlan:
Basic Example
Here’s a complete example showing text generation, structured output, and tool calling:Error Handling
Effect AI provides semantic error types throughAiError:
Next Steps
Language Models
Learn about text generation, structured output, and streaming
Tools & Chat
Build AI agents with tools and stateful conversations
