CLI

Validate, simulate, and publish experiment configs.

Basic usage

pairit config lint your_experiment.yaml # Validate YAML and run lints
pairit config compile your_experiment.yaml # Parse and compile to canonical JSON

Publish / manage configs (stored in MongoDB via the Manager Server API)

pairit config upload your_experiment.yaml
pairit config upload your_experiment.yaml --name my-exp --openai-api-key-env OPENAI_API_KEY
pairit config upload your_experiment.yaml --name my-exp --anthropic-api-key-env ANTHROPIC_API_KEY
pairit config list
pairit config history <configId>
pairit config history <configId> --revision 1 --out rev1.json
pairit config get <configId> --out compiled.json # TODO
pairit config delete <configId>

Each config has a name you choose and a config ID that Pairit assigns. The ID is the participant link.

  • The name comes from --name, else a top-level name: in the YAML, else the file name without .yaml.
  • Names are unique among your own configs only. Two researchers can both have trust-study.
  • The first upload of a name creates the config and prints its link, e.g. https://pairit.pairium.ai/trust-study-k3f9x2m8q1. The random part keeps links unguessable.
  • Uploading again under the same name keeps the ID and link. If the compiled config changed, it becomes a new revision (1, 2, 3…). Changing only settings like allowRetake keeps the revision.
  • Every session records the revision it ran, and the sessions export includes it as configRevision.
  • A participant who returns mid-session keeps the revision they started on.
  • If participants already ran the previous revision, upload warns you. For a real new study, rather than a fix, upload under a new name to get a new link and separate data.
  • pairit config history <configId> lists revisions with their session counts. --revision N prints or saves that revision's compiled config.
  • --config-id updates a config by ID. Use it for configs created before names existed. Creating a new config with --config-id is admin-only.

Per-experiment LLM credentials

If a config includes AI agents, upload the required provider key with that config.

  • The OpenAI key is used for OpenAI models like gpt-6-luna, the Anthropic key for Anthropic models like claude-sonnet-*
  • Pass each key one of three ways:

    OpenAI Anthropic Reads the key from
    --openai-api-key-env VAR --anthropic-api-key-env VAR the environment variable VAR
    --openai-api-key-stdin --anthropic-api-key-stdin stdin (one key per upload)
    --openai-api-key sk-... --anthropic-api-key sk-ant-... the command line

    Prefer the first two: a key on the command line shows up in ps and your shell history. For example:

    export OPENAI_API_KEY=sk-...   # or keep it in a .env your shell loads
    pairit config upload exp.yaml --openai-api-key-env OPENAI_API_KEY
    pbpaste | pairit config upload exp.yaml --openai-api-key-stdin
    
  • --clear-openai-api-key and --clear-anthropic-api-key remove a stored key

  • Keys are encrypted at rest and stored per configId
  • Re-uploading the same config without a new key keeps the existing key for that config. Setting one provider's key keeps the other's.
  • Agent runs do not fall back to a shared platform API key
  • If the required provider key is missing, the agent run fails

Custom LLM endpoints (gateways and OpenAI/Anthropic-compatible APIs)

To route a study's agents through a university gateway, proxy, or third-party OpenAI/Anthropic-compatible provider, pass a per-config base URL on config upload:

OpenAI-compatible Anthropic-compatible Purpose
--openai-base-url <url> --anthropic-base-url <url> Custom HTTPS API prefix (include /v1 if required by the gateway)
--openai-api-mode <chat\|responses> --anthropic-auth-mode <x-api-key\|bearer> Wire protocol (chat default with custom OpenAI URL) / auth header (x-api-key default)
--clear-openai-base-url --clear-anthropic-base-url Remove the custom endpoint and revert to the vendor default

Examples:

# University Anthropic-compatible gateway (e.g. with Bearer token auth)
pairit config upload exp.yaml \
  --anthropic-api-key-env GATEWAY_KEY \
  --anthropic-base-url https://gateway.example.edu/anthropic/v1 \
  --anthropic-auth-mode bearer

# OpenAI-compatible gateway (OpenRouter, LiteLLM, vLLM, university proxy)
pairit config upload exp.yaml \
  --openai-api-key-env GATEWAY_KEY \
  --openai-base-url https://openrouter.ai/api/v1

Notes: - Pairit appends /messages to Anthropic base URLs and /chat/completions (or /responses) to OpenAI base URLs. Include /v1 in the base URL if your gateway expects /v1/messages or /v1/chat/completions. - Custom OpenAI-compatible endpoints default to Chat Completions (chat); pass --openai-api-mode responses if your gateway supports the OpenAI Responses API. Both custom OpenAI and custom Anthropic endpoints fall back to standard JSON-schema workspace tools (read_workspace, edit_workspace, write_workspace) for broad gateway compatibility. - Base URLs must use https:// and resolve to public internet addresses (private networks, single-label internal hostnames, loopback, and cloud metadata endpoints are blocked; http://localhost is allowed only in local development). - For non-standard gateway model IDs (e.g. us.anthropic.claude-sonnet-4 on an Anthropic gateway, or claude-sonnet-4 routed through an OpenAI-compatible proxy), set provider: anthropic or provider: openai on the agent in your YAML config. - pairit config list shows any custom endpoints and active modes stored on your configs.

Coming soon

pairit simulate --seed 42 your_experiment.yaml

Compilation output

  • Normalizes helper shorthands (text, buttons, componentType) into canonical component entries.
  • Expands survey questions so each answer has a declared type (and required choices for multiple_choice).

Compiled JSON can be written with --out <file> to inspect what the runtime will consume.

Validation & lints

pairit config lint runs structural checks before you publish: - Validate props against JSON Schemas declared in components. - Enforce unique ids across pages, matchmaking, and agents. - Require unique button ids per page and ensure every go_to/branch target exists. - Verify assign statements only touch session_state.* and that RHS types match the schema. - Reject unknown action.type values and undeclared component events.

HTML embeds

Reference a local .html file from an html component (src: slider.html). No extra command.

pairit config lint experiment.yaml
# ✓ experiment.yaml passed lint checks
#   html slider_task ← slider.html (4.2 KB)

pairit config upload experiment.yaml --name my-exp
# ✓ Attached slider.html (4.2 KB)
# ✓ Created my-exp (my-exp-k3f9x2m8q1), revision 1

Lint checks that each src exists, is a local .html file, is not a URL, and is under 1 MB. Upload attaches the file to the published config and includes it in the checksum. Compile does not attach file bytes. See HTML.

Media

pairit media upload hero.png
pairit media list --prefix onboarding/
pairit media delete onboarding/hero.png

Each upload goes in your own folder and returns a public URL. Use that URL in your config. Anyone with the URL can read the file, so do not upload sensitive files. media list shows only your files, and media delete deletes only your files. Files uploaded before per-researcher folders keep their URLs; ask an admin to delete one.

Data Export

Export experiment data for analysis.

pairit data export <configId>                    # Export as CSV (default)
pairit data export <configId> --format json      # Export as JSON
pairit data export <configId> --format jsonl     # Export as JSONL
pairit data export <configId> --out ./exports    # Custom output directory

Creates seven files per export:

File Contents
{configId}-sessions.csv Session records: sessionId, configId, status, session_state., prolific., provenance, timestamps
{configId}-events.csv Component events: sessionId, type, pageId, componentType, data.*, timestamp
{configId}-chat-messages.csv Chat history: messageId, groupId, senderId, senderType, content, createdAt
{configId}-groups.csv Group records: groupId, members, createdAt
{configId}-survey-responses.csv Survey response data: sessionId, itemId, answer, pageId, timestamp
{configId}-workspace-documents.csv Workspace documents: groupId, content, fields, updatedAt
{configId}-workspace-updates.csv Every edit to a workspace document, in order

Formats: CSV flattens nested objects with dot notation (session_state.treatment). JSON/JSONL preserve full nesting.

In CSV, a text value that starts with =, +, -, @, a tab, or a carriage return gets a leading ', so Excel and Google Sheets show participant answers as text instead of running them as formulas. Numbers are unchanged. JSON and JSONL keep the original text.

Provenance columns in the sessions file show what each participant ran:

Column Meaning
configRevision Config revision the session started on
configChecksum Checksum of that compiled config
labVersion Lab code version (git commit) that served the session
labRevision Cloud Run revision that served the session

Sessions created before provenance was recorded have empty values. Group or filter by these columns to separate participants across a mid-study config edit or lab deploy.

Audit a test run

pairit data audit checks a test run before you launch a real study. See Test a study before launch.

pairit data audit <configId> --pid-prefix bot_qa_ --since 2026-11-23T10:00:00Z
pairit data audit <configId> --config study.yaml --require-state treatment,choice
Option Effect
--pid-prefix <prefix> Only sessions whose PROLIFIC_PID starts with this
--since <time> Only sessions created at or after this ISO time
--config <path> Also check that required survey answers were saved
--require-state <keys> Comma-separated session_state keys (dotted paths allowed) every finished session must have

It reports an error for each session that did not reach an end page (with the page it stopped on), each required survey answer that was not saved, and each missing --require-state key. It warns about groups where only some members finished, and about sessions that span config revisions. It exits with status 1 if there are errors.

Delete study data

Permanently delete all participant data for a config (sessions, events, chat messages, groups, workspace documents, workspace updates, and timers) after exporting it—for example, to satisfy IRB data-retention or de-identification requirements:

pairit data delete <configId>            # Interactive: preview, optional local JSON backup, confirm
pairit data delete <configId> --force    # Skip prompts and delete immediately (for scripts)
  • Before deleting, the CLI displays per-collection counts and recent session activity (warning if any sessions were active in the last 15 minutes).
  • It offers to save a local lossless JSON backup first (Y/n, default Y); if you skip the backup, it asks you to confirm you already exported the data (y/N, default N).
  • Finally, it requires typing <configId> verbatim (pressing Enter or Ctrl-D aborts with a non-zero exit code).
  • Only the owner of <configId> can delete its data.
  • The config itself and its revision history are kept so you can still inspect them or take down the link separately with pairit config delete <configId>.
  • Always run pairit data delete <configId> before pairit config delete <configId>: deleting the config removes only the config definition and leaves participant records behind, after which data export and data delete can no longer verify ownership.

See IRB and Data Privacy for data storage, encryption, and protocol boilerplate.

Database layout (MongoDB)

Published configs live in the configs collection (keyed by configId) with name, revision, metadata and a checksum. Each revision's compiled config is kept in config_revisions (keyed by configId + revision). Runs create:

  • sessions — participant sessions (id, configId, config, currentPageId, session_state, prolific?, endedAt?, createdAt, updatedAt, userId?, configRevision, configChecksum, labVersion, labRevision)
  • events — component and page events (sessionId, configId, pageId, componentType, componentId, type, timestamp, data, createdAt)
  • chat_messages — group and agent chat messages (configId, groupId, senderId, senderType, content, createdAt)
  • groups — multi-participant matchmaking groups (groupId, configId, memberSessionIds, matchedAt)
  • workspace_documents and workspace_updates — collaborative workspace snapshots and edit history (configId, groupId)
  • timers — server-backed countdown deadlines (configId, scopeKey, timerKey, startedAt, expiresAt)

Use pairit config get <configId> to download a compiled config snapshot for auditing or debugging (where supported). Media objects live in the configured storage backend (local filesystem for dev, Google Cloud Storage in prod); pairit media * commands proxy uploads and deletes via the manager service so the CLI never requires direct GCP credentials. Public media uploads should use the stable asset URL returned by the manager service, not a temporary signed read URL.