go.bigb.es/claudio

v0.7.0
Doc Versions Source

Variables

DefaultMetrics is the package-level metrics instance.

Functions

f func CloseLogger

src

CloseLogger logs a shutdown message and closes the log file if open.

f func SetHTTPDebug

src
func SetHTTPDebug(enabled bool, outputPath string)

SetHTTPDebug enables or disables proxy logging with an optional output path. Must be called before any logging happens (i.e. before Start/StartPassthrough). If outputPath is empty, defaults to "./claude-proxy.log".

f func Start

src
func Start(upstreamURL string, tokenFunc func() (string, error), extraHeaders map[string]string, proxyURL string, providerName string) (addr string, shutdown func(), err error)

Start launches a local Anthropic-to-OpenAI translation proxy. upstreamURL is the OpenAI-compatible base URL (e.g. "https://api.openai.com/v1"). Returns the proxy address (host:port), a shutdown function, and any error.

f func StartPassthrough

src
func StartPassthrough(upstreamURL string, tokenFunc func() (string, error), proxyURL string, providerName string) (addr string, shutdown func(), err error)

StartPassthrough launches a logging-only proxy that forwards requests unchanged. Used for Anthropic-compatible providers to enable logging without translation.

f func StartSOCKSBridge

src
func StartSOCKSBridge(socksURL string) (addr string, shutdown func(), err error)

StartSOCKSBridge starts a local HTTP CONNECT proxy that forwards connections through the given SOCKS5 proxy. This allows clients that only support HTTP(S) proxies (like Node.js / Claude Code) to route through SOCKS5.

f func StaticToken

src
func StaticToken(key string) func() (string, error)

StaticToken returns a token function that always returns the given key.

Types

T type CallRecord

src
type CallRecord struct {
	Provider       string
	UpstreamDomain string
	Endpoint       string
	Model          string
	StatusCode     int
	Stream         bool
	Duration       time.Duration
	InputTokens    int
	OutputTokens   int
	CacheCreation  int
	CacheRead      int
	Error          bool
	QuotaProbe     bool
	Timestamp      time.Time
}

CallRecord holds metrics for a single proxy call.

T type Metrics

src
type Metrics struct {
	// contains filtered or unexported fields
}

Metrics collects proxy call records for the session.

m func (*Metrics) Record

src
func (m *Metrics) Record(r CallRecord)

Record appends a call record.

m func (*Metrics) Summary

src
func (m *Metrics) Summary() string

Summary returns a formatted metrics summary. Returns empty string if no calls recorded.