effect-ai-provider

Configure and compose AI provider layers using @effect/ai packages for language model integration.

1|Updated Aug 24, 2026
One-click install
npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-ai-provider-lambdasolver2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-ai-provider
Source: https://github.com/lambdasolver2/opencode-effect-harness/tree/main/packages/module-typescript/assets/skills/effect-ai-provider
Command: npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-ai-provider-lambdasolver2

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @effect/ai-anthropic, @effect/ai-openai, @effect/ai-openrouter, effect.

What problem does it solve? Setting up AI language model providers in Effect applications involves juggling client layers, API key configuration, HTTP clients, and multi-provider fallback logic. This Skill provides the correct patterns for wiring Anthropic, OpenAI, OpenAI-compatible, and OpenRouter providers into Effect services without runtime misconfiguration. ## Core Features & Use Cases - Provider Layer Setup: Construct client and language model layers for Anthropic, OpenAI, OpenAI-compatible APIs, and OpenRouter with Config.redacted secrets and FetchHttpClient wiring. - ExecutionPlan Fallback: Define multi-provider retry and fallback strategies, capturing requirements and applying plans per-effect. - Stateful Chat & Streaming: Maintain conversation history with Chat.fromPrompt, export/restore sessions as JSON, and stream text deltas through Stream pipelines. - Use Case: Build an AiWriter service that drafts announcements using a cheap OpenAI model first, falls back to Claude on failure, keeps a chat session with history, and wraps AiError into a domain-specific TaggedError. ## Quick Start Set up an Anthropic language model layer with a redacted API key and use it to generate text from a prompt in an Effect program.

Frequently Asked Questions about effect-ai-provider

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up an Anthropic or OpenAI provider in Effect?

Create a client layer with ProviderClient.layerConfig using Config.redacted for the API key, then provide FetchHttpClient.layer. Use ProviderLanguageModel.model(modelId) to get a Model for Effect.provide or ExecutionPlan, or .layer({ model }) for a raw Layer.

How do I implement multi-provider fallback with Effect AI?

Use ExecutionPlan.make with ordered entries specifying provide (a Model) and attempts (retry count). Call plan.captureRequirements inside Layer.effect to satisfy client requirements, then apply it with Effect.withExecutionPlan on your effect.

Does @effect/ai support Google or Amazon Bedrock providers?

No @effect/ai-google or @effect/ai-amazon-bedrock packages exist. Use @effect/ai-openrouter with provider-prefixed model IDs like anthropic/claude-sonnet-4 to access Google, Bedrock, and other models through the OpenRouter proxy.

Why does my Effect AI provider layer fail at runtime?

The most common cause is a missing FetchHttpClient.layer, since all provider clients require an HttpClient. Also verify API keys use Config.redacted rather than hardcoded strings, and that client layers are provided to the language model layer.

How do I maintain chat conversation history with Effect AI?

Create a session with Chat.fromPrompt using Prompt.setSystem for the system message, then call session.generateText which maintains history automatically. Access history via Ref.get(session.history), persist with session.exportJson, and restore with Chat.fromJson.

Can I override model config like temperature per request in Effect AI?

Yes, use the provider's withConfigOverride dual API, such as AnthropicLanguageModel.withConfigOverride({ temperature: 0.7, max_tokens: 4096 }), piped onto any effect using the LanguageModel. OpenAI overrides also support reasoning, text verbosity, and strictJsonSchema.