anthropic

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: Apache-2.0 Imports: 7 Imported by: 2

README

Anthropic Plugin

This plugin provides a simple interface for using Anthropic's services.

Prerequisites

  • Go installed on your system
  • An Anthropic API key

Running Tests

First, set your Anthropic API key as an environment variable:

export ANTHROPIC_API_KEY=<your-api-key>

By default, baseURL is set to "https://api.anthropic.com/v1". However, if you want to use a custom value, you can set ANTHROPIC_BASE_URL environment variable:

export ANTHROPIC_BASE_URL=<your-custom-base-url>
Running All Tests

To run all tests in the directory:

go test -v .
Running Tests from Specific Files

To run tests from a specific file:

# Run only generate_live_test.go tests
go test -run "^TestGenerator"

# Run only anthropic_live_test.go tests
go test -run "^TestPlugin"
Running Individual Tests

To run a specific test case:

# Run only the streaming test from anthropic_live_test.go
go test -run "TestPlugin/streaming"

# Run only the Complete test from generate_live_test.go
go test -run "TestGenerator_Complete"

# Run only the Stream test from generate_live_test.go
go test -run "TestGenerator_Stream"
Test Output Verbosity

Add the -v flag for verbose output:

go test -v -run "TestPlugin/streaming"

Note: All live tests require the ANTHROPIC_API_KEY environment variable to be set. Tests will be skipped if the API key is not provided.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anthropic

type Anthropic struct {
	Opts []option.RequestOption
	// contains filtered or unexported fields
}

func (*Anthropic) DefineModel

func (a *Anthropic) DefineModel(id string, opts ai.ModelOptions) ai.Model

func (*Anthropic) Init

func (a *Anthropic) Init(ctx context.Context) []api.Action

func (*Anthropic) Model

func (a *Anthropic) Model(g *genkit.Genkit, id string) ai.Model

func (*Anthropic) Name

func (a *Anthropic) Name() string

Name implements genkit.Plugin.