| |

With pay-as-you-go API billing, are you willing to spawn subagents in Codex and Claude Code? Breaking down two charges of $0.282 and $0.444

With pay-as-you-go API billing, are you willing to spawn subagents in Codex and Claude Code? Breaking down two charges of $0.282 and $0.444

Short answer: whether to enable it depends on whether the waiting time saved by parallelism outweighs the extra request cost. Using the same model at the same rate, let’s calculate with an example task: completing it with a single agent costs $0.282. A main agent plus two subagents plus one retry costs $0.444—$0.162 more, about 1.57× the original. The extra money is mainly spent in three places: each subagent reads the context once, the main agent reads the reports back and cross-checks them, and retries after failures. So the conclusion isn’t “enable” or “don’t enable”; it’s enable only for tasks that can progress independently and whose deliverables come with clear evidence, and evaluate them together using “cost per successful task + wall-clock time.”

What you’ll learn from this article

  • A usage-based bill you can verify line by line: how the $0.282 and $0.444 figures are calculated.
  • Where to initiate subagent delegation in Codex and Claude Code, the configuration options, and a read-only delegation prompt that works directly in both.
  • Where costs are recorded when using an API key, a subscription account, and a gateway key.
  • A fair comparison method for single-agent vs. subagent setups, plus the criteria for deciding when to “enable” and when to “stop.”

Index: Start with the concept table and impact overview to align terminology and find where you fit. The “Objective Facts” section gives the cost calculation, the delegation methods and billing definitions for the two tools in order, which suits readers who want to check numbers and configuration directly. The “Analysis and Judgment” section discusses how to run controlled comparisons, which tasks are suitable for enabling subagents, and when to stop, which suits readers defining team rules.

codex-claude-code-subagents-pay-as-you-go-cost-en-image-0


To Know: 8 Concepts You Need to Understand First About Pay-As-You-Go Sub-Agents

Concept Brief explanation
Main agent The session that receives the goal, breaks tasks down, dispatches them to sub-agents, and finally aggregates and accepts the results
Sub-agent An agent delegated by the main agent that handles a sub-problem in its own independent context, generating separate model and tool calls
Parallel delegation Running sub-tasks that can proceed independently at the same time; parallelism isn’t a requirement for sub-agents — tasks with dependencies can be executed in batches
Wall-clock time The real time the user waits from task start to acceptance; it’s not simply the sum of each sub-agent’s duration
Cache read The portion of input that matches an already cached prefix and gets reused, billed at a lower cache-read rate
Cache write The process of creating a reusable prefix from a piece of input, billed separately on platforms where applicable
Retry A request re-issued after results fall short or partially fail; as long as it’s been charged, it counts toward the total cost
Cost per successful task All actual billed spend for the same set of tasks, divided by the number of tasks that ultimately pass acceptance

Impact at a Glance: Who Feels Pay-As-You-Go Sub-Agents the Most

Audience Main impact Suggested action
Individual developers writing code with an API Key Each extra sub-agent means another set of requests, so the bill changes directly Start small with read-only tasks and no more than two sub-agents
Small-team leads Parallelism may shorten the wait, but the human cost of review and merging doesn’t necessarily drop Evaluate by “cost per successful task + review minutes,” not just speed
Subscription users Sub-agents consume plan usage or extra credits, so they don’t show up directly as a dollar bill Check the plan usage page; don’t mistake the client’s estimate for the actual charge
Users connecting through a gateway Actual charges follow the gateway logs and may be affected by group multipliers Use a dedicated test token to aggregate usage for easier reconciliation

The Facts: Costs, Usage, and Billing Conventions for Codex and Claude Code Subagents

All facts and prices below were verified on November 23, 2026.

1. Breaking down the same usage-based bill: $0.282 for a single agent vs. $0.444 for subagents

The worked example uses the standard-tier list price for gpt-6.2-sol in APIYI’s public model catalog on that day: $2 per million uncached input tokens, $0.10 per million cache-read tokens, and $10 per million output tokens. There are three assumptions: each request’s input stays at or under 272,000 tokens so it falls within the same pricing tier; it’s the same day and the same rates; and there are no extra cache-write fees or standalone tool fees. This uses a single model only to demonstrate the math, and doesn’t represent a Claude Code bill or any user’s actual spending.

