Documentation
¶
Overview ¶
Package anthropicadmin reads what an Anthropic organization has spent.
Anthropic's replies carry tokens and no money, and a Claude Console org has no read-only credential for its cost report: an Admin key or an org:admin login is full access to the org, whatever it is used for. So a host should hold one as little as it can. This package takes either, and prefers a login, which leaves no key for the host to keep:
KeyFile a file holding an Admin API key (sk-ant-admin…) Ant Anthropic's `ant` CLI, logged in under Profile with the org:admin scope
A key file wins when it exists: somebody put it there on purpose. With neither, How says so and a host shows estimates.
The report is daily, in UTC, and usually within 5 minutes of the request. It is org-wide: spend per key has another API, behind by hours.
Index ¶
Constants ¶
const DefaultProfile = "admin"
DefaultProfile is the ant profile the admin login is kept under, apart from any day-to-day one.
Variables ¶
var ErrNoCredential = errors.New("no Anthropic admin credential")
ErrNoCredential means neither a key file nor an ant login is set up.
Functions ¶
Types ¶
type Source ¶
type Source struct {
KeyFile string // path; "" or a missing file is no key
Ant string // path to ant; "" is not installed
Profile string // "" is DefaultProfile
Base string // "" is https://api.anthropic.com
HTTP *http.Client
}
Source is where an admin credential comes from.
func (Source) How ¶
How names the flow this source would use: "key", "ant", or "" for neither. "ant" says it is installed, not that it is logged in.
func (Source) LoginArgs ¶
LoginArgs are the arguments of the login, for a host that runs it with a terminal attached. noBrowser prints a URL and reads a pasted code.
func (Source) LogoutArgs ¶
LogoutArgs are the arguments that remove the login.