MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-go

github.com/anthropics/anthropic-sdk-go

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.18.0 ↗ · + Follow · compare 2 versions
22,690 symbols 69,824 edges 563 files 9,419 documented · 42% ● updated 11d agov2.15.0 · 2026-11-24★ 1,25424 open issues

Browse by type

⨍ Functions 17,396◇ Types & classes 5,294
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Anthropic SDK for Go

Go Reference

The Anthropic SDK for Go provides access to the Claude API from Go applications.

Documentation

Full documentation is available at platform.claude.com/docs/en/api/sdks/go.

Installation

import (
    "github.com/anthropics/anthropic-sdk-go/v2" // imported as anthropic
)

Or explicitly add the dependency:

go get -u 'github.com/anthropics/anthropic-sdk-go/v2@v2.18.0'

Getting started

package main

import (
    "context"
    "fmt"

    "github.com/anthropics/anthropic-sdk-go/v2"
    "github.com/anthropics/anthropic-sdk-go/v2/option"
)

func main() {
    client := anthropic.NewClient(
        option.WithAPIKey("my-anthropic-api-key"), // defaults to os.LookupEnv("ANTHROPIC_API_KEY")
    )
    message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
        MaxTokens: 1024,
        Messages: []anthropic.MessageParam{
            anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),
        },
        Model: anthropic.ModelClaudeOpus5_5,
    })
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v\n", message.Content)
}

Requirements

Go 1.25+

Contributing

See CONTRIBUTING.md.

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details. Versions released before the change from the MIT License, and third-party contributions merged before it, remain under the MIT License. See LICENSE-MIT.

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Method 13,685
Struct 3,812
Function 3,711
TypeAlias 1,171
Interface 284
FuncType 27

Languages

Go100%

Modules by API surface

betamessage.go3,033 symbols
shared/constant/constants.go2,152 symbols
message.go2,003 symbols
betasessionevent.go1,168 symbols
betaagent.go878 symbols
shared/shared.go768 symbols
betabedrocksessionevent.go567 symbols
betasession.go345 symbols
betawebhook.go268 symbols
betaorganizationanalytics.go258 symbols
betadeployment.go257 symbols
betabedrockagent.go234 symbols

Dependencies from manifests, versioned

cloud.google.com/go/authv0.7.2 · 1×
cloud.google.com/go/auth/oauth2adaptv0.2.3 · 1×
cloud.google.com/go/compute/metadatav0.5.0 · 1×
github.com/aws/aws-sdk-go-v2v1.38.0 · 1×
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstreamv1.6.3 · 1×
github.com/aws/aws-sdk-go-v2/configv1.27.27 · 1×
github.com/aws/aws-sdk-go-v2/credentialsv1.17.27 · 1×
github.com/aws/aws-sdk-go-v2/feature/ec2/imdsv1.16.11 · 1×
github.com/aws/aws-sdk-go-v2/internal/configsourcesv1.3.15 · 1×
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2v2.6.15 · 1×
github.com/aws/aws-sdk-go-v2/internal/iniv1.8.0 · 1×

For agents

$ claude mcp add anthropic-sdk-go \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page