Skip to content

feat: add OpenCode Zen as inference provider#336

Open
DheerGupta35959 wants to merge 1 commit into
Conway-Research:mainfrom
DheerGupta35959:feat/opencode-zen-provider
Open

feat: add OpenCode Zen as inference provider#336
DheerGupta35959 wants to merge 1 commit into
Conway-Research:mainfrom
DheerGupta35959:feat/opencode-zen-provider

Conversation

@DheerGupta35959

Copy link
Copy Markdown

Summary

Adds OpenCode Zen as a first-class inference provider, enabling access to a curated selection of 75+ LLM models (GPT-5, Claude, Gemini, DeepSeek, Qwen, and more) through automaton's existing inference routing system.

Changes

  • src/types.ts — Added "opencode" to ModelProvider union type, added opencodeBaseUrl/opencodeApiKey to config
  • src/conway/inference.ts — Added OpenCode as a recognized InferenceBackend, routed through chatViaOpenAiCompatible with provider-specific error messages (401/429/404)
  • src/inference/registry.ts — Added "opencode" to the providers that are skipped during baseline auto-disable (dynamically-discovered models manage their own lifecycle)
  • src/index.ts — OpenCode provider startup: reads OPENCODE_BASE_URL/OPENCODE_API_KEY env vars, auto-discovers available models from proxy via GET /v1/models, populates the model registry
  • src/config.ts — Added opencodeBaseUrl/opencodeApiKey to createConfig for setup wizard support
  • src/__tests__/inference-router.test.ts — 4 unit tests covering model registry, auto-disable skip, model discovery, and fallback routing

Tests

Unit tests (68/68 passing):

  • All existing tests plus 4 new OpenCode-specific tests pass.

Risk / Compatibility

  • Additive only. No existing providers modified.
  • OpenCode backend is opt-in via OPENCODE_BASE_URL and OPENCODE_API_KEY env vars.
  • Auto-discovery from /v1/models populates available models at startup.

Example usage

  1. Configure the OpenCode Zen connection:
export OPENCODE_BASE_URL=https://opencode.ai/zen/v1
export OPENCODE_API_KEY=sk-your-opencode-key

Or in your automaton config:

{
  "opencodeBaseUrl": "https://opencode.ai/zen/v1",
  "opencodeApiKey": "sk-your-opencode-key"
}
  1. Any model served by your OpenCode Zen proxy is registered with provider: "opencode" and available for inference routing. The startup log shows:
OpenCode Zen: discovered 24 models from https://opencode.ai/zen/v1/v1/models
  1. Model routing is automatic. Once registered, models route to the OpenCode backend based on the model registry lookup — no manual backend selection needed. The inference router picks the right backend (conway, openai, anthropic, ollama, or opencode) based on the model's registered provider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant