Versions in this module Expand all Collapse all v0 v0.0.195 Sep 11, 2026 Changes in this version + const APIKeyEnvVar + const AuthFileName + const DefaultBaseURL + const DefaultStudioHost + const DefaultTerminalWidth + const ErrNetwork + const ErrNotAuthenticated + const ErrSessionExpired + const PathCredits + const PathNamespaces + const PathSubscriptions + const PathUsageSummary + const PathWhoami + const UserAgent + var PlanCredits = map[string]float64 + var PlanNames = map[string]string + func AuthPath(home string) string + func DefaultHome() string + func FormatCost(value float64) string + func FormatCredits(amount float64) string + func FormatCreditsView(credits *Credits) string + func FormatDuration(d time.Duration) string + func FormatNamespacesView(namespaces *Namespaces) string + func FormatSubscriptionView(sub *Subscription) string + func FormatSummaryView(summary *UsageSummary) string + func FormatUsage(view *View, opts FormatOptions) string + func FormatUsageJSON(data *UsageData) ([]byte, error) + func FormatWhoami(whoami *Whoami) string + func ProgressBarWidth(terminalWidth int) int + func ResolveBaseURL(apiURL string) string + func ResolveHome(home string) (string, error) + type APIError struct + Code string + Docs string + Message string + Method string + Path string + Status int + func (e *APIError) Error() string + func (e *APIError) Unauthorized() bool + type Auth struct + APIKey string + AuthenticatedAt string + KeyName string + Source string + UserID string + UserName string + func ReadAuth(home string) (*Auth, error) + type Bar struct + Empty string + Filled string + func BuildBlockBar(percentage float64, width int) Bar + type Client struct + Auth *Auth + BaseURL string + HTTP *http.Client + Home string + UserAgent string + func NewClient(home, baseURL string) (*Client, error) + func (c *Client) Credits(ctx context.Context, orgID string) (*Credits, error) + func (c *Client) Endpoint(path string, params map[string]string) string + func (c *Client) FetchUsage(ctx context.Context) (*UsageData, error) + func (c *Client) FetchUsageWithOptions(ctx context.Context, opts UsageOptions) (*UsageData, error) + func (c *Client) Get(ctx context.Context, path string, params map[string]string, out any) error + func (c *Client) Namespaces(ctx context.Context) (*Namespaces, error) + func (c *Client) Subscription(ctx context.Context, orgID string) (*Subscription, error) + func (c *Client) Summary(ctx context.Context, orgID, since string) (*UsageSummary, error) + func (c *Client) Whoami(ctx context.Context, orgID string) (*Whoami, error) + type CreditBalance struct + BelowThreshold bool + CreditThreshold float64 + FreeCredits float64 + MonthlyCredits float64 + PurchasedCredits float64 + type Credits struct + Credits CreditBalance + WindowLimits *WindowLimits + type CreditsView struct + FreeRemaining float64 + HasCreditsInfo bool + MonthlyRemaining float64 + PurchasedRemaining float64 + TotalPool float64 + TotalRemaining float64 + TotalSpent float64 + UsagePercent float64 + type FormatOptions struct + Color bool + Width int + type Namespaces struct + Org *Org + Orgs []Org + Success bool + Type string + User User + type NetworkError struct + Err error + URL string + func (e *NetworkError) Error() string + func (e *NetworkError) Unwrap() error + type Org struct + ID string + Login string + Name string + type OrgLimit struct + Exceeded bool + Limit float64 + Model string + ModelLabel string + ResetAt string + ResetInterval string + Scope string + Spent float64 + type Plan struct + ID string + MonthlyCredits float64 + Name string + func GetPlanInfo(planID string) *Plan + type Subscription struct + CancelAt *string + CancelAtPeriodEnd bool + CanceledAt *string + CreatedAt string + CurrentPeriodEnd string + CurrentPeriodStart string + EndedAt *string + ID string + Metadata json.RawMessage + OrgID *string + PendingPhase json.RawMessage + PlanID string + PriceID string + Quantity int + Status string + UserID string + type SubscriptionResponse struct + Data *Subscription + Success bool + type UsageData struct + Credits *Credits + Errors []string + Subscription *Subscription + Summary *UsageSummary + Whoami *Whoami + type UsageOptions struct + OrgID string + Since string + type UsageSummary struct + AverageCost float64 + CompletedCount int + FailedCount int + PeriodBasis string + SuccessRate float64 + TotalCost float64 + TotalCount int + TotalCredits float64 + TotalFreeCredits float64 + TotalMonthlyCredits float64 + TotalPurchasedCredits float64 + TotalTokens int64 + TotalTokensIn int64 + TotalTokensOut int64 + type User struct + Email string + ID string + Name string + UserName string + type View struct + Credits CreditsView + DaysLeft *int + HasBillingData bool + Now time.Time + OrgLimits []OrgLimit + Plan *Plan + Subscription *Subscription + Summary *UsageSummary + UsageURL string + UsageURLDisplay string + WindowLimits *WindowLimits + func ProjectUsageView(data *UsageData, now time.Time) *View + type Whoami struct + Org *Org + OrgLimits []OrgLimit + Success bool + User User + type WindowLimits struct + Exceeded *bool + FiveHour *WindowSpan + Limited bool + Weekly *WindowSpan + type WindowSpan struct + Cap float64 + Exceeded bool + ResetAt float64 + Used float64