anthropics/anthropic-sdk-go

Access to Anthropic's safety-first language model APIs via Go

Claude SDK for Go – Quick Overview

What it is: A Go‑language client library that lets developers call Anthropic’s Claude large‑language‑model API from their Go applications.

Key features

  • Simple NewClient factory that reads your API key from ANTHROPIC_API_KEY (or you can pass it explicitly).
  • Typed request structs such as MessageNewParams and helper constructors like NewUserMessage/NewTextBlock to build Claude chat‑style prompts.
  • Strongly‑typed response objects (Message, Content, etc.) that map directly to the Claude API fields.
  • Supports the latest Claude model identifiers (e.g., ModelClaudeOpus5_5).
  • Works with Go 1.24+ and is published on pkg.go.dev for easy reference.

Typical use‑case

client := anthropic.NewClient(option.WithAPIKey("my-key"))
msg, _ := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
    MaxTokens: 1024,
    Messages: []anthropic.MessageParam{
        anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),
    },
    Model: anthropic.ModelClaudeOpus5_5,
})
fmt.Println(msg.Content)

The snippet shows how to ask Claude a question and print the model’s reply.

Who it’s for: Go developers who want to integrate Anthropic’s Claude LLM into services, bots, or any backend system without handling raw HTTP calls.

How to get it: Add the module with go get -u github.com/anthropics/anthropic-sdk-go@v1.80.0 or import it directly in your code. Full docs are at the linked Anthropic platform page.

License: MIT, so you can use it in both open‑source and commercial projects.

Related

  • Project
  • Project
  • Project
  • Dispatch
  • Dispatch