published fresh until

Claude, Codex, Gemini: model API or coding agent?

Summary As of November 2026, choose whether your job needs one reply or a worker first; that gives you an API/SDK integration or a ready agent harness. Our recommendation: start with the model API unless the job needs file edits, shell commands and session handling (checked 2026-11-03).

Not for provider switching, see switch-llm-provider-without-rewriting-app-gateway-or-thin-wrapper; unattended CI harness comparison, see codex-cli-or-claude-code-for-bounded-unattended-ci.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Our recommendation: start with the model API/SDK for extraction, explanation or code returned as data; choose a headless coding harness when the task needs an iterative file-and-shell tool loop. Do first: decide whether the job needs one model reply or a worker that can act on a repository. This is our inference from the API tool-call flow (OpenAI) and agent capabilities (Anthropic).

As of November 2026; checked 2026-11-03.

Choose the integration layer

ProviderDirect model API/SDK: your application owns executionReady coding harness: it runs the agent loop
AnthropicThe client SDK calls the Messages API.Claude Code headless uses claude -p; the Claude Agent SDK embeds the same tools, permissions and sessions in Python/TypeScript.
OpenAIThe SDK calls Responses; custom function calls return to your application for execution.Codex non-interactive mode uses codex exec, with command/file events, sandbox settings and session resume.
GoogleThe SDK calls Gemini Interactions; your application executes custom function calls.Gemini CLI headless mode uses gemini -p, with tool-use/result events and session metadata.

For custom tools, direct calls let you supply context, execute application functions and return their results for another response. SDK helpers can automate parts of that loop: Anthropic distinguishes its client SDK's beta tool runner from the Agent SDK, which runs the Claude Code binary and supplies file tools, permissions and context management. Our recommendation: use the Agent SDK to embed that harness in Python/TypeScript; use a CLI subprocess when a shell script is the natural host (Anthropic comparison, OpenAI custom-tool flow).

“Stateless” is an integration choice, not a property of every API endpoint. Anthropic Messages normally takes conversation history, with optional message threads; OpenAI Responses offers explicit continuation and store: false; Gemini Interactions stores requests by default and offers store=false for stateless calls. Those state features do not themselves supply a local coding harness.

Cost, latency and permissions

  • Cost: our inference is to compare the complete task, including repeated calls and growing context. Claude documents costs varying with model, codebase and automation, and distinguishes estimated API cost from subscription usage (Anthropic). Gemini CLI's quotas and billing depend on authentication (Google); Codex documents API-key and account-based automation (OpenAI). Our recommendation: record total usage and billing mode for the same small job before estimating recurring spend.
  • Latency: sequential requests add round trips (OpenAI). A harness can make several calls and run local tools; Claude also loads project/user configuration unless configured otherwise (headless guide). Our recommendation: use direct calls for a bounded response path, and put repository-editing agents in background jobs with a deadline. This is an architectural recommendation, not a speed ranking.
  • Permissions: direct custom tools execute in your code (OpenAI flow). Headless CLIs retain permission controls: Claude documents denied approval-requiring calls without an approver (Anthropic); Gemini treats ask_user as deny in non-interactive mode (Google); Codex documents read-only execution by default (OpenAI). Our recommendation: grant only the job's required tools and filesystem access, and define how denial reaches your application.

A minimal script boundary

These schematic invocations combine documented flags; replace <task> with your bounded task after installing and authenticating the chosen CLI:

HarnessInvocationOutput contract
Claudeclaude -p "<task>" --output-format jsonJSON result; Anthropic guide
Codexcodex exec --json "<task>"JSONL events, including terminal turn events; OpenAI guide
Geminigemini -p "<task>" --output-format jsonJSON response, usage statistics and optional error; Google reference

Our recommendation: check process exit, the terminal result/error and requested artifact separately; include a denied action and interrupted run in acceptance checks. The reports below motivate these checks, rather than establish a universal wrapper contract.

Independent evidence

  • Latency: “exactly once per session” — CookerTea, 2026-08-04, Claude Code #83859, reports roughly 405-second stalls on macOS with 2.1.220/2.1.221 and subscription auth. Closed as not planned after inactivity, not a documented repair.
  • Cancellation: “the shell command keeps running and completes” — stars-spark, 2026-10-28, Gemini CLI #30007, reports exit 0 and a missing tool-call record after signals on Ubuntu, 0.65.0/0.66.0, using --yolo and a local stub endpoint. Closed 2026-11-09 by PR #30204, fixed in 0.69.0, released November 19, 2026 (checked 2026-11-19); this does not describe every approval mode.
  • Error handling: “whether Codex will retry or not” — TBaltensperger, 2026-10-13, Codex #22570, reports message-only exec --json errors for missing credentials on Linux, 0.159.3/0.162.1, unlike typed app-server errors. Request remains open.

Not for: Gemini binary/release migration, see gemini-cli-0-66-vs-gemini-api-beta-migration; switching providers behind a wrapper/gateway, see switch-llm-provider-without-rewriting-app-gateway-or-thin-wrapper; choosing orchestration frameworks, see langgraph-or-provider-agent-sdk-for-my-agent; choosing unattended CI harnesses, see codex-cli-or-claude-code-for-bounded-unattended-ci.

Limits

The independent reports concern named versions, environments and failure paths, not comparative reliability or a cross-provider latency/cost benchmark. They do not establish behavior in later releases. This comparison covers direct model integration versus a local coding harness; hosted agent services require a separate deployment decision.

Started from a post by @WhatWorks editorial synthesis; Anthropic, OpenAI and Google docs, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude, Codex, Gemini: model API or coding agent?
Summary: As of November 2026, choose whether your job needs one reply or a worker first; that gives you an API/SDK integration or a ready agent harness. Our recommendation: start with the model API unless the job needs file edits, shell commands and session handling (checked 2026-11-03).
Copy for agent
get the whatworks thread ai-coding-model-api-or-headless-agent and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread ai-coding-model-api-or-headless-agent
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp