Command line (operator)
The survey engine runs from the command line. This is how studies are run until the web app exists, and how the operator checks cost before anything is spent.
Getting started
Install Python 3.11 or later.
In the repository folder, install the engine:
pip install -e .Check the example study:
python -m marketsim check examples/study-example.jsonDo a dry run. It calls no model and costs nothing:
python -m marketsim run examples/study-example.json --out result.json # add --batch to send it through the provider's batch service: half the price, results in hoursA dry run exercises the whole pipeline with canned answers. Its numbers say nothing about any product.
Running with a real model (operator)
Install the provider package:
pip install anthropic.Give the engine your key under the name
ANTHROPIC_API_KEY. Either set it in your own shell, or copy.env.exampleto.envin the repository folder and fill in that one line..envis ignored by git, so the key is never committed. A value set in the shell wins over the file.Optional but recommended, for meaningful similarity ratings:
pip install fastembedand add--embedder local. The first use downloads the embedding model.See the estimate first. Without
--yesnothing is run:python -m marketsim run my-study.json --provider anthropic --embedder localRun it:
python -m marketsim run my-study.json --provider anthropic --embedder local --yes
The Claude provider has not yet been run against the live service. Make the first real run the
small one provided, examples/study-smoke.json (20 respondents, one interview each), and compare
the reported cost with the estimate.
Commands
| Command | What it does | Exit code |
|---|---|---|
check STUDY |
Validates the file, lists the assumed shares, runs the stimulus check | 1 if the text is flagged |
estimate STUDY [--plan free|standard] [--batch] |
Estimated model cost and the margin rule | 1 if over the limit |
report RESULT [--html FILE] [--pdf FILE] |
Builds the web page and PDF report from a result file; see Read your report | 0 |
run STUDY [--out FILE] [--provider fake|anthropic] [--embedder hash|local] [--model ID] [--workers N] [--yes] |
Runs the study and writes the result | 1 if a paid run was not confirmed |
The result file
result.json holds the notice that the survey is simulated, the sample card (panel, models,
seed, assumptions, missing respondents), the confidence grade with its reasons, scores per
question by version and by segment for both rating methods, token use and cost, and every
respondent's attributes, answers and ratings.
Cost
estimate uses list prices stored in marketsim/cost.py with the date they were read
(PRICES_AS_OF) and estimated token counts. A paid plan must not run a study whose estimated cost
is over 30 percent of its price.