/
View dependency graph
Depends on
- dh-golang (dh-sequence-golang)
- dpkg (dpkg-build-api)
- golang-defaults (golang-any)
- golang-github-dnaeon-go-vcr (golang-github-dnaeon-go-vcr-dev)
- golang-github-invopop-jsonschema (golang-github-invopop-jsonschema-dev)
- golang-github-tidwall-gjson (golang-github-tidwall-gjson-dev)
- golang-github-tidwall-sjson (golang-github-tidwall-sjson-dev)
- golang-golang-x-oauth2 (golang-golang-x-oauth2-google-dev)
- golang-golang-x-sync (golang-golang-x-sync-dev)
- golang-google-api (golang-google-api-dev)
- golang-testify (golang-github-stretchr-testify-dev)
- debhelper-compat, golang-github-aws-aws-sdk-go-v2-dev, golang-github-aws-smithy-go-dev
README (full)
Claude SDK for Go
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/[email protected]'
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.22+
Contributing
See CONTRIBUTING.md.
License
This project is licensed under the MIT License. See the LICENSE file for details.