About this project
This package is a community provider for the Vercel AI SDK that integrates with OpenCode, a terminal-based AI coding assistant. It allows developers to use OpenCode's configured AI providers (Anthropic, OpenAI, Google, etc.) through the standard AI SDK interface.
Key features include:
- Text generation with `generateText()` and `streamText()`
- Real-time streaming with SSE
- Multi-turn conversations with session management
- Tool observation (server-side execution, no custom tools)
- Tool approval flows
- Interactive question handling with `onQuestion` callback
- File and source streaming parts
- Structured output with native JSON schema and fallback patterns
- Abort/cancellation support
- Error handling with AI SDK error types
Version compatibility:
- v4.x for AI SDK v7 (latest)
- v3.x for AI SDK v6 (maintenance, tag `ai-sdk-v6`)
- v2.x and v1.x legacy for v6
- v0.x for v5 (tag `ai-sdk-v5`)
Requires Node.js >= 22 and OpenCode CLI installed. Models are specified in `providerID/modelID` format, e.g., `opencode("openai/gpt-5.3-codex-spark")`.
Provider settings allow custom hostname, port, auto-start server, client options, and default settings. Model settings include session ID, agent selection, permissions, variant, directory, and question policy.
The package exports advanced utilities for power users, such as runtime classes, validation helpers, and event conversion functions. Examples are provided for basic usage, streaming, conversation history, structured output, tool observation, question handling, abort signals, image input, custom config, client options, limitations, and long-running tasks.
License: MIT
Comments
0 people shared their preference · Deer Point appears after 10 participants
Sign in to join the discussion.