Help us shape the future of Go! Take the 2026 Go Developer Survey

anthropic-cli

module
v2.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: Apache-2.0, MIT

README

ant — Claude Platform CLI

GitHub release Homebrew

ant is the official CLI for the Claude Platform. It puts the Claude API in your terminal — send messages, manage agents and sessions, upload files, and script against every API endpoint.

Demo of the ant CLI

Documentation

Full documentation is available at platform.claude.com/docs/en/api/sdks/cli.

Installation

Installing with Homebrew
brew install anthropics/tap/ant
Installing with Go

To test or install the CLI locally, you need Go version 1.22 or later installed.

go install 'github.com/anthropics/anthropic-cli/v2/cmd/ant@latest'

Once you have run go install, the binary is placed in your Go bin directory:

  • Default location: $HOME/go/bin (or $GOPATH/bin if GOPATH is set)
  • Check your path: Run go env GOPATH to see the base directory

If commands aren't found after installation, add the Go bin directory to your PATH:

# Add to your shell profile (.zshrc, .bashrc, etc.)
export PATH="$PATH:$(go env GOPATH)/bin"

Getting started

Log in with your Claude Console account:

ant auth login

Or set the ANTHROPIC_API_KEY environment variable to an API key from the Claude Console.

To hand the CLI a key from a secret manager without putting it in the environment, pipe it on stdin:

op read op://vault/anthropic/api-key | ant --api-key-stdin models list

Then send your first message:

ant messages create \
  --max-tokens 1024 \
  --message '{role: user, content: "Hello, Claude"}' \
  --model claude-opus-5-5

Structured flags accept relaxed JSON or YAML, so unquoted keys are fine.

Claude Models on Google Cloud (Anthropic managed)

Sign in with Google and name your workspace; the CLI then sends requests through the Google Cloud gateway and keeps the Google access token fresh:

gcloud auth application-default login

export ANTHROPIC_GOOGLE_CLOUD_PROJECT=my-project
export ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID=wrkspc_...
ant models list

The same settings are available as --google-cloud-project, --google-cloud-workspace-id and --google-cloud-location (default global). The project defaults to the one your Google credentials carry. Any credentials Google's Application Default Credentials find are used, including a service account key named by GOOGLE_APPLICATION_CREDENTIALS. An API key, an auth token or a profile named with --profile takes precedence; ant auth status shows which is in use. Google credentials are sent only to the gateway: --base-url and ANTHROPIC_BASE_URL are not used, and --google-cloud-base-url (ANTHROPIC_GOOGLE_CLOUD_BASE_URL) overrides the gateway URL. ant beta:worker is not supported on Google Cloud.

Claude Platform on AWS

Name your region and workspace; the CLI then sends requests through the Claude Platform on AWS gateway, signed with your AWS credentials:

export AWS_REGION=us-east-1
export ANTHROPIC_AWS_WORKSPACE_ID=wrkspc_...
ant models list

The same settings are available as --aws-region and --aws-workspace-id. Either flag, ANTHROPIC_AWS_WORKSPACE_ID or an AWS API key selects AWS; AWS_REGION and AWS_PROFILE on their own don't, since most AWS machines set them for other reasons. The region defaults to AWS_REGION, then AWS_DEFAULT_REGION. Any credentials the AWS default credential chain finds are used, including AWS_PROFILE, environment keys and an IAM role. To use an API key generated in the AWS Console instead, set ANTHROPIC_AWS_API_KEY or pipe it to --aws-api-key-stdin. The key works only in the region it was generated in, so set the region to match. ANTHROPIC_API_KEY, an auth token, a profile named with --profile or Google Cloud settings take precedence; ant auth status shows which is in use. AWS credentials are sent only to the gateway: --base-url and ANTHROPIC_BASE_URL are not used, and --aws-base-url (ANTHROPIC_AWS_BASE_URL) overrides the gateway URL. ant beta:worker is not supported on AWS.

Requirements

macOS, Linux, or Windows.

Contributing

See CONTRIBUTING.md.

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details. Versions released before the change from the MIT License, and third-party contributions merged before it, remain under the MIT License. See LICENSE-MIT.

Directories

Path Synopsis
cmd
ant command
internal
apischema
Package apischema lists the fields of some of the API's resources, and the resource that each field refers to, judged by the field's name and shape.
Package apischema lists the fields of some of the API's resources, and the resource that each field refers to, judged by the field's name and shape.
declarative/acctest
Package acctest drives `ant apply` lifecycles against a real API.
Package acctest drives `ant apply` lifecycles against a real API.
declarative/claude
Package claude teaches the core reconciler about the Claude Developer Platform: which resources exist, what their files look like, which fields the server owns, and how to talk to the API.
Package claude teaches the core reconciler about the Claude Developer Platform: which resources exist, what their files look like, which fields the server owns, and how to talk to the API.
declarative/conformance
Package conformance is a tool-neutral format for reconcile test cases, and a runner that drives any declarative client of the Claude Developer Platform through them against the real service.
Package conformance is a tool-neutral format for reconcile test cases, and a runner that drives any declarative client of the Claude Developer Platform through them against the real service.
declarative/core
Package core reconciles a tree of declarative files against a remote API: it parses them, resolves the references between them, orders the work, diffs it against what the server holds, and records the outcome in a lockfile.
Package core reconciles a tree of declarative files against a remote API: it parses them, resolves the references between them, orders the work, diffs it against what the server holds, and records the outcome in a lockfile.
declarative/render
Package render turns a declarative plan into terminal output.
Package render turns a declarative plan into terminal output.
sessions/live
Package live is the view-agnostic transport for an attached Managed Agents session.
Package live is the view-agnostic transport for an attached Managed Agents session.
sessions/sessiontest
Package sessiontest builds session events from terse JSON for the sessions test suites.
Package sessiontest builds session events from terse JSON for the sessions test suites.
sessions/timeline
Package timeline folds an ordered stream of session events into the nodes the connect TUI renders.
Package timeline folds an ordered stream of session events into the nodes the connect TUI renders.
sessions/tui
Package tui is the terminal front end of `ant beta:sessions connect`: a scrolling transcript above a composer, with a status bar on top and key hints below.
Package tui is the terminal front end of `ant beta:sessions connect`: a scrolling transcript above a composer, with a status bar on top and key hints below.
sessions/web
Package web serves the single-file session viewer on loopback and bridges it to internal/sessions/live: the browser gets whole events over SSE and writes back through POST /send, while credentials and transport stay in this process.
Package web serves the single-file session viewer on loopback and bridges it to internal/sessions/live: the browser gets whole events over SSE and writes back through POST /send, while credentials and transport stay in this process.
termsafe
Package termsafe makes text from outside the program, such as API responses, safe to print on a terminal.
Package termsafe makes text from outside the program, such as API responses, safe to print on a terminal.
pkg
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL