SPB Git forge

spb/doc-api

Public
2commits 1branches 0releases
15.7 MBsize
maindefault branch
13 days agolast push
Python 88.3% TypeScript 7.6% Shell 4.1%
5.9 KB

# Anthropic ant CLI

Status: DOCUMENTED (not installed locally; no live run). Reference page api/cli/messages/create mirrors POST /v1/messages 1:1. Sources: https://platform.claude.com/docs/en/cli-sdks-libraries/cli/quickstart · …/cli/using · …/cli/authentication · …/cli/scripting · …/cli/apply · …/cli/sessions-connect · https://platform.claude.com/docs/en/api/cli/messages/create · https://platform.claude.com/docs/en/api/beta-headers Machine-readable: generated/fragments/sdks/anthropic-sdks.json (record language: cli) Last verified: 2026-09-18 (docs only)

# Install & auth

Command
Homebrew brew install anthropics/tap/ant
Linux tarball curl -fsSL https://github.com/anthropics/anthropic-cli/releases/download/v1.33.0/ant_1.33.0_${OS}_${ARCH}.tar.gz | sudo tar -xz -C /usr/local/bin ant
Go go install github.com/anthropics/anthropic-cli/cmd/ant@latest (Go ≥1.25)
Check ant --version
Login ant auth login — browser OAuth against the Console, token scoped to one workspace, stored under $ANTHROPIC_CONFIG_DIR/credentials/<profile>.json
Admin ant auth login --scope org:admin under a dedicated profile (org-wide)
API key ANTHROPIC_API_KEY env (overrides every profile) or --api-key; ANTHROPIC_AUTH_TOKEN also honored; ANTHROPIC_BASE_URL / --base-url
Status / logout ant auth status (which credential source & workspace won; not a health check) · ant auth logout [--all]
Profiles ant profile … (workspace_id, base_url, organization_id, scope, client_id, console_url); --profile / ANTHROPIC_PROFILE; WIF for CI
Reuse token in curl ant auth print-credentials --access-token → Authorization: Bearer … (keep ANTHROPIC_API_KEY/ANTHROPIC_AUTH_TOKEN unset)
Completion ant @completion zsh|bash|fish|powershell

# Command structure

ant <resource> <action>; nested resources use colons (ant beta:sessions:events stream). Beta resources live under beta: and add the right anthropic-beta header automatically; --beta a,b (or repeated) overrides/adds.

# Global flags

Flag Meaning
--format auto|json|jsonl|yaml|pretty|raw|explore auto = pretty JSON for create/modify; list/retrieve open the interactive explorer on a TTY, pretty JSON when piped. jsonl = one item/event per line. raw = raw body bytes, no auto-pagination
--transform <GJSON path> reshape/filter (per item on list endpoints)
-r, --raw-output unquoted strings (like jq -r) — not applied to errors
--format-error, --transform-error same for error responses
--workspace-id wrkspc_… anthropic-workspace-id header (ANTHROPIC_WORKSPACE_ID)
--profile, --base-url, --api-key, --beta see above
--debug full HTTP request/response on stderr, keys redacted (shows request-id)

# Request bodies

Scalars → flags; structured values accept relaxed YAML-ish or strict JSON (--message '{role: user, content: "Hello"}'); repeatable flags build arrays (--tool, --message, --event); stdin JSON/YAML document (heredoc <<'YAML') merged with flags (flags win); @path inlines file contents into string fields (binary auto-base64; @file:// text, @data:// base64; \@ literal).

# ant messages create (POST /v1/messages)

bash
ant messages create --model claude-opus-5 --max-tokens 1024 --message '{role: user, content: "Hello, Claude"}'
ant messages create --stream --format jsonl --model claude-opus-5 --max-tokens 1024 --message '{role: user, content: "Hello"}' \
  | jq -rj 'select(.delta.type? == "text_delta") | .delta.text'
ant --debug messages create --model claude-sonnet-5 --max-tokens 1024 --message '{role: user, content: "Hi"}'   # request-id on stderr
ant messages create --stream --format jsonl <<'YAML'
model: claude-sonnet-5
max_tokens: 128000
messages:
  - role: user
    content: Write a detailed analysis...
YAML
Flag Body / header field
--model, --max-tokens, --message (repeatable), --system (string or text blocks; @file.md), --stop-sequence (repeatable), --stream model, max_tokens, messages[], system, stop_sequences[], stream
--metadata, --service-tier auto|standard_only, --cache-control, --container, --inference-geo, --output-config, --thinking, --tool (repeatable), --tool-choice same-named body fields
--temperature, --top-p, --top-k deprecated sampling params (same model rules as the API)
--user-profile-id, --workspace-id anthropic-user-profile-id (beta), anthropic-workspace-id headers
--beta a,b anthropic-beta

Output = the full Message JSON (or, with --stream --format jsonl, one SSE event object per line: message_start, content_block_start, content_block_delta{delta.type: text_delta…}, …). Sibling commands follow the same resource pattern: ant messages count-tokens, ant models list, ant models retrieve <id>, ant messages:batches …, ant files …, ant skills …, ant beta:agents|sessions|environments ….

# Scripting patterns

  • Chain ids: ant beta:agents list --transform id --raw-output | head -1 | xargs -I{} ant beta:agents retrieve --agent-id {}
  • Errors: ant … --format-error yaml --transform-error error.message
  • Claude Code can shell out to ant directly (no integration code).
  • ant apply [--dry-run|--yes|--force|--prune|--upgrade|--lock-file <p>|-v] — Managed Agents resources as files (agents/*.md, environments/*.yaml, memory_stores/, deployments/*.md, skills/<dir>/SKILL.md), lockfile claude-lock.json (commit it); CI: ant apply --yes . with WIF.
  • ant beta:sessions connect --session-id … [--web] [--no-browser] [-v] — live transcript, Enter sends user.message, Esc interrupts, tool-approval prompts.

# Not covered here

Claude Code (claude CLI) is a different tool (agentic coding); Agent SDK and Managed Agents are documented elsewhere in this atlas.