aperture

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package aperture is the adapter for Aperture, the model gateway on the tailnet: an agentcore.ChatModel (llm.LLM) backed by its chat-completions API. Aperture speaks the OpenRouter dialect (internal/chatwire), so like openrouter it needs no SDK — and it differs from OpenRouter in exactly the parts this adapter owns: the endpoint is on the tailnet, reached by host rather than by key, so no API key is required (one may still be set for a route that asks), and there are no app-attribution headers.

Model ids are Aperture's own, as its /v1/models lists them, e.g. "anthropic/claude-sonnet-5.5" or "qwen-27b".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListModels added in v0.6.1

func ListModels(ctx context.Context, baseURL, apiKey string) ([]string, error)

ListModels returns Aperture's live model ids, as its /v1/models lists them. See ListModelInfo for the rest of each entry.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter wraps Aperture's chat-completions API as an llm.LLM.

func New

func New(cfg Config) (*Adapter, error)

New builds an Adapter from config.

func (*Adapter) Generate

func (a *Adapter) Generate(ctx context.Context, msgs []ac.Message, tools []ac.ToolSpec, opts ...ac.CallOption) (*ac.LLMResponse, error)

Generate runs a one-shot chat completion.

func (*Adapter) GenerateStream

func (a *Adapter) GenerateStream(ctx context.Context, msgs []ac.Message, tools []ac.ToolSpec, opts ...ac.CallOption) (<-chan ac.StreamEvent, error)

GenerateStream runs a streaming chat completion, emitting the agentcore StreamEvent sequence the loop expects: thinking/text start-delta-end, tool-call start/delta/end with the completed call, a terminal done event carrying the fully assembled message with its stop reason and an error event on failure.

func (*Adapter) ProviderName

func (a *Adapter) ProviderName() string

ProviderName implements agentcore.ProviderNamer.

func (*Adapter) SupportsTools

func (a *Adapter) SupportsTools() bool

SupportsTools reports true: this adapter wires OpenAI-format tool calling.

type Config

type Config struct {
	APIKey  string
	Model   string
	BaseURL string
	// Meter, if set, receives token, cost and latency Usage for every call.
	Meter llm.Meter
	// Temperature and TopP are optional sampler params. nil leaves them off the
	// wire (the model's own default).
	Temperature *float64
	TopP        *float64
	// StreamIdleTimeout aborts a stream that has produced nothing for this
	// long, surfacing agentcore.ErrProviderStreamIdle so the agent loop can
	// fail over instead of waiting on a dead connection. Zero uses two
	// minutes; negative disables the watchdog. Streaming has no overall
	// deadline: a legitimately long generation must not be cut off.
	StreamIdleTimeout time.Duration
}

Config configures the adapter. Model is required; it is an Aperture model id such as "anthropic/claude-sonnet-5.5". BaseURL defaults to the tailnet endpoint. APIKey is optional: the tailnet authenticates the host, not a bearer, so the header is left off entirely when no key is set.

type ModelInfo added in v0.6.2

type ModelInfo struct {
	ID string
	// Provider is the gateway's provider id for the entry (the machine or
	// vendor account behind it), not the model's vendor.
	Provider string
	// Endpoints are the paths the gateway serves the model on, as
	// supported_endpoints lists them. This adapter speaks /v1/chat/completions.
	Endpoints []string
	// RequiresClientAuth is true when the caller must bring its own
	// credential; the gateway does not authenticate the host for it.
	RequiresClientAuth bool
	ContextTokens      int64
	MaxOutputTokens    int64
	// InputPrice and OutputPrice are USD per token, as the gateway prints
	// them (a decimal string), empty when unpriced. Tiered and fast-mode
	// rates are not read.
	InputPrice  string
	OutputPrice string
}

ModelInfo is one /v1/models entry, reduced to what routing stacks read. Zero values mean the gateway did not say: a local model usually carries no context window and no price, and that is unknown, not free.

func ListModelInfo added in v0.6.2

func ListModelInfo(ctx context.Context, baseURL, apiKey string) ([]ModelInfo, error)

ListModelInfo returns Aperture's live registry entries, as its /v1/models lists them. Empty baseURL uses the tailnet default; an API key is sent when given (the gateway usually authenticates by host instead). It exists for callers that need the registry, not a chat client: routing stacks read it to build their runtime offers.

Jump to

Keyboard shortcuts

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