ocpipe
Build LLM pipelines with OpenCode, Claude Code, and Zod.
Inspired by DSPy.
- Type-safe Define inputs and outputs with Zod schemas
- Modular Compose modules into complex pipelines
- Checkpoints Resume from any step
- Multi-backend Choose between OpenCode (75+ providers) or Claude Code SDK
- Auto-correction Fixes schema mismatches automatically
bun add ocpipeimport { signature, field, module, Pipeline, createBaseState } from 'ocpipe'
const Greet = signature({
doc: 'Generate a friendly greeting for the given name.',
inputs: { name: field.string('The name of the person to greet') },
outputs: { greeting: field.string('A friendly greeting message') },
})
const pipeline = new Pipeline(
{
name: 'hello-world',
defaultModel: { providerID: 'opencode', modelID: 'minimax-m2.1-free' },
defaultAgent: 'default',
},
createBaseState,
)
const result = await pipeline.run(module(Greet), { name: 'World' })
console.log(result.data.greeting)
// Extract types from signatures
import { InferInputs, InferOutputs } from 'ocpipe'
type GreetIn = InferInputs<typeof Greet> // { name: string }
type GreetOut = InferOutputs<typeof Greet> // { greeting: string }ocpipe supports two backends for running LLM agents:
OpenCode (default) - Requires opencode CLI in your PATH. Supports 75+ providers.
const pipeline = new Pipeline(
{
name: 'my-pipeline',
defaultModel: {
providerID: 'anthropic',
modelID: 'claude-sonnet-4-20250514',
},
defaultAgent: 'default',
},
createBaseState,
)Claude Code - Uses @anthropic-ai/claude-agent-sdk. Install as a peer dependency.
// modelID: 'opus', 'sonnet', or 'haiku'
defaultModel: { backend: 'claude-code', modelID: 'sonnet' },
// permissionMode: 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan'
claudeCode: { permissionMode: 'acceptEdits' },For OpenCode backend: Currently requires this OpenCode fork. Once the following PRs are merged, the official release will work:
For Claude Code backend: Install the SDK as a peer dependency:
bun add @anthropic-ai/claude-agent-sdk- Getting Started - Tutorial with examples
- Design - Architecture and concepts
- Contributing - Development setup
An Aperture Robotics project.