proxy

package
v0.13.0-go Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package proxy implements an OpenAI-compatible HTTP proxy server with smart routing. It classifies incoming requests, selects the cheapest capable model, and forwards to the upstream API.

Index

Constants

This section is empty.

Variables

View Source
var Version = "1.0.0"

Version is set at build time or defaults to "dev".

Functions

This section is empty.

Types

type Config

type Config struct {
	// Port to listen on
	Port int
	// Upstream API base URL (e.g. "https://api.example.com")
	UpstreamBase string
	// API key for upstream
	UpstreamAPIKey string
	// Routing config override (nil = use default)
	RoutingConfig *router.RoutingConfig
}

Config controls the proxy server behavior.

type CostBreakdown

type CostBreakdown struct {
	Total      float64 `json:"total"`
	Input      float64 `json:"input"`
	Output     float64 `json:"output"`
	Baseline   float64 `json:"baseline"`
	SavingsPct *int    `json:"savings_pct,omitempty"`
	Model      string  `json:"model"`
	Tier       string  `json:"tier,omitempty"`
}

CostBreakdown is the usage.cost payload injected into every routed response.

type Server

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

Server is the OpenAI-compatible proxy with smart routing.

func New

func New(cfg Config) *Server

New creates a new proxy server.

func (*Server) Close

func (s *Server) Close()

Close shuts down the proxy server and its components.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the proxy server.

Jump to

Keyboard shortcuts

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