One Big API Call or Four Small Ones From Your Terminal
One Big API Call or Four Small Ones From Your Terminal
Splitting an AI task into smaller calls sounds cheaper until every request repeats your instructions. One large call sounds efficient until it carries files the model never needed. Let’s measure both approaches on four source files, using the same model and a comparable output budget.
I use Fluxo here because one key and one base URL, https://api.fluxorelay.com, cover Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok and more. The setup also works with Claude Code, Codex, Gemini CLI and any OpenAI SDK. This walkthrough uses curl and jq so the request bodies stay visible.
Prepare Four Files and Select One Model
Run these commands in Bash from your repository. You need Python 3, curl and jq. Choose four real source files, preferably related modules. Use files you are comfortable sending to an API.
export FLUXO_BASE_URL=https://api.fluxorelay.com; read -rsp 'Fluxo API key: ' FLUXO_API_KEY; echo; export FLUXO_API_KEY
curl --fail-with-body -sS "$FLUXO_BASE_URL/v1/models" -H "Authorization: Bearer $FLUXO_API_KEY" | jq .
For example, choose Claude Sonnet 5.5. Copy its exact API identifier from the response; a display name is not necessarily a request identifier.
read -rp 'Exact model ID: ' MODEL; export MODEL; mkdir -p .fluxo-cost
files=(src/auth.ts src/users.ts src/billing.ts src/config.ts); for f in "${files[@]}"; do test -f "$f" || { printf 'Missing file: %s\n' "$f"; exit 1; }; done
Replace those paths before running the command. Keep this file list unchanged throughout the comparison.
Build One Combined Request and Four Separate Requests
Ask for an independent review of each file. That makes splitting legitimate: neither strategy requires cross-file reasoning. Both receive the same review instructions and source content.
export REVIEW='Review each supplied file independently. Report concrete bugs with file names and brief fixes. Do not infer behavior from other files. Keep each file review under 120 words.'
for i in "${!files[@]}"; do f=${files[$i]}; { printf '\nFILE: %s\n' "$f"; cat "$f"; } > ".fluxo-cost/input-$i.txt"; done; cat .fluxo-cost/input-*.txt > .fluxo-cost/combined.txt
jq -n --arg model "$MODEL" --arg instruction "$REVIEW" --rawfile source .fluxo-cost/combined.txt '{model:$model,messages:[{role:"user",content:($instruction+"\n"+$source)}],max_tokens:1200}' > .fluxo-cost/big.json
for i in "${!files[@]}"; do jq -n --arg model "$MODEL" --arg instruction "$REVIEW" --rawfile source ".fluxo-cost/input-$i.txt" '{model:$model,messages:[{role:"user",content:($instruction+"\n"+$source)}],max_tokens:300}' > ".fluxo-cost/small-$i.json"; done
The combined request allows 1,200 output tokens; four smaller requests allow 300 each. These are ceilings, not guaranteed consumption. Check for truncated answers before comparing usefulness.
Run Both Strategies and Save Actual Usage
The following command makes five billable requests, sequentially. Saving complete responses preserves usage details and lets you inspect review quality afterward.
for name in big small-0 small-1 small-2 small-3; do curl --fail-with-body -sS "$FLUXO_BASE_URL/v1/chat/completions" -H "Authorization: Bearer $FLUXO_API_KEY" -H 'Content-Type: application/json' --data-binary @".fluxo-cost/$name.json" -o ".fluxo-cost/$name.response.json" || break; done
for name in big small-0 small-1 small-2 small-3; do printf '\n%s\n' "$name"; jq '{usage,finish_reason:.choices[0].finish_reason,review:.choices[0].message.content,error}' ".fluxo-cost/$name.response.json"; done
Inspect the full usage objects. Cache fields vary across models and response formats. Missing cache details do not prove that every input token was billed as fresh input.
Price Fresh Input, Cache Activity and Output Separately
Fluxo bills real tokens, including cache reads and writes, with no monthly fee. Use the current rates for your selected model and reconcile usage with billing records. Where categories are disjoint, calculate: cost = (fresh input × input rate + cache reads × read rate + cache writes × write rate + output × output rate) / 1,000,000.
For arithmetic only, assume $2 per million fresh input tokens and $8 per million output tokens, without caching. These are illustrative rates, not Fluxo prices.
- One combined call using 12,200 input and 800 output tokens costs $0.0308.
- Four calls totaling 12,800 input and 800 output tokens cost $0.0320.
The extra $0.0012 comes from repeated instructions. Smaller calls can still win when routing skips irrelevant files or retries repeat only one failed review. Cache reads can change the result again. Repeat only when the additional spend answers a specific uncertainty.
Create a Fluxo account if you want to run this comparison on your own repository. If you need help interpreting charges, leave a note on the contact page after signing in. Users also earn a referral share when people they invite pay.