Access to Anthropic's safety-first language model APIs via Go
Go
1,211
847 commits
updated Sep 30, 2026
The Claude SDK for Go provides access to the Claude API from Go applications.
Full documentation is available at platform.claude.com/docs/en/api/sdks/go.
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.78.0'
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.ModelClaudeOpus5_5,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", message.Content)
}
Go 1.24+
See CONTRIBUTING.md.
This project is licensed under the MIT License. See the LICENSE file for details.
(top 24 of 31)
234 followers · starred Mar 2026
594 followers · starred Sep 2025
952 followers · starred Nov 2025
1,966 followers · starred Aug 2024
Access to Anthropic's safety-first language model APIs via Go
Go
1,211
847 commits
updated Sep 30, 2026
The Claude SDK for Go provides access to the Claude API from Go applications.
Full documentation is available at platform.claude.com/docs/en/api/sdks/go.
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.78.0'
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.ModelClaudeOpus5_5,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", message.Content)
}
Go 1.24+
See CONTRIBUTING.md.
This project is licensed under the MIT License. See the LICENSE file for details.
(top 24 of 31)
234 followers · starred Mar 2026
594 followers · starred Sep 2025
952 followers · starred Nov 2025
1,966 followers · starred Aug 2024