Langfuse observability plugin for OpenCode - LLM tracing, prompt versioning, and cost tracking
npm install opencode-plugin-langfuse

Automatic LLM observability for OpenCode using Langfuse via OpenTelemetry.
Zero-config tracing of sessions, messages, tool calls, costs, and performance.
---
``bash`
npm install opencode-plugin-langfuseor
bun add opencode-plugin-langfuse
---
Sign up at cloud.langfuse.com and create a project.
Go to Settings → API Keys and copy your keys.
`bash`
export LANGFUSE_PUBLIC_KEY="pk-lf-..."
export LANGFUSE_SECRET_KEY="sk-lf-..."
export LANGFUSE_BASEURL="https://cloud.langfuse.com" # Optional
In .opencode/opencode.json:
`json`
{
"experimental": {
"openTelemetry": true
},
"plugin": ["opencode-plugin-langfuse"]
}
That's it! All traces appear automatically in your Langfuse dashboard.
---
This plugin initializes a LangfuseSpanProcessor that captures all OpenTelemetry spans emitted by OpenCode when experimental.openTelemetry is enabled.
``
OpenCode (OTEL spans) → LangfuseSpanProcessor → Langfuse Dashboard
---
| Variable | Required | Default | Description |
| --------------------- | -------- | ---------------------------- | ---------------------- |
| LANGFUSE_PUBLIC_KEY | Yes | - | Langfuse public key |LANGFUSE_SECRET_KEY
| | Yes | - | Langfuse secret key |LANGFUSE_BASEURL
| | No | https://cloud.langfuse.com | Self-hosted instance |
---
`bash`
export LANGFUSE_BASEURL="https://langfuse.yourcompany.com"
See Langfuse self-hosting docs.
---
1. Verify experimental.openTelemetry: true is setecho $LANGFUSE_PUBLIC_KEY
2. Check credentials: curl https://cloud.langfuse.com/api/public/health
3. Check Langfuse health:
- Ensure opencode-plugin-langfuse is in dependencies (not devDependencies).opencode/opencode.json` syntax
- Verify
---
MIT © omercnet
---