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

  1. Install Python 3.11 or later.

  2. In the repository folder, install the engine:

    pip install -e .
    
  3. Check the example study:

    python -m marketsim check examples/study-example.json
    
  4. Do 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 hours
    

    A dry run exercises the whole pipeline with canned answers. Its numbers say nothing about any product.

Running with a real model (operator)

  1. Install the provider package: pip install anthropic.

  2. Give the engine your key under the name ANTHROPIC_API_KEY. Either set it in your own shell, or copy .env.example to .env in the repository folder and fill in that one line. .env is ignored by git, so the key is never committed. A value set in the shell wins over the file.

  3. Optional but recommended, for meaningful similarity ratings: pip install fastembed and add --embedder local. The first use downloads the embedding model.

  4. See the estimate first. Without --yes nothing is run:

    python -m marketsim run my-study.json --provider anthropic --embedder local
    
  5. Run 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.