Line item Uncached input Cache reads Output Amount (USD)
Single-agent total 80,000 20,000 12,000 0.16 + 0.002 + 0.12 = 0.282
Main agent (including report reads and review) 45,000 10,000 8,000 0.09 + 0.001 + 0.08 = 0.171
Subagent A 30,000 15,000 5,000 0.06 + 0.0015 + 0.05 = 0.1115
Subagent B 35,000 15,000 6,000 0.07 + 0.0015 + 0.06 = 0.1315
One billed retry 10,000 0 1,000 0.02 + 0 + 0.01 = 0.03
Multi-agent total — — — 0.444 (0.162 more than the single agent)

The main-agent row already includes the cost of its final read of the subagent reports and its review pass, so report tokens aren’t double-counted. One more note: these figures don’t assume any relationship between the two approaches in terms of result quality, latency, or actual token volume; they’re only here to show where the extra spend might come from.

codex-claude-code-subagents-pay-as-you-go-cost-en-image-1

The general billing formula is: split every request’s tokens into mutually exclusive buckets according to the platform’s billing convention—uncached input, cache reads, applicable cache writes, and billed output—multiply each by the corresponding rate, then add standalone tool fees. Here’s where those fields come from:

  • The OpenAI Responses API returns usage.input_tokens_details and usage.output_tokens_details. Reasoning tokens are already included in the output tokens, so don’t add them again.
  • Anthropic Messages usage reports input_tokens, cache_creation_input_tokens, cache_read_input_tokens, and output_tokens separately.
  • If requests are routed to different models, groups, or price tiers, verify each one against the actual routing. Public pricing, client-side estimates, and console quotas are three different accounting bases.

The script below demonstrates how to pull values from the Responses usage fields and convert them with the rates above:

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.apiyi.com/v1"  # APIYI OpenAI-compatible endpoint
)

# 2026-11-23 billing rates (USD per million tokens); actual values are subject to catalog and logs
PRICE = {"input": 2.0, "cache_read": 0.10, "output": 10.0}

def request_cost(usage) -> float:
    cached = usage.input_tokens_details.cached_tokens or 0
    uncached = usage.input_tokens - cached           # mutually exclusive categorization to avoid double counting
    output = usage.output_tokens                      # already includes reasoning tokens; don't add them again
    return (uncached * PRICE["input"]
            + cached * PRICE["cache_read"]
            + output * PRICE["output"]) / 1_000_000

resp = client.responses.create(model="gpt-6.2-sol", input="列出本仓库的 CSV 导出入口")
print(f"本次请求约 ${request_cost(resp.usage):.4f}")

2. How to Delegate to Subagents in Codex and Claude Code

Both tools support asking for delegation in natural language, but their entry points and extension models are different.

Aspect Codex Claude Code
Default state The current official guide states that subagents are enabled by default in the current release Supports regular subagents; Agent Teams is an experimental feature and is off by default
Natural-language delegation Just ask directly: “Assign one subagent to each independent question, then collect and summarize the results” Just ask for delegation in natural language
Management entry point CLI uses /subagents to view or switch agent threads /agents manages definitions; project-level definitions go in .claude/agents/
Key configuration agents.enabled, agents.max_concurrent_threads_per_session (formerly agents.max_threads); you can set the default subagent model and reasoning effort Definitions can specify model, tools, and permissions; Teams requires setting CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
Billing attribution Draws on subscription quota or API key / gateway billing Subagent requests count toward the same usage limit or API bill
Third-party access Custom provider points to APIYI at https://api.apiyi.com/v1; verify it against Responses compatibility Connect via the root domain; the client automatically appends the Messages path

A few things to keep straight:

  • OpenAI API’s multi-agent interface and Codex’s local agent are two different product entry points, and they shouldn’t be conflated.
  • In the current Claude Code release, named regular subagents can also message one another. So to tell regular subagents and Teams apart, look at the work structure, not at whether they can communicate.
  • In Agent Teams, the lead and teammates can communicate directly; teammates with the Task tool can also claim work from a shared task list. Once enabled, named subagents in some interactive calls start as teammates. But claude -p and the Agent SDK don’t start Teams teammates, so local interactive use and automated workflows need to be evaluated separately.
  • Anthropic’s “roughly 7x usage” figure comes with a clear precondition: you’re using Agent Teams and teammates are running in plan mode. It shouldn’t be treated as a fixed multiplier for regular subagents, and it definitely shouldn’t be converted directly into per-person dollar costs.

Here’s a read-only delegation prompt you can paste directly into either tool:

Act as the main agent and assign tasks to two read-only subagents:
A should only check whether the entry point, default values, and documentation for this project's CSV export are consistent;
B should only check how existing tests cover empty tables, quotes, and line breaks.
Each should return no more than three findings, with a file location for each, and keep "actual findings" and "inferences" in separate sections; do not commit or modify any files.
Wait until both have returned, then cross-check conflicts, organize reproducible steps, and decide whether another round is needed.

This prompt constrains the intent of the subtasks; it doesn’t amount to permission control. Actually preventing file changes depends on the client’s permission mode. There are three acceptance criteria: every finding has a source, actual findings and inferences are kept separate, and no files in the repository have changed.

codex-claude-code-subagents-pay-as-you-go-cost-en-image-2

3. When connecting through APIYI, where do sub-agent costs get recorded?

First, confirm which path the client is currently on: a subscription account, an official API key, or a gateway key.

  • Subscription: usage quotas and extra credits follow the rules of the corresponding plan. Codex Cloud requires signing in to ChatGPT; API keys can only be used on local entry points that support this authentication method.
  • Claude Code’s /usage: the Session dollar amount shown there is the client’s own estimate at list price; if an organization pricing table is configured, it’s displayed at the rate you set.
  • Gateway: the gateway’s request logs and billing are the source of truth. APIYI’s call logs show the actual quota deductions and account for group multipliers; the equivalent discount from top-up bonuses has to be calculated separately.

For connecting Codex, you can refer to the custom provider configuration below (field names depend on the Codex version docs you’re using):

model_provider = "apiyi"
model = "gpt-6.2-sol"

[model_providers.apiyi]
name = "APIYI"
base_url = "https://api.apiyi.com/v1"
env_key = "APIYI_API_KEY"
wire_api = "responses"   # Newer Codex checks against Responses compatibility; it no longer falls back to the old Chat mode

[agents]
enabled = true
max_concurrent_threads_per_session = 2   # Limit to two sub-agents during the trial phase

Claude Code, meanwhile, connects through environment variables: set ANTHROPIC_BASE_URL to the APIYI root domain, and put your key in ANTHROPIC_AUTH_TOKEN. As of November 23, the catalog lists gpt-6.2-sol (tagged responses/chat) and claude-opus-5-5 (tagged messages/chat). But the catalog only proves the models are listed and which protocols they support. Which model the sub-agents actually use, the mapping relationships, the fallback strategy, and how billing works — all of that needs to be verified in your own environment.

🚀 Quick start: if you’d like to run the comparison experiment above first, you can register at APIYI (apiyi.com) to get free test credits for new users. It’s worth creating a separate test token for this experiment so that all requests from the main agent and sub-agents end up in one log, which makes checking them a lot easier.

Analysis: Are Codex and Claude Code Subagents Worth Enabling Under Pay-as-You-Go?

The following is an interpretation based on the facts above. Anything about trends is a judgment call, not a settled conclusion.

How to Make a Fair Single-Agent vs. Subagent Comparison

The $0.162 difference by itself doesn’t tell you much. What matters is what it buys. A fair comparison requires changing only one variable: whether delegation is enabled. Keep the same code snapshot, the same task prompt, the same file access scope, and the same model tier, and start one clean session for each group. The first group explicitly asks for no delegation; the second group enables only two read-only subagents.

If you want to compare different clients, first compare “on” vs. “off” within each tool, then look across the results. Otherwise, model differences and protocol differences get mistakenly attributed to subagents. For each group, record at least the following columns:

Field How to record Notes
Wall-clock time From start to acceptance/end Don’t add the two subagents’ times together
Request count and token categories Record uncached input, cache read, cache write, and output separately Classify them mutually exclusively; don’t double-count reasoning tokens
Actual charge Use gateway logs or billing records as the source of truth Note the group multiplier and top-up discount
Number of accepted conclusions Items that meet the “sourced, sectioned, no changes” criteria Count actual findings and speculation separately
Extra retries Count and amount Include failures that were still charged
Minutes of manual review Keep this as its own column Don’t mix it into wall-clock time
Model and routing The models used by the main agent and each subagent Also spell out downgrades and authorization differences

Clients don’t always tag each request with the subtask it belongs to. A safer approach is to use a dedicated test token or an exclusive time window to aggregate usage for the whole group, and list separately any items you truly can’t attribute. For batch statistics, cost per successful task = total actual spend (including failures and retries) ÷ number of passes. For example, if 5 of 8 tasks pass, the denominator is 5. If the number of passes is zero, report only total cost and pass rate; don’t force a unit cost.

Which tasks justify spinning up subagents—and when to stop

Our view: tasks worth spinning up subagents for have two things in common: the branches are largely independent, and each branch can hand over reviewable evidence. For example, one branch checks the API entry point while another checks existing regression tests; running them at the same time can shorten the wait. By contrast, the following cases are better handled with a single agent first:

  • Repeatedly reading the same big chunk of context: every subagent has to read it again, and caching may not fully offset that cost.
  • The same file has to be edited: merge conflicts often cost more than the time parallelism saves.
  • A shared assumption has to be settled first: resolve dependencies serially first, then decide whether to split the work.
  • Very short, small changes: startup and aggregation overhead can outweigh the gain, so run a single agent as a baseline first.

If there are multiple writing tasks, agree in advance on who owns each file, or have each use its own worktree, and accept the result with the same test suite at the end. You can also manually open multiple terminals or Worktrees to run in parallel, but then you’ll have to arrange who splits the work and how to merge—the main agent won’t do that for you.

During a pilot, you can set four guardrails: at most two subagents; each subagent’s scope must not overlap; only hand over conclusions that need review; explicitly state when to stop proactively. If you need another round, first check whether the number of passed conclusions from the previous round increased; if it didn’t, stop.

💡 Decision tip: You can decide with one simple rule. If the subagent group’s evidence quality meets the same acceptance standard as the single agent, and the waiting time saved is worth the extra money, expand its use on similar tasks; otherwise, go back to a single agent. Compare the two groups through the same billing channel. On APIYI apiyi.com, just run both groups with the same token, and the logs can be reconciled directly.

codex-claude-code-subagents-pay-as-you-go-cost-en-image-3

Subscription Credits and Flat-Rate Pricing Aren’t the Same Bill

There’s another distinction that’s easy to miss: under a subscription plan, subagents draw on the usage credits bundled into your plan. No dollars come out of your pocket until those credits run out — but you hit the ceiling sooner. With pay-as-you-go, every request is billed in real time. So the same statement — “subagents cost more” — means “credits run out faster” to a subscriber, and “a bigger bill” to an API key user. The trade-offs aren’t the same, so don’t draw conclusions from a single spreadsheet.

We expect gaps like $0.162 to keep shifting as both tools continue to tweak default concurrency, subagent model settings, and caching strategies. But the three underlying cost drivers — repeated context reads, report verification, and retries — aren’t going anywhere. Rather than memorizing some multiplier, it’s better to lock in the tracking table above and rerun the comparison each time you upgrade the client. And if you want to run this exercise on both the GPT and Claude lines with a single key, you can connect through APIYI (apiyi.com) for unified access — pay-as-you-go, with logs all in one place, which makes long-term reconciliation much easier.


References

  1. OpenAI Codex Subagents: subagent support scope, CLI commands, and concurrency configuration
    • Link: learn.chatgpt.com/docs/agent-configuration/subagents
  2. OpenAI Codex Gateway compatibility: Responses compatibility requirements
    • Link: learn.chatgpt.com/docs/enterprise/gateway-compatibility
  3. OpenAI Responses API usage: description of the usage field
    • Link: developers.openai.com/api/reference/resources/responses/methods/create
  4. Anthropic Claude Code custom subagents: defining regular subagents and their usage
    • Link: code.claude.com/docs/en/sub-agents
  5. Anthropic Agent Teams: experimental toggle and limitations
    • Link: code.claude.com/docs/en/agent-teams
  6. Anthropic Manage costs effectively: the assumptions behind the ~7x usage figure and client-side estimates
    • Link: code.claude.com/docs/en/costs
  7. APIYI Documentation Center: full model catalog, invocation log billing, Codex and Claude Code integration
    • Link: docs.apiyi.com

Author: APIYI Technical Team
Technical discussion: Questions about the subagent cost comparison? Feel free to reach out through the APIYI homepage.

Related Articles

Similar Posts