Class: LLM::OpencodeZen

Inherits:
OpenAI
  • Object
show all
Defined in:
lib/brute/providers/opencode_zen.rb

Overview

OpenAI-compatible provider for the OpenCode Zen API gateway.

OpenCode Zen is a curated model gateway at opencode.ai that proxies requests to upstream LLM providers (Anthropic, OpenAI, Google, etc.). All models are accessed via the OpenAI-compatible chat completions endpoint; the gateway handles format conversion internally.

Examples:

llm = LLM::OpencodeZen.new(key: ENV["OPENCODE_API_KEY"])
ctx = LLM::Context.new(llm)
ctx.talk "Hello from brute"

Anonymous access (free models only)

llm = LLM::OpencodeZen.new(key: "public")
ctx = LLM::Context.new(llm)
ctx.talk "Hello"

Direct Known Subclasses

OpencodeGo

Constant Summary collapse

HOST =
"opencode.ai"

Instance Method Summary collapse

Constructor Details

#initialize(key: "public") ⇒ OpencodeZen

Returns a new instance of OpencodeZen.

Parameters:

  • key (String) (defaults to: "public")

    OpenCode API key, or “public” for anonymous access



38
39
40
# File 'lib/brute/providers/opencode_zen.rb', line 38

def initialize(key: "public", **)
  super(host: HOST, key: key, **)
end

Instance Method Details

#audioObject

Raises:

  • (NotImplementedError)


66
# File 'lib/brute/providers/opencode_zen.rb', line 66

def audio        = raise(NotImplementedError, "Not supported via Zen gateway")

#default_modelString

Returns the default model.

Returns:

  • (String)


51
52
53
# File 'lib/brute/providers/opencode_zen.rb', line 51

def default_model
  "zen-bickpickle"
end

#filesObject

Raises:

  • (NotImplementedError)


67
# File 'lib/brute/providers/opencode_zen.rb', line 67

def files        = raise(NotImplementedError, "Not supported via Zen gateway")

#imagesObject

Raises:

  • (NotImplementedError)


65
# File 'lib/brute/providers/opencode_zen.rb', line 65

def images       = raise(NotImplementedError, "Not supported via Zen gateway")

#modelsBrute::Providers::ModelsDev

Returns models from the models.dev catalog for the opencode provider.



58
59
60
# File 'lib/brute/providers/opencode_zen.rb', line 58

def models
  Brute::Providers::ModelsDev.new(provider: self, provider_id: "opencode")
end

#moderationsObject

Raises:

  • (NotImplementedError)


68
# File 'lib/brute/providers/opencode_zen.rb', line 68

def moderations  = raise(NotImplementedError, "Not supported via Zen gateway")

#nameSymbol

Returns:

  • (Symbol)


44
45
46
# File 'lib/brute/providers/opencode_zen.rb', line 44

def name
  :opencode_zen
end

#responsesObject

– Unsupported sub-APIs –

Raises:

  • (NotImplementedError)


64
# File 'lib/brute/providers/opencode_zen.rb', line 64

def responses    = raise(NotImplementedError, "Use chat completions via the Zen gateway")

#vector_storesObject

Raises:

  • (NotImplementedError)


69
# File 'lib/brute/providers/opencode_zen.rb', line 69

def vector_stores = raise(NotImplementedError, "Not supported via Zen gateway")