MCPcopy Index your code
hub / github.com/anthropics/anthropic-sdk-go

github.com/anthropics/anthropic-sdk-go @v1.56.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.56.0 ↗ · + Follow
8,495 symbols 21,347 edges 237 files 3,396 documented · 40% 33 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Claude SDK for Go

Go Reference

The Claude 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" // imported as anthropic
)

Or explicitly add the dependency:

go get -u 'github.com/anthropics/anthropic-sdk-go@v1.56.0'

Getting started

package main

import (
    "context"
    "fmt"

    "github.com/anthropics/anthropic-sdk-go"
    "github.com/anthropics/anthropic-sdk-go/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.ModelClaudeOpus4_6,
    })
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v\n", message.Content)
}

Requirements

Go 1.24+

Contributing

See CONTRIBUTING.md.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Extension points exported contracts — how you extend this code

BetaTool (Interface)
BetaTool represents a tool that can be executed by the BetaToolRunner. [8 implementers]
betatoolrunner.go
Unmarshaler (Interface)
Unmarshaler is the interface implemented by types that can unmarshal a JSON description of themselves. The input can be [1008 …
internal/encoding/json/decode.go
IdentityTokenProvider (Interface)
IdentityTokenProvider provides a JWT identity token for federation. [4 implementers]
internal/auth/types.go
Union (Interface)
(no doc) [6 implementers]
internal/apiform/form_test.go
Queryer (Interface)
(no doc) [33 implementers]
internal/apiquery/query.go
Union (Interface)
(no doc) [6 implementers]
internal/apijson/json_test.go
ParamNullable (Interface)
ParamNullable encapsulates all structs in parameters, and all [Opt] types in parameters. [1 implementers]
packages/param/param.go
RequestOption (Interface)
(no doc) [2 implementers]
internal/requestconfig/requestconfig.go

Core symbols most depended-on inside this repo

UnmarshalRoot
called by 1540
internal/apijson/decoder.go
Valid
called by 374
packages/param/option.go
IsOmitted
called by 368
packages/param/param.go
MarshalObject
called by 308
packages/param/encoder.go
New
called by 234
message.go
String
called by 217
packages/param/option.go
Error
called by 214
mcp/mcp.go
marshalString
called by 202
shared/constant/constants.go

Shape

Method 5,036
Struct 1,449
Function 1,322
TypeAlias 560
Interface 111
FuncType 17

Languages

Go100%

Modules by API surface

betamessage.go1,428 symbols
message.go1,031 symbols
betasessionevent.go908 symbols
shared/constant/constants.go611 symbols
betaagent.go325 symbols
betadeployment.go280 symbols
betasession.go277 symbols
betavaultcredential.go229 symbols
betawebhook.go192 symbols
betadeploymentrun.go133 symbols
betaenvironment.go108 symbols
betasessionthread.go103 symbols

For agents

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

⬇ download graph artifact