route

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package route holds concrete route.Router builders for the bundled wire APIs: a static chat route (OpenAI/Anthropic style) and Gemini's mode-aware model-in-path route. These are wire-API facts only — no provider default endpoints, auth policy, or model catalogue lives here. Callers may supply any route.Router; these are conveniences for the shapes the bundled codecs speak.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MissingModelError

type MissingModelError struct{}

MissingModelError is returned when a Gemini route is built for a request whose Model carries no Name — the name is required for the model-in-path URL. Typed per the repo rule so callers can errors.As it rather than string-matching.

func (*MissingModelError) Error

func (e *MissingModelError) Error() string

type Route

type Route struct {
	Method string
	URL    string
	Header http.Header
}

Route is a fully-resolved outbound request target: method, absolute URL, and route headers. It is what a Router returns so the generic transport need not hardcode POST, a chat path, a Content-Type, or a streaming Accept header.

type Router

type Router interface {
	BuildRoute(baseURL string, req inference.Request, mode codec.RequestMode) (Route, error)
}

Router builds the Route for a given base endpoint, request, and mode. It is the seam that keeps mode-aware wire APIs (such as Gemini's model-in-path generateContent vs streamGenerateContent routes) out of the transport. Concrete builders live in the route package; callers may supply any Router.

func GeminiGenerateContent

func GeminiGenerateContent() Router

GeminiGenerateContent returns a Router for Gemini's generateContent API:

invoke: POST {base}/models/{model}:generateContent
stream: POST {base}/models/{model}:streamGenerateContent?alt=sse

The model name is read from req.Model.Name.

func StaticChat

func StaticChat(path string) Router

StaticChat returns a Router that targets POST {trimRight(base,"/")}{path} for every mode. Use "/chat/completions" for OpenAI-compatible APIs and "/messages" for Anthropic-compatible APIs.

Jump to

Keyboard shortcuts

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