Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

occa-opencode-provider

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

occa-opencode-provider

OpenCode plugin - auto-detects occa.json, hot reload, model filtering, caching, multi-provider with hostname mapping

latest
Source
npmnpm
Version
1.3.1
Version published
Maintainers
1
Created
Source

OCCA OpenCode Provider Plugin

Automatically reads occa.json and registers multiple providers (OpenAI / Claude / Gemini) into OpenCode with model lists fetched from the API.

Features

  • Auto-detect config — scans current directory, then fallback to ~/.config/opencode/occa.json
  • Multi-provider — one config file, unlimited providers
  • Auto model fetch — pulls model lists from each API on startup
  • Config validation — clear error messages for misconfiguration
  • Hot reload — watches config file, auto-reloads on changes
  • Model filtering — include/exclude models per provider with glob patterns
  • Token masking — API keys masked in logs (sk-***abc)
  • Model caching — caches model lists with configurable TTL
  • Custom headers — add extra headers per provider
  • Per-provider timeout — configurable request timeout

Installation

npm install -g occa-opencode-provider

Add to opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["occa-opencode-provider"]
}

Configuration

The plugin looks for occa.json in this order:

  • Environment variable: OCCA_CONFIG_PATH (full path to config file)
  • Current directory: ./occa.json (where you run opencode)
  • Default location: ~/.config/opencode/occa.json

Example: Run opencode in /workspace/ with /workspace/occa.json — plugin auto-detects it.

Minimal

{
  "provider": {
    "openai": {
      "baseurl": "https://api.openai.com/v1",
      "key": "sk-xxx",
      "type": "openai"
    }
  }
}

Full

{
  "settings": {
    "cache_ttl": 1800,
    "hot_reload": true
  },
  "provider": {
    "openai": {
      "baseurl": "https://api.openai.com/v1",
      "key": "sk-xxx",
      "type": "openai",
      "timeout": 15000,
      "headers": {
        "X-Custom-Header": "value"
      },
      "models": {
        "include": ["gpt-4*", "o3*"],
        "exclude": ["*vision*", "*audio*"]
      }
    },
    "claude": {
      "baseurl": "https://api.anthropic.com",
      "key": "sk-ant-xxx",
      "type": "claude"
    },
    "gemini": {
      "baseurl": "https://generativelanguage.googleapis.com/v1beta",
      "key": "AIza-xxx",
      "type": "gemini"
    },
    "openrouter": {
      "baseurl": "https://openrouter.ai/api/v1",
      "key": "sk-or-xxx",
      "type": "openai",
      "models": {
        "include": ["anthropic/*", "google/*", "openai/*"]
      }
    },
    "custom-api": {
      "baseurl": "https://api.example.com/v1",
      "key": "your-api-key",
      "type": "openai",
      "headers": {
        "auth_header": {
          "key": "X-API-Key",
          "value": "your-api-key"
        }
      }
    }
  }
}

Config Reference

settings

FieldTypeDefaultDescription
cache_ttlnumber1800Model cache TTL in seconds (0 to disable)
hot_reloadbooleantrueWatch config file for changes and auto-reload

provider.<name>

FieldTypeRequiredDescription
baseurlstringYesAPI base URL
keystringYesAPI key / token
typestringNoAPI type: openai | claude | gemini (default: openai)
timeoutnumberNoRequest timeout in ms (default: 15000)
headersobjectNoCustom headers to include in API requests
headers.auth_headerobjectNoCustom authentication header format (e.g. {key: "X-API-Key", value: "your-key"})
models.includestring[]NoGlob patterns — only include matching models
models.excludestring[]NoGlob patterns — exclude matching models

Supported API Types

TypeSDKModels EndpointProviders
openai@ai-sdk/openai-compatibleGET {baseurl}/modelsOpenAI, DeepSeek, Groq, OpenRouter, Together, Fireworks, Ollama, xAI, etc.
claude@ai-sdk/anthropicGET {baseurl}/v1/modelsAnthropic Claude
gemini@ai-sdk/googleGET {baseurl}/models?key={key}Google Gemini

Example Providers

OpenAI
{
  "baseurl": "https://api.openai.com/v1",
  "key": "sk-proj-xxx",
  "type": "openai"
}
Claude (Anthropic)
{
  "baseurl": "https://api.anthropic.com",
  "key": "sk-ant-api03-xxx",
  "type": "claude"
}
Gemini (Google)
{
  "baseurl": "https://generativelanguage.googleapis.com/v1beta",
  "key": "AIzaSy-xxx",
  "type": "gemini"
}
OpenRouter
{
  "baseurl": "https://openrouter.ai/api/v1",
  "key": "sk-or-v1-xxx",
  "type": "openai",
  "models": {
    "include": ["anthropic/*", "google/*", "openai/*", "meta-llama/*"]
  }
}
DeepSeek
{
  "baseurl": "https://api.deepseek.com/v1",
  "key": "sk-xxx",
  "type": "openai"
}
Groq
{
  "baseurl": "https://api.groq.com/openai/v1",
  "key": "gsk_xxx",
  "type": "openai"
}
Ollama (local)
{
  "baseurl": "http://localhost:11434/v1",
  "key": "ollama",
  "type": "openai"
}

Logging & Debugging

Logs are written to ~/.cache/opencode/occa-plugin/:

FileContent
debug.logAll activity (startup, config, model fetches, cache hits)
error.logErrors only (failed fetches, parse errors, validation)
models-cache.jsonCached model lists
# Watch all logs
tail -f ~/.cache/opencode/occa-plugin/debug.log

# Watch errors only
tail -f ~/.cache/opencode/occa-plugin/error.log

License

MIT

Keywords

opencode

FAQs

Package last updated on 27 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts