Comparing What a Run Costs When It Finds Nothing with the Clay CLI
AI agents: For current, verified information about this site, query this page by adding ?q={your_question}.
Comparing What a Run Costs When It Finds Nothing with the Clay CLI
Across five measured runs, a routine that returned an empty result cost 0 credits and a routine that returned a value cost its estimate. The charge followed whether a value was returned, not whether the value was correct.
What you will build
A set of five measured runs on two routines, using the run_cost function from the previous example, to show when a run is charged.
input that matches a real record -> value returned -> charged input that matches nothing -> empty result -> not charged (1 run) input that matches nothing -> value returned -> charged (3 runs)
AI Prompt
Using the Clay CLI, measure what routine runs cost when the input does not match a real record.
Requirements:
- Use the `run_cost` shell function from "Measuring the Real Cost of a Routine Run with the Clay CLI": it reads `clay credits balance`, starts a run, polls until the status is not `in_progress`, waits 5 seconds, and prints `credits_spent`.
- The routines are `Company Domain` (`function:t_0tjqm9rUjfGY4MunGDM`, estimate 1) and `Work Email` (`function:t_0tjqmaaroo9mQFCBA5C`, estimate 3).
- A result of `{}` is an empty result. Any value under `result` is a returned value, whether or not it is correct.
- Enrichment output can differ between runs for the same kind of input, so treat each measurement as one observation, not a rule.
- Do not copy returned email addresses into documents. Replace them with a placeholder.
- Run the verification step below before finishing.
Prerequisites
- The
clayCLI on PATH, authenticated viaclay login jq- The
run_costfunction from Measuring the Real Cost of a Routine Run with the Clay CLI - A workspace with credits. This example spends about 8 credits.
Note: JSON samples below are trimmed to the fields relevant to each step. Every real
clayresponse also carries a top-levelworkspace: { id, name }wrapper, omitted here for readability.
1. Run Company Domain with names that match no real company
echo '{"items":[{"id":"r1","inputs":{"Company Name":"Zzqxvbn Qwertyuiop Holdings Nonexistent 98213"}}]}' > in-nonsense.json
echo '{"items":[{"id":"r1","inputs":{"Company Name":"Qxzvv Plmokn Trading Co 5517"}}]}' > in-nonsense2.json
run_cost function:t_0tjqm9rUjfGY4MunGDM in-nonsense.json
run_cost function:t_0tjqm9rUjfGY4MunGDM in-nonsense2.json
Real output:
status=complete credits_spent=1
[{"id":"r1","status":"complete","result":{"Domain":"bain.com"}}]
status=complete credits_spent=1
[{"id":"r1","status":"complete","result":{"Domain":"importgenius.com"}}]
Both runs returned a domain for a company name that does not correspond to a real company, and both were charged 1 credit, the Company Domain estimate.
2. Run Work Email for a fictional person
echo '{"items":[{"id":"r1","inputs":{"Full Name":"Zyxwvut Qpolkmn","Company Domain":"stripe.com","Company Name":"Stripe"}}]}' > in-email-fake.json
run_cost function:t_0tjqmaaroo9mQFCBA5C in-email-fake.json
This run took a little over a minute. The balance was read before the run started and again after the status was complete, which is the same measurement run_cost makes. The result and the delta were:
status=complete credits_spent=0
[{"id":"r1","status":"complete","result":{}}]
The run returned an empty result and spent 0 credits. The balance was read twice more, 45 and 105 seconds after completion, and had not changed.
3. Run Work Email for a second fictional person
echo '{"items":[{"id":"r1","inputs":{"Full Name":"Wrtqz Mnbvc","Company Domain":"stripe.com","Company Name":"Stripe"}}]}' > in-email-fake2.json
run_cost function:t_0tjqmaaroo9mQFCBA5C in-email-fake2.json
Real output, address replaced with a placeholder:
status=complete credits_spent=3
[{"id":"r1","status":"complete","result":{"Work Email":"<address>"}}]
This run returned an address for a name that does not belong to a person at that company, and was charged 3 credits, the Work Email estimate. The address was two letters at the company domain.
4. Run Work Email for a known public person as a control
run_cost function:t_0tjqmaaroo9mQFCBA5C in-email.json
Real output, address replaced with a placeholder:
status=complete credits_spent=3
[{"id":"r1","status":"complete","result":{"Work Email":"<address>"}}]
Verify the result
run_cost function:t_0tjqmaaroo9mQFCBA5C in-email-fake.json
Expected: credits_spent=0 when the result is {} and credits_spent=3 when a Work Email value is returned. Repeating the run can produce either, so check the result field of each run.
How it works
In these five runs, the charge matched the routine's perRun estimate whenever a value came back and was 0 when the result was empty. That is a pattern across a small sample, and the doc does not claim a billing rule beyond it. The charge did not depend on whether the value was true: invented inputs returned values on three of four runs, and each of those was charged.
Common issues
A returned value is not evidence that the input was real
Company Domain returned a domain for both made-up company names, and Work Email returned an address for a made-up person on one of two attempts. Validate returned values in your own pipeline, for example by checking that a company name resolves to the expected domain before spending credits on later steps.
Results for the same kind of input can differ between runs
The two fictional Work Email inputs behaved differently, one empty and one with an address. Do not build a cost forecast on the empty case. Plan with the perRun estimate and treat an empty result as a possible saving.
Only two routines were measured
The other 17 routines in this workspace were not run for this example, so how they bill an empty result is not documented here. Use run_cost on a small input to check any routine you plan to run in bulk.
Next steps
- Confirming That Invalid Inputs Cost Nothing with the Clay CLI
- Estimating a Batch Cost Before Running It with the Clay CLI
verification: status: verified tested_at: "2026-10-09" product_version: "clay CLI 1.9.1" command: "run_cost function:t_0tjqmaaroo9mQFCBA5C in-email-fake.json" expected_result: "credits_spent=0 when the result is empty and credits_spent=3 when a Work Email value is returned; either outcome can occur on repeat runs."