github.com/anthropics/anthropic-sdk-go@v1.70.1/README.md (about)

     1  # Claude SDK for Go
     2  
     3  <!-- x-release-please-start-version -->
     4  
     5  <a href="https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go"><img src="https://pkg.go.dev/badge/github.com/anthropics/anthropic-sdk-go.svg" alt="Go Reference"></a>
     6  
     7  <!-- x-release-please-end -->
     8  
     9  The Claude SDK for Go provides access to the [Claude API](https://docs.anthropic.com/en/api/) from Go applications.
    10  
    11  ## Documentation
    12  
    13  Full documentation is available at **[platform.claude.com/docs/en/api/sdks/go](https://platform.claude.com/docs/en/api/sdks/go)**.
    14  
    15  ## Installation
    16  
    17  <!-- x-release-please-start-version -->
    18  
    19  ```go
    20  import (
    21  	"github.com/anthropics/anthropic-sdk-go" // imported as anthropic
    22  )
    23  ```
    24  
    25  <!-- x-release-please-end -->
    26  
    27  Or explicitly add the dependency:
    28  
    29  <!-- x-release-please-start-version -->
    30  
    31  ```sh
    32  go get -u 'github.com/anthropics/anthropic-sdk-go@v1.70.1'
    33  ```
    34  
    35  <!-- x-release-please-end -->
    36  
    37  ## Getting started
    38  
    39  ```go
    40  package main
    41  
    42  import (
    43  	"context"
    44  	"fmt"
    45  
    46  	"github.com/anthropics/anthropic-sdk-go"
    47  	"github.com/anthropics/anthropic-sdk-go/option"
    48  )
    49  
    50  func main() {
    51  	client := anthropic.NewClient(
    52  		option.WithAPIKey("my-anthropic-api-key"), // defaults to os.LookupEnv("ANTHROPIC_API_KEY")
    53  	)
    54  	message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
    55  		MaxTokens: 1024,
    56  		Messages: []anthropic.MessageParam{
    57  			anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),
    58  		},
    59  		Model: anthropic.ModelClaudeOpus4_6,
    60  	})
    61  	if err != nil {
    62  		panic(err.Error())
    63  	}
    64  	fmt.Printf("%+v\n", message.Content)
    65  }
    66  ```
    67  
    68  ## Requirements
    69  
    70  Go 1.24+
    71  
    72  ## Contributing
    73  
    74  See [CONTRIBUTING.md](./CONTRIBUTING.md).
    75  
    76  ## License
    77  
    78  This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.