anthropic
Interact with Claude AI from the command line
TLDR
SYNOPSIS
anthropic [-g role content] [-m model] [-s system] [-i image] [-t temp] [-x tokens]
DESCRIPTION
anthropic is a command-line interface for interacting with Anthropic's Claude AI models. It provides direct access to the Claude API from the terminal, allowing users to send text messages and images for analysis.The tool supports multi-turn conversations by chaining multiple -g flags, enabling context-aware interactions. It handles various image formats including PNG, JPEG, and PDF files for vision tasks. The CLI integrates well with shell pipelines, making it useful for scripting and automation workflows.
PARAMETERS
-g, --message role content
Add a message with the specified role (user/assistant) and content. Can be repeated for multi-turn conversations.-m, --model model
Specify the Claude model to use. The built-in default is claude-3-opus-20240229, which has since been retired, so pass a current model such as claude-opus-4-8 or claude-sonnet-4-6.-s, --system prompt
System message providing context or instructions for the conversation.-i, --image path
Path to an image file (PNG, JPEG, or PDF) for vision tasks.-t, --temperature value
Controls response randomness. Higher values produce more creative outputs.-k, --top_k value
Restricts sampling to the top k most likely tokens.-p, --top_p value
Nucleus sampling; restricts to tokens with cumulative probability above threshold.-x, --max_tokens count
Maximum number of tokens in the response. Default: 1024.
CAVEATS
Requires an ANTHROPIC_API_KEY environment variable to be set with valid API credentials. PDF processing requires the Poppler library (used by pdf2image) to be installed on the system; it is not needed if you never pass PDFs. The hardcoded default model (claude-3-opus-20240229) has been retired, so supply a current model with -m. API usage incurs costs based on token consumption.
HISTORY
The anthropic-cli tool is a community project by dvcrn that provides command-line access to Anthropic's Claude models. It wraps the official Anthropic Python SDK and was created for developers who prefer terminal-based workflows over web interfaces. It is distributed on PyPI as anthropic-cli and is unrelated to Anthropic's own claude (Claude Code) and ant command-line tools.
