opencodego

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package opencodego provides OpenCode Zen (Go subscription) integration for the LLM gateway.

Index

Constants

This section is empty.

Variables

View Source
var Registration = providers.Registration{
	Type: "opencode_go",
	New:  New,
	Discovery: providers.DiscoveryConfig{
		DefaultBaseURL: defaultBaseURL,
	},
}

Registration provides factory registration for the OpenCode Go provider. The "opencode_go" type derives OPENCODE_GO_API_KEY, OPENCODE_GO_BASE_URL, and OPENCODE_GO_MODELS by convention.

Functions

func New

New creates a new OpenCode Go provider.

Types

type Provider

type Provider struct {
	*openai.ChatCompatible
	// contains filtered or unexported fields
}

Provider implements the core.Provider interface for OpenCode Go.

OpenCode Zen exposes two upstream dialects behind one base URL: OpenAI-style /chat/completions (most models) and Anthropic-style /messages (a few models rejected by /chat/completions). The embedded ChatCompatible handles the former; chat requests for models in messagesModels are delegated to an Anthropic provider pinned to the same base URL, mirroring how GoModel already serves /v1/messages for native Anthropic. Both paths normalize to the canonical OpenAI-shaped response, so callers see one consistent surface.

func (*Provider) ChatCompletion

func (p *Provider) ChatCompletion(ctx context.Context, req *core.ChatRequest) (*core.ChatResponse, error)

ChatCompletion routes Anthropic-only models to /messages and everything else to /chat/completions.

func (*Provider) Embeddings

Embeddings returns an error because OpenCode Go does not expose an embeddings endpoint.

func (*Provider) Passthrough added in v0.1.87

Passthrough forwards an opaque request with the identification headers filled in wherever the caller did not send its own. Passthrough is opaque by contract, so a caller-provided x-opencode-session, x-opencode-client, or User-Agent always wins over the gateway's value.

func (*Provider) Responses

Responses dispatches through this provider's ChatCompletion so /v1/responses honors the per-model /messages routing.

func (*Provider) StreamChatCompletion

func (p *Provider) StreamChatCompletion(ctx context.Context, req *core.ChatRequest) (io.ReadCloser, error)

StreamChatCompletion mirrors ChatCompletion's per-model endpoint routing.

func (*Provider) StreamResponses

func (p *Provider) StreamResponses(ctx context.Context, req *core.ResponsesRequest) (io.ReadCloser, error)

StreamResponses dispatches through this provider's streaming ChatCompletion so /v1/responses honors the per-model /messages routing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL