Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

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.

关于 About

The CLI for the Claude API
anthropicapiclaudecli

语言 Languages

Go99.2%
Shell0.7%
PowerShell0.1%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
575
Total Commits
峰值: 50次/周
Less
More

核心贡献者 Contributors