Skip to content

About

The CLI for the Claude API

Topics

Resources

Contributing

Security policy

Stars

753 stars

Watchers

23 watching

Forks

Repository files navigation

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.

Claude in Microsoft Foundry

Name your resource and set an API key from the Foundry portal. The CLI then sends requests to that resource:

export ANTHROPIC_FOUNDRY_RESOURCE=my-resource
export ANTHROPIC_FOUNDRY_API_KEY=...
ant messages create \
  --max-tokens 1024 \
  --message '{role: user, content: "Hello, Claude"}' \
  --model claude-opus-5-5

--model takes the name of your deployment, which defaults to the model ID. To use Microsoft Entra ID instead of an API key, set an access token:

export ANTHROPIC_FOUNDRY_AUTH_TOKEN="$(az account get-access-token --resource https://ai.azure.com --query accessToken -o tsv)"

The CLI doesn't refresh the token, so set it again when it expires.

--foundry-resource also sets the resource, and --foundry-api-key-stdin and --foundry-auth-token-stdin read the key or the token from standard input. A key, a token or --foundry-resource selects Foundry; ANTHROPIC_FOUNDRY_RESOURCE on its own doesn't, since a Claude Code setup can export it with no key or token. When both a key and a token are set, the piped one is used; when both come from the environment, the token is used, as in Claude Code, and the CLI prints a note. ANTHROPIC_API_KEY, an auth token, a profile named with --profile, Google Cloud settings and AWS settings take precedence, and ant auth status shows which is in use. Foundry credentials are sent only to your resource, so --base-url and ANTHROPIC_BASE_URL are not used. ANTHROPIC_CUSTOM_HEADERS is not applied either. To send requests to another URL, set --foundry-base-url (ANTHROPIC_FOUNDRY_BASE_URL) in place of the resource, and include the /anthropic path. Claude in Microsoft Foundry lists the features available there. ant beta:worker is not supported on Foundry.

Amazon Bedrock

Name your region. The CLI then sends requests to Amazon Bedrock in that region, signed with your AWS credentials:

export ANTHROPIC_BEDROCK_REGION=us-east-1
ant beta:bedrock:agents list

--bedrock-region also sets the region. Nothing else selects Bedrock: AWS_REGION, AWS_PROFILE and AWS_BEARER_TOKEN_BEDROCK on their own don't, since AWS machines set them for other tools. Any credentials the AWS default credential chain finds are used, including AWS_PROFILE, environment keys and an IAM role. If AWS_BEARER_TOKEN_BEDROCK is set, the CLI sends its value as a bearer token instead of signing requests, so unset it to sign with AWS credentials. ANTHROPIC_API_KEY, an auth token, a profile named with --profile, Google Cloud settings, AWS settings and Foundry settings take precedence, and ant auth status shows which is in use.

The beta:bedrock:* commands go to https://bedrock.{region}.amazonaws.com/anthropic. They run only on Bedrock: when other credentials are in use, they stop before sending anything and name those credentials. The one exception is --base-url on the command line, with credentials that are sent there. Other commands go to https://bedrock-runtime.{region}.amazonaws.com, which serves ant messages create; --model takes a Bedrock model ID there, such as us.anthropic.claude-sonnet-5-5. --workspace-id (ANTHROPIC_WORKSPACE_ID) is still sent as the anthropic-workspace-id header.

AWS credentials are sent only to Bedrock, so --base-url and ANTHROPIC_BASE_URL are not used. ANTHROPIC_CUSTOM_HEADERS is not applied either. To send requests to another URL, set --bedrock-base-url (ANTHROPIC_BEDROCK_BASE_URL). It replaces both URLs and is used exactly as given, so include the /anthropic path if the beta:bedrock:* commands need it there. ant beta:worker is not supported on Bedrock. To attach to a session there, run ant beta:bedrock:sessions connect in place of ant beta:sessions connect.

ant apply manages agents and memory stores on Bedrock, from the same files as elsewhere, and sends its requests where the beta:bedrock:* commands go. It stops at a skill, an environment, a vault or a deployment, which Bedrock doesn't have.

Requirements

macOS, Linux, or Windows.

Contributing

See CONTRIBUTING.md. The sandboxes/ directory, the pieces for running Claude Managed Agents self-hosted sandboxes, is a separate Go module with its own README.

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

Topics

Resources

Contributing

Security policy

Stars

753 stars

Watchers

23 watching

Forks

Releases

Used by

Contributors

Languages