anthropic

package
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package anthropic is a fake Anthropic API that authenticates callers with workload identity federation: JWTs are verified against a JWK set and can be exchanged only once, as the real API enforces.

Index

Constants

View Source
const Audience = "https://api.anthropic.com"

Variables

This section is empty.

Functions

This section is empty.

Types

type Anthropic

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

func New

func New(t *testing.T, fopts ...Option) *Anthropic

New returns a fake Anthropic API. Callers authenticate with WithJWKS or WithAPIKey.

func (*Anthropic) Cleanup

func (a *Anthropic) Cleanup(t *testing.T)

func (*Anthropic) Endpoint

func (a *Anthropic) Endpoint() string

Endpoint is the base URL to configure the Anthropic component with.

func (*Anthropic) Exchanged

func (a *Anthropic) Exchanged() []jwt.Token

Exchanged returns the verified JWTs exchanged for access tokens, in order.

func (*Anthropic) Messages

func (a *Anthropic) Messages() int

Messages returns the number of authenticated messages requests.

func (*Anthropic) Run

func (a *Anthropic) Run(t *testing.T, ctx context.Context)

type Option

type Option func(*options)

Option configures the fake Anthropic API.

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey authenticates callers with apiKey instead of workload identity federation.

func WithJWKS

func WithJWKS(keySet jwk.Set) Option

WithJWKS authenticates callers with workload identity federation, trusting JWTs signed by keys in keySet.

Jump to

Keyboard shortcuts

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