Claude Code API: Architecture, Models, and CCA-F Exam Guide
July 29, 2026
A technical explainer mapping the three layers of the Claude Code API — Anthropic REST API, CLI invocation surface, and Agent SDK — with CCA-F exam guidance.
The Claude Code API is not a single endpoint — it is three layered interfaces: the Anthropic REST API that Claude Code calls for model inference, the CLI and stdin surface that lets you drive Claude Code headlessly in scripts, and the Agent SDK extension points for building tools on top of Claude Code. The CCA-F exam tests all three layers.
What Is the Claude Code API? Three Layers Defined
When developers search for the Claude Code API, they often expect a single REST endpoint or SDK package. The reality is architectural: Claude Code exposes three distinct programmatic surfaces, each operating at a different level of abstraction. Conflating them is one of the most common mistakes on the Claude Certified Architect — Foundations exam.
Layer 1: The Anthropic REST API
Claude Code's inference engine is POST https://api.anthropic.com/v1/messages. Every prompt you type interactively, every tool result Claude processes, and every response Claude generates flows through this endpoint. Your ANTHROPIC_API_KEY authenticates these calls. The messages array, tool definitions, and model parameter in each request follow the same schema you would use calling the API directly from any Anthropic SDK.
Layer 2: The CLI and stdin Surface
Claude Code's headless invocation interface lives at the command line. The --print flag suppresses the interactive TUI and writes Claude's response to stdout. The --model flag overrides the active model. The --no-permission-prompts flag prevents pauses during automated execution. This is the layer most platform and DevOps engineers interact with when embedding Claude Code in CI/CD workflows.
Layer 3: The Agent SDK and Tool Extension Points
The Anthropic Agent SDK and Model Context Protocol (MCP) form the third layer — the surface for extending what Claude Code can do. MCP servers connect Claude Code to external data sources and APIs through a standardized tool interface. The Agent SDK supports managed agents with persistent state, versioned configurations, and server-hosted tool execution. The CCA-F exam probes this layer most heavily in its agentic architecture domain.
How Does Claude Code Connect to Anthropic's API Under the Hood?
When Claude Code receives a prompt, it constructs a structured JSON payload and sends it to POST /v1/messages. Three environment variables govern this connection:
ANTHROPIC_API_KEY— required; authenticates all inference callsANTHROPIC_BASE_URL— optional; overrides the API host for proxied or enterprise deploymentsANTHROPIC_MODEL— optional; sets the default model without a per-invocation flag
Claude Code applies its own defaults on top of the raw API. For agentic loops on Opus 4.7 and later models, Claude Code sets output_config: {effort: "xhigh"} — the level between high and max that controls thinking depth and token spend, and the documented default for coding and agentic use cases in Claude Code. This elevated effort level explains why Claude Code's agentic loops typically consume more tokens than a bare API call with the same prompt, a distinction the CCA-F exam addresses in questions about token budget and latency trade-offs.
Which Claude API Models Can Claude Code Use — and How Do You Switch Them?
Claude Code works with any model in the Anthropic catalog. The active model is determined at runtime from ANTHROPIC_MODEL, or overridden per-invocation:
claude --model claude-sonnet-4-6 "Refactor this function for readability"
A well-designed Claude Code pipeline often uses different claude api models for different sub-tasks. Claude Code's own Explore subagents — which handle read-only file search — run on Haiku, the fastest and most cost-effective tier, while the main agentic loop stays on Opus or Sonnet. This pattern of delegating sub-tasks to a lower-tier model is an architectural strategy the CCA-F exam covers under model selection design.
Current production models and their context windows (figures as of mid-2026 — verify against the Anthropic model docs before your exam):
- claude-opus-4-8: 1M token context window — highest capability, optimal for complex multi-step agentic tasks
- claude-sonnet-4-6: 1M token context window — strong balance of speed and intelligence
- claude-haiku-4-5: 200K token context window — fastest and most cost-effective
Do not confuse context window size with maximum output tokens — they are separate architectural constraints and the CCA-F exam treats them as such.
How Do You Invoke Claude Code Programmatically Without a Human in the Loop?
Three CLI patterns make Claude Code fully headless:
- Print mode:
claude --print "prompt"writes the final response to stdout and exits. Pipe dynamic content via stdin:cat error.log | claude --print "Diagnose this error" - Permission suppression:
--no-permission-promptsprevents Claude Code from pausing when a tool call would normally require human approval — essential for unattended CI/CD runs - Output chaining: stdout from print mode pipes directly into downstream tools, files, or scripts, making Claude Code composable with standard Unix tooling
A typical CI/CD integration:
git diff HEAD~1 | claude --print --no-permission-prompts \
"Write a commit message for these changes" > commit_msg.txt
The CCA-F exam distinguishes interactive from headless use. Expect questions about which flag combination enables unattended execution and how stdin piping changes the way prompts and context reach the model.
How Does the Claude Code API Interact with Model Context Protocol Servers?
Model Context Protocol (MCP) is an open standard that lets Claude Code connect to external services — databases, APIs, file systems — through a uniform interface. Claude Code uses model context protocol MCP servers to extend its built-in toolset with integrations your team builds or installs from the broader MCP ecosystem.
Each MCP server declares named tools with descriptions and JSON input schemas. Claude Code discovers these tools at startup and invokes them during an agentic session exactly as it invokes built-in tools like bash or file read/write. The MCP server handles execution; Claude Code handles reasoning about when to call each tool and what to do with the result.
From an exam architecture perspective, MCP servers bridge Layer 2 (CLI configuration — which servers to load) and Layer 3 (tool definitions that participate in the messages array through the standard tool-use protocol). A common CCA-F question traces the flow of a tool call from a user prompt, through the MCP server, and back into the assistant turn.
Because MCP is an actively evolving standard, the CCA-F exam focuses on architectural understanding — what a server exposes, how Claude Code discovers tools, and what the request/response cycle looks like — rather than memorizing specific server implementations.
What Does the CCA-F Exam Actually Test About the Claude Code API?
Practitioner observation of CCA-F domain coverage indicates the Claude Code API surfaces across three primary question areas. Plinth Prep is an independent study resource, not affiliated with Anthropic.
Architecture Identification
These questions ask you to place a behavior, error, or configuration within the correct layer. A missing ANTHROPIC_API_KEY is a Layer 1 issue. Claude Code hanging in CI while waiting for permission approval is a Layer 2 issue. A custom MCP tool that fails to appear in the active tool list is a Layer 3 issue. The exam expects confident reasoning about all three layers and their boundaries.
Model Selection Strategy
These questions probe your understanding of --model, the ANTHROPIC_MODEL environment variable, and when to route sub-tasks to a lower-tier model. Expect trade-off questions framed around cost, latency, and context window — not raw capability rankings.
Headless and Agentic Pipeline Design
These questions test whether you can construct a valid headless invocation and predict how Claude Code behaves in an automated pipeline. The interaction between --no-permission-prompts and tool use during agentic loops is a recurring exam pattern worth practicing.
FAQ: Claude Code API Quick-Reference Answers
What is the Claude Code API?
The Claude Code API is not a single interface — it is three stacked layers: the Anthropic REST API for model inference, the CLI and stdin surface for headless scripting, and the Agent SDK extension points for building custom tools. Each layer has distinct configuration options, and the CCA-F exam tests all three.
How do you switch models in Claude Code?
Set the ANTHROPIC_MODEL environment variable to any Anthropic model ID, or pass --model on each invocation. Claude Code also lets sub-tasks run on a lower-tier model — read-only search tasks often use Haiku to reduce cost and latency while heavier agentic reasoning stays on Opus or claude-sonnet-4-6.
How do you run Claude Code headlessly in a script or CI pipeline?
Use the --print flag to suppress the interactive TUI and write Claude's response to stdout. Add --no-permission-prompts to prevent pauses during automated tool calls. Pipe input through stdin for dynamic content. These three patterns give you a fully headless, scriptable Claude Code invocation suitable for CI/CD pipelines.
What is Model Context Protocol and how does it extend Claude Code?
Model Context Protocol is an open standard that lets Claude Code connect to external services — databases, APIs, file systems — through a standardized server interface. Each MCP server exposes named tools with input schemas. Claude Code discovers these at startup and invokes them during agentic sessions exactly as it invokes its built-in tools.
What does the CCA-F exam test about the Claude Code API?
The CCA-F exam asks you to identify which layer a given behavior belongs to — REST API, CLI surface, or Agent SDK — and how they interact in agentic pipelines. Expect architecture questions about model selection, headless flags, MCP tool discovery, and how claude api models differ by context window and capability tier.
Frequently asked questions
- What is the Claude Code API?
- The Claude Code API is not a single interface — it is three stacked layers: the Anthropic REST API for model inference, the CLI and stdin surface for headless scripting, and the Agent SDK extension points for building custom tools. Each layer has distinct configuration options, and the CCA-F exam tests all three.
- How do you switch models in Claude Code?
- Set the ANTHROPIC_MODEL environment variable to any Anthropic model ID, or pass --model on each invocation. Claude Code also lets sub-tasks run on a lower-tier model — read-only search tasks often use Haiku to reduce cost and latency while heavier agentic reasoning stays on Opus or claude-sonnet-4-6.
- How do you run Claude Code headlessly in a script or CI pipeline?
- Use the --print flag to suppress the interactive TUI and write Claude's response to stdout. Add --no-permission-prompts to prevent pauses during automated tool calls. Pipe input through stdin for dynamic content. These three patterns give you a fully headless, scriptable Claude Code invocation suitable for CI/CD pipelines.
- What is Model Context Protocol and how does it extend Claude Code?
- Model Context Protocol is an open standard that lets Claude Code connect to external services — databases, APIs, file systems — through a standardized server interface. Each MCP server exposes named tools with input schemas. Claude Code discovers these at startup and invokes them during agentic sessions exactly as it invokes its built-in tools.
- What does the CCA-F exam test about the Claude Code API?
- The CCA-F exam asks you to identify which layer a given behavior belongs to — REST API, CLI surface, or Agent SDK — and how they interact in agentic pipelines. Expect architecture questions about model selection, headless flags, MCP tool discovery, and how claude api models differ by context window and capability tier.