opencode-koji
v0.3.0
Published
OpenCode plugin for koji local AI server auto-discovery and model configuration
Downloads
349
Maintainers
Readme
OpenCode Koji Plugin
Auto-discovers models from Koji local AI server and provides OpenCode with model configuration.
Features
- Auto-detection: Finds koji running on default ports (11434, 8080)
- Model Discovery: Queries
/koji/v1/opencode/modelsfor rich model metadata - Configuration Enhancement: Adds model metadata (context limits, name, etc.)
- Graceful Fallback: Works even if koji is offline
Installation
Add to your opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-koji"]
}Or install via npm:
npm install opencode-kojiUsage
Simply install the plugin - it will auto-detect koji and discover models.
Manual Configuration
If you want to use a custom koji instance:
{
"provider": {
"koji": {
"npm": "@ai-sdk/openai-compatible",
"name": "Koji (local)",
"options": {
"baseURL": "http://localhost:11434/v1"
}
}
}
}The plugin will still enhance this with auto-discovered models, merging with any manually configured ones.
Authentication
If your koji instance is gated behind a bearer token (e.g. a public endpoint fronted by a reverse proxy), set the token in one of two ways:
KOJI_TOKENenvironment variable (highest priority):export KOJI_TOKEN=your-token-hereapiKeyin youropencode.jsonprovider options:{ "provider": { "koji": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "https://koji.example.com/v1", "apiKey": "your-token-here" } } } }
The token is sent as Authorization: Bearer <token> on both model discovery and inference requests. When unset, no auth header is sent (fine for localhost).
How It Works
- On opencode startup, the
confighook is called - Plugin checks for existing
kojiprovider or auto-detects on default ports - Queries
GET /koji/v1/opencode/modelsfrom koji - Merges discovered models into opencode's configuration
- Models appear in
/modelslist automatically
Requirements
- Koji running with
koji serve - OpenCode with plugin support
License
MIT
