This project provides an unofficial Go SDK for Anthropic, a next-generation AI assistant platform. The SDK simplifies interactions with the Anthropic API in Go applications. For more information about Anthropic and its API, visit the official Anthropic documentation.
Install the Anthropic SDK for Go using:
go get github.com/madebywelch/anthropic-go/v3
- Support for both native Anthropic API and AWS Bedrock
- Completion and streaming completion
- Message and streaming message support
- Tool usage capabilities
Here's a basic example of using the SDK:
package main
import (
"context"
"fmt"
"github.com/madebywelch/anthropic-go/v3/pkg/anthropic"
"github.com/madebywelch/anthropic-go/v3/pkg/anthropic/client/native"
)
func main() {
ctx := context.Background()
client, err := native.MakeClient(native.Config{
APIKey: "your-api-key",
})
if err != nil {
panic(err)
}
request := anthropic.NewMessageRequest(
[]anthropic.MessagePartRequest{{Role: "user", Content: []anthropic.ContentBlock{anthropic.NewTextContentBlock("Hello, world!")}}},
anthropic.WithModel[anthropic.MessageRequest](anthropic.Claude35Sonnet),
anthropic.WithMaxTokens[anthropic.MessageRequest](20),
)
response, err := client.Message(ctx, request)
if err != nil {
panic(err)
}
fmt.Println(response.Content)
}
For more detailed usage examples, including streaming, completion, and tool usage, please refer to the pkg/internal/examples
directory in the repository.
Contributions are welcome! To contribute:
- Fork this repository
- Create a new branch (
git checkout -b feature/my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push the branch (
git push origin feature/my-new-feature
) - Create a new pull request
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.