opencodego

package
v0.1.60 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 10 Imported by: 0

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 NewWithHTTPClient

func NewWithHTTPClient(apiKey string, baseURL string, httpClient *http.Client, hooks llmclient.Hooks) *Provider

NewWithHTTPClient creates a new OpenCode Go provider with a custom HTTP client. If httpClient is nil, http.DefaultClient is used.

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) 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