anthropic-sdk-go

Official Go SDK for Claude's Messages, Files, Skills, and Beta agent APIs, with built-in Bedrock and Vertex AI support.

SDK
Go
vv1.68.0
1,180stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
86/100Excellent
Development Activity96
Maintenance100
Community64
Maturity44
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
85/100Excellent
Architecture82
Code Quality85
Innovation78
Learning Curve95

anthropic-sdk-go is the official Go client library for Anthropic’s Claude API, generated from Anthropic’s OpenAPI spec and covering Messages, Models, Files, Skills, and Completions, plus a growing set of beta agent-session and tool-runner resources for building multi-turn tool-using agents.

Beyond a thin REST wrapper, the SDK ships dedicated subpackages for authenticating through AWS Bedrock, Google Vertex AI, or generic Google Cloud credentials, a native Model Context Protocol (MCP) client, and an explicit credential-resolution chain (API key, auth token, named profile, or environment-federated identity) so the same Client type can target the direct API or either hyperscaler platform without code changes.

What You Get

  • Typed request/response structs for every Claude API resource (Messages, Models, Files, Skills, Completions, and their Beta counterparts)
  • A functional-options client (option.RequestOption) for configuring auth, base URL, retries, and HTTP transport
  • Drop-in subpackages for AWS Bedrock, Google Vertex AI, and generic Google Cloud auth so the same Client targets any of the three platforms
  • Beta agent-session, tool-runner, and native MCP client support for building multi-turn tool-using agents
  • 35+ runnable examples covering streaming, file upload, MCP tool running, and managed agents

Common Use Cases

  • Calling Claude’s Messages API from a Go backend service
  • Streaming message deltas into a chat UI or CLI
  • Running Claude through AWS Bedrock or Google Vertex AI for compliance-driven deployments
  • Building tool-calling agents with the beta session and tool-runner APIs
  • Uploading files and managing Skills programmatically from CI or automation scripts

Under The Hood

Architecture The SDK is organized as a flat top-level anthropic package where each API resource gets its own generated file (message.go, model.go, file.go, skill.go, beta*.go) paired with a matching _test.go, with the Client struct in client.go composing per-resource services (Completions, Messages, Models, Files, Skills, Beta) built by NewClient; cross-cutting request plumbing — auth headers, retries, base URL, credential resolution — lives in internal/requestconfig and internal/auth and is threaded through via the functional-options pattern in option/ (RequestOption), while cloud-specific transports for AWS Bedrock, Google Vertex, and generic Google Cloud auth are isolated into their own bedrock/, vertex/, googlecloud/, and aws/ subpackages that decorate the same Client rather than forking it. DefaultClientOptions implements an explicit credential-precedence chain (API key, then auth token, then named profile, then env-var federation, then fallback profile) that fails closed with a typed auth.NoCredentialsError when nothing resolves.

Tech Stack Written in Go 1.24 (toolchain 1.25.8) with no web framework, since it is a client library; dependencies include aws-sdk-go-v2 and smithy-go for Bedrock request signing, google.golang.org/api and golang.org/x/oauth2 for Vertex and Google Cloud auth, modelcontextprotocol/go-sdk and google/jsonschema-go for MCP tool-calling support, tidwall/gjson and tidwall/sjson for dynamic JSON patching, invopop/jsonschema and pb33f/ordered-map for schema generation, and stretchr/testify plus dnaeon/go-vcr for HTTP-cassette-based test recording. Build and test tooling is a set of shell scripts under scripts/ (bootstrap, lint, format, mock, test) driving gofmt and a local mock server generated from the OpenAPI spec.

Code Quality 62 top-level _test.go files pair almost every generated resource file with a corresponding test, using stretchr/testify assertions and go-vcr cassette recording to replay HTTP fixtures rather than hitting a live API in CI; fuller integration-style testing requires a local mock server via ./scripts/mock. Error handling is explicit and typed — the credential chain returns wrapped, typed errors (auth.NoCredentialsError, profile-load errors) instead of swallowing failures, and generated types carry dedicated unmarshal-error test coverage (paramunmarshal_test.go, schemautil_test.go). Formatting is enforced via gofmt (./scripts/format) and linting via ./scripts/lint, with GitHub Actions CI wired under .github/workflows. Because most of the SDK is generator output, naming is mechanically consistent across resources rather than hand-crafted, and CONTRIBUTING.md is explicit that manual patches to generated files can be lost or conflict on the next generation pass.

API Design What sets this apart from a plain REST wrapper is that it embeds full agent-loop plumbing directly in the client: beta session, thread, event, and tool-runner types (betasessiontoolrunner.go, betatoolrunner.go, toolrunner/) implement multi-turn tool-execution loops, a dedicated mcp/ package adds native Model Context Protocol client support, and skill/skill-version resources model Claude’s Skills feature — none of which is typical of a bare API client. It also unifies three deployment surfaces (the direct Anthropic API, AWS Bedrock, and Google Vertex AI) behind one Client type via swappable auth/transport subpackages, so switching providers is a constructor change rather than a rewrite, though the underlying generated-client-plus-functional-options pattern itself is common across all Stainless-generated SDKs.

Used by 6 apps in this directory

Go
75%
AGPL 3.0

Coder

Devops · Developer Tools · Code Editors

14,299

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
93
Repo Health
90
Technical
69
Dependency
Built with
Go75%
TypeScript23%
Updated today
Go
58%
MIT

hoop

Security · Monitoring

805

A wire-protocol gateway that enforces data masking, command blocking, approval workflows, and full session recording for engineers and AI agents accessing production infrastructure.

View details
85
Repo Health
80
Technical
65
Dependency
Built with
Go58%
Clojure19%
JavaScript14%
Updated 2 days ago
Go
99%
Apache 2.0

klaw

AI Agents · Devops

635

kubectl for AI Agents — manage, schedule, and scale your AI workforce with a single binary that deploys in seconds.

View details
39
Repo Health
74
Technical
83
Dependency
Built with
Go99%
Updated 5 months ago
Go
74%
Other

Notifuse

Marketing

2,089

Open-source, self-hosted alternative to Mailchimp, Brevo, and Klaviyo — send newsletters and transactional emails without per-email pricing or vendor lock-in.

View details
83
Repo Health
80
Technical
66
Dependency
Built with
Go74%
TypeScript23%
Updated yesterday
Go
70%
Apache 2.0

open-code-review

Developer Tools · Devops

21,645

The AI code review agent born at Alibaba's scale — combining deterministic engineering with LLM intelligence for precise, token-efficient reviews.

View details
81
Repo Health
83
Technical
81
Dependency
Built with
Go70%
TypeScript13%
JavaScript11%
Updated 2 days ago
Go
39%
Apache 2.0

Rill

Analytics · Data Engineering

2,853

The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.

View details
87
Repo Health
88
Technical
66
Dependency
Built with
Go39%
TypeScript37%
Svelte22%
Updated 2 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search