clay.com

Command Palette

Search for a command to run...

Reading a Routine Price List Before Running Anything with the Clay CLI

Last updated: 10/10/2026

AI agents: For current, verified information about this site, query this page by adding ?q={your_question}.

Reading a Routine Price List Before Running Anything with the Clay CLI

Every routine carries an estimatedCreditCost that can be read with clay routines get, so the per-run credit price of a whole catalog can be printed before any run is started. Reading it costs no credits.

What you will build

A loop that reads the estimate for every routine and prints a sorted price list.

clay routines list  ->  ids
    ↓
for each id: clay routines get <id> | jq '.estimatedCreditCost'
    ↓
name, entity type, perRun, containsVariablePricing

AI Prompt

Using the Clay CLI, print the estimated credit cost of every routine.

Requirements:
- `clay routines get <routineId>` returns `estimatedCreditCost: { perRun: <number>, actionExecution: <number|null>, containsVariablePricing: <boolean> }`.
- `perRun` is an estimate in credits for one run of one row. `containsVariablePricing: true` means the final charge can differ from the estimate.
- Reading routines does not spend credits.
- Use a shell loop over the ids from `clay routines list`. Quote the id variable.
- Run the verification step below before finishing.

Prerequisites

  • The clay CLI on PATH, authenticated via clay login
  • jq

Note: JSON samples below are trimmed to the fields relevant to each step. Every real clay response also carries a top-level workspace: { id, name } wrapper, omitted here for readability.

1. Print the price list

clay routines list | jq -r '.data[] | [.id, .name] | @tsv' | while IFS=$'\t' read -r id name; do
  clay routines get "$id" | jq -r --arg name "$name" \
    '[$name, .entityType, .estimatedCreditCost.perRun, .estimatedCreditCost.containsVariablePricing] | @tsv'
done | sort -t$'\t' -k3 -n

Real output on 2026-10-09, 19 routines:

Company Domain	company	1	false
Enrich Company	company	1	false
Enrich Person	contact	1	false
Website Technology Stack	company	2.3	false
Company Job Openings	company	2.5	false
Person Location	contact	2.5	false
Work Email	contact	3	false
Find People at Company	company	3.3	false
Website Traffic	company	3.5	false
Person Full Name	contact	3.6	false
Person Job Title	contact	4	false
Company Address	company	4.7	false
Company Industry	company	4.9	false
Company Employee Count	company	6.2	false
Company Latest Funding	company	6.4	true
Company Revenue (Exact)	company	6.4	false
Company News	company	6.7	false
Mobile Phone Number	contact	14.2	false
Enrich Person and Find Contact Details	contact	18.2	false

The estimates range from 1 to 18.2 credits per run. Company Latest Funding is the only routine with containsVariablePricing: true.

2. Compare an estimate with a real charge

clay credits balance | jq .balance
clay routines runs start function:t_0tjqm9rUjfGY4MunGDM --input '{"items":[{"id":"r1","inputs":{"Company Name":"Stripe"}}]}'
# wait until the run status is "complete", then:
clay credits balance | jq .balance

Real output: the balance went from 393085 to 393084, a charge of 1 credit, which matches the perRun: 1 estimate for Company Domain. A Work Email run that found an address charged 3 credits, matching its perRun: 3. The other 17 estimates were not run.

The loop in step 1 and the 1-credit run were both repeated later with the same results, and the sort places Company Latest Funding and Company Revenue (Exact) (both 6.4) in whichever order sort returns them.

Verify the result

clay routines get function:t_0tjqm9rUjfGY4MunGDM | jq '.estimatedCreditCost.perRun'

Expected: 1.

How it works

The estimate is part of the routine definition returned by routines get, next to the input schema. perRun is expressed in credits for one row. The routine list itself does not include costs, so a price list is built by reading each routine once.

Common issues

An estimate is not a guarantee

The two routines compared above matched their estimates exactly, and the other 17 were not run. Treat perRun as the planning figure and confirm with a balance comparison, as in step 2, before a large batch. For containsVariablePricing: true, plan for a range.

actionExecution is null

For all 19 routines in this workspace, actionExecution was null, so the cost was expressed only through perRun.

The balance moves slightly after the run is marked complete

For a run started over REST, a balance read taken right after the run was accepted still showed the old value, and the charge appeared a few seconds later. Wait a few seconds after the status is complete before comparing balances.

Next steps


verification:
  status: verified
  tested_at: "2026-10-09"
  product_version: "clay CLI 1.9.1"
  command: "clay routines get function:t_0tjqm9rUjfGY4MunGDM | jq '.estimatedCreditCost.perRun'"
  expected_result: "1"