usage

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package usage supplies shared provider account readers without acquiring credentials.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadVerified

func ReadVerified(ctx context.Context, access func(context.Context) (Access, error), reader Reader) (wire.AccountUsageResponse, error)

ReadVerified publishes usage only while the native credential and route remain the same throughout the provider read.

func RequestError

func RequestError(vendor string, err error) *acp.RequestError

RequestError exposes provider status and retry timing without response bodies or credentials.

Types

type Access

type Access struct {
	APIKey      string
	AccountID   string
	BaseURL     string
	Reason      string
	Fingerprint [32]byte
}

Access identifies the credential and route selected by the native runtime. BaseURL is where the runtime sends the key; Fingerprint covers native routing facts beyond the credential itself.

type Credential

type Credential struct {
	Token     string
	AccountID string
	BaseURL   string
}

Credential identifies the effective provider account resolved by the native harness. BaseURL is the route the harness sends the token to; a reader that addresses the provider's own endpoint ignores it.

type HTTPError

type HTTPError struct {
	StatusCode int
	RetryAt    time.Time
}

HTTPError reports an unsuccessful provider read without exposing credentials or bodies.

func (*HTTPError) Error

func (e *HTTPError) Error() string

type Reader

type Reader interface {
	Read(context.Context, Credential) (wire.AccountUsageResponse, error)
}

Reader reads the account addressed by the caller's effective provider credential.

Directories

Path Synopsis
Package anthropic reads Claude subscription allowances and usage credits.
Package anthropic reads Claude subscription allowances and usage credits.
Package gateway reads the aggregate usage report a forwarding gateway publishes for the upstream accounts it brokers.
Package gateway reads the aggregate usage report a forwarding gateway publishes for the upstream accounts it brokers.
internal
usagehttp
Package usagehttp bounds authenticated provider usage reads.
Package usagehttp bounds authenticated provider usage reads.
Package openaicodex reads ChatGPT subscription allowance windows.
Package openaicodex reads ChatGPT subscription allowance windows.
Package opencodego reads OpenCode Go subscription windows.
Package opencodego reads OpenCode Go subscription windows.
Package openrouter reads OpenRouter key allowances and account credit balances.
Package openrouter reads OpenRouter key allowances and account credit balances.

Jump to

Keyboard shortcuts

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