amp

package
v6.10.9-aug.2 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Overview

Package amp implements the Amp CLI routing module, providing OAuth-based integration with Amp CLI for ChatGPT and Anthropic subscriptions.

Package amp provides model mapping functionality for routing Amp CLI requests to alternative models when the requested model is not available locally.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

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

Module implements the RouteModuleV2 interface for Amp CLI integration. It provides:

  • Reverse proxy to Amp control plane for OAuth/management
  • Provider-specific route aliases (/api/provider/{provider}/...)
  • Automatic gzip decompression for misconfigured upstreams
  • Model mapping for routing unavailable models to alternatives

func New

func New(opts ...Option) *Module

New creates a new Amp routing module with the given options. This is the preferred constructor using the Option pattern.

Example:

ampModule := amp.New(
    amp.WithAccessManager(accessManager),
    amp.WithAuthMiddleware(authMiddleware),
)

func (*Module) GetModelMapper

func (m *Module) GetModelMapper() *defaultModelMapper

GetModelMapper returns the model mapper instance (for testing/debugging). noinspection GoExportedFuncWithUnexportedType — internal package, unexported return type is intentional.

func (*Module) Name

func (m *Module) Name() string

Name returns the module identifier

func (*Module) OnConfigUpdated

func (m *Module) OnConfigUpdated(cfg *config.Config) error

OnConfigUpdated handles configuration updates with partial reload support. Only updates components that have actually changed to avoid unnecessary work. Supports hot-reload for: model-mappings, upstream-api-key, upstream-url, restrict-management-to-localhost.

func (*Module) Register

func (m *Module) Register(ctx modules.Context) error

Register sets up Amp routes if configured. This implements the RouteModuleV2 interface with Context. Routes are registered only once via sync.Once for idempotent behavior.

type Option

type Option func(*Module)

Option configures the Module.

func WithAccessManager

func WithAccessManager(am *sdkaccess.Manager) Option

WithAccessManager sets the access manager for the module.

func WithAuthMiddleware

func WithAuthMiddleware(middleware gin.HandlerFunc) Option

WithAuthMiddleware sets the authentication middleware for provider routes.

Jump to

Keyboard shortcuts

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