Research API
Ask a defined audience a structured question and receive simulated answer shares in JSON.
Our methodology reports the historical benchmark, its full distribution of errors and its scope.
Overview
API access is configured with your client team. The synchronous endpoint returns one question at a time. Every respondent is simulated; preserve that provenance wherever you show a result.
This endpoint can return 503 while interactive inference is paused. Queued panel-study delivery is a separate workflow.
Discuss API accessKeys and authentication
Keep API keys on your server. Send Authorization: Bearer sk-lew-… and Content-Type: application/json. Workspace access and key issuance are set up with the team. Ask us to revoke a key if it is exposed.
Account-owned keys share respondent usage and request limits. Creating another key does not create another account allowance.
Quickstart
Set LEWSEARCH_API_KEY in your server environment. These examples use the standard HTTP client in each language.
curl https://lewsearch.com/api/v1/cohort/query \
-H "Authorization: Bearer $LEWSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{"question":"Would you switch brands at $4.99?","options":["Definitely","Probably","Probably not","No"],"audience":{"market":"national_us","n":500}}'Endpoint reference
POST https://lewsearch.com/api/v1/cohort/query
The body is JSON. The endpoint is synchronous, with a server execution budget of 60 seconds. There is no asynchronous job id or polling endpoint in this v1 response.
Request fields
| Field | Type | Meaning |
|---|---|---|
question | string · required | Nonempty research question. Input moderation and question-quality validation also apply. |
options | string[] · optional | Two to six nonempty answer options. Blank entries are removed. Omit for the freeform mode, which currently uses an internal Yes/No elicitation and has no numeric validation claim. |
audience.market | string · required | A registered market id, such as national_us or texas. Missing and unknown ids return 400; no fallback market is selected. |
audience.n | number · optional | Default 200. Clamped between 20 and the API tier’s maximum. Send a finite whole number. |
request_id | string · optional | Echoed in the response and recorded with usage. Reuse does not cache inference or guarantee protection from repeated quota reservations. |
Response fields
| Field | Type | Meaning |
|---|---|---|
ok | boolean | true on a successful response. |
request_id | string | Provided id or a generated UUID. |
mode | "mc" | "freeform" | Multiple-choice or omitted-options mode. |
question | string | The trimmed submitted question. |
summary | string | Generated summary of the answer distribution and panel-support tier. |
distribution | array | Answer shares after the endpoint’s configured calibration steps. |
distribution[].option | string | Answer label. |
distribution[].pct | number | Percentage share, on the 0–100 scale. |
distribution[].count | number | Underlying answer count; calibration may change pct without changing count, so count/n need not equal pct. |
panel_composition.respondent_origin | "synthetic_panel" | Every respondent is simulated. |
panel_composition.n_real | number | Legacy name for persistent simulated-panel records. These are not human interviews. |
panel_composition.n_synthetic | number | On-the-fly simulated records used to fill the draw. |
panel_composition.n_total | number | Total simulated records queried. |
panel_composition.market_mode | string | Sampling mode: live_panel, pooled_panel or census_weighted. live_panel is a legacy name for stored simulated records. |
panel_composition.market | string | Resolved market id. |
confidence.score | number | Rounded 0–1 panel-support heuristic, described below. |
confidence.label | string | Human-readable panel-support label. |
confidence.tier | "green" | "amber" | "orange" | "red" | Thresholded heuristic; not a probability of accuracy. |
usage.respondents_billed | number | Respondents with returned answers. |
usage.month_used | number | Usage reported from the authentication snapshot plus this call; concurrent requests may make it stale. |
usage.month_limit | number | Effective monthly respondent allowance. |
The following shortened response uses invented example values. It is not a benchmark result.
{
"ok": true,
"request_id": "example-request",
"mode": "mc",
"question": "Would you switch brands at $4.99?",
"summary": "Illustrative summary only.",
"distribution": [
{
"option": "Probably",
"pct": 38,
"count": 190
}
],
"panel_composition": {
"respondent_origin": "synthetic_panel",
"n_real": 500,
"n_synthetic": 0,
"n_total": 500,
"market_mode": "pooled_panel",
"market": "national_us"
},
"confidence": {
"score": 0.8,
"label": "Higher panel support",
"tier": "green"
},
"usage": {
"respondents_billed": 500,
"month_used": 500,
"month_limit": 50000
}
}n_real is a compatibility field for stored simulated records. It never counts human completes. The supplied respondent_origin is the appropriate label for downstream displays.
Errors and retries
Most errors have an ok: false and error body. The interactive pause response is an exception: it has no ok field. Check the HTTP status before reading success fields.
| Field | Type | Meaning |
|---|---|---|
400 | Invalid request | Invalid JSON, missing question, invalid option count, moderation, question-quality or market validation. |
401 | Missing or invalid key | Missing API key, or an invalid or revoked key. Example body below. |
403 | Not currently emitted | This endpoint does not currently return 403. If an upstream access layer returns it, contact the team; no endpoint-specific JSON body is promised. |
429 | Rate or quota limit | Request/minute cap, monthly respondent pool or lifetime demo-call cap. Rate-limit 429 responses do not currently include Retry-After. |
500 | Server configuration/auth error | Auth lookup failed or inference endpoint not configured. |
502 | Inference unavailable | error: lewis_unavailable; the response also includes a message. |
503 | Interactive pause or maintenance | A Retry-After header is supplied. Use it before retrying. |
401
{"ok":false,"error":"Invalid or revoked API key."}
429 (example: free API tier)
{"ok":false,"error":"Rate limit reached (10 requests/min on the free plan, across all your keys). Slow down or upgrade."}
500
{"ok":false,"error":"Inference endpoint not configured"}
502
{"ok":false,"error":"lewis_unavailable","message":"Lewis inference is temporarily unavailable. Please try again later."}
503 (interactive pause; Retry-After: 3600)
{"error":"[current pause message]","interactive_unavailable":true,"retry_hint":"Queued study delivery is unaffected."}For transient 5xx failures, use bounded retries with exponential backoff and jitter; honor Retry-After when present. Do not automatically retry 400 or 401. A repeated request can perform new inference and consume additional quota.
Plan limits
These are the API tier ids enforced by the current v1 handler, not the marketing plan names. Your configured monthly override takes precedence over the default below.
| API tier | Respondents/query | Requests/minute | Default monthly respondents |
|---|---|---|---|
| free | 200 | 10 | 1,000 |
| demo | 100 | 5 | 1,000 |
| starter | 500 | 15 | 50,000 |
| growth | 1,000 | 30 | 250,000 |
| scale | 2,500 | 120 | 1,000,000 |
Demo keys also have a lifetime limit of five recorded calls. Monthly usage resets at 00:00 UTC on the first day of the month. Failed inference releases the reserved account quota; returned answers determine billed respondents.
What the confidence fields measure
The legacy confidence object describes panel support using a heuristic. It is not fitted to held-out question errors, and neither its score nor its color is a probability that an answer is correct.
score = 0.50
+ (multiple choice ? 0.20 : -0.25)
+ (market class = high ? 0.20 : directional ? 0 : -0.10)
+ (persistent-panel fraction - 0.50) × 0.20
- (returned n < 50 ? 0.15 : 0)
+ (largest answer share > 88% ? 0.05 : 0)
Clamp to [0, 1], round to two decimals, then assign tier.| Field | Type | Meaning |
|---|---|---|
green | score ≥ 0.80 | Higher panel support |
amber | 0.60 ≤ score < 0.80 | Moderate panel support |
orange | 0.40 ≤ score < 0.60 | Limited panel support |
red | score < 0.40 | Low panel support |
The current market registry returns benchmarked, benchmarking or directional, so the legacy high bonus is not reached by registered markets. Both benchmarked and benchmarking currently take the “otherwise” deduction. We preserve this v1 behavior here; it is another reason to read the field as a heuristic rather than an accuracy grade.
The persistent-panel fraction uses n_real / returned n; those records are still simulated. A concentrated answer receives a small score bonus under the legacy formula even though concentration can also reflect model bias. The internal within_moe flag is not used by this API score. See the planned evaluation of predicted error.
Versioning and changelog
The URL carries the v1 version. Preserve unknown response fields when forwarding data, and use named fields rather than array positions. Breaking changes require a versioned interface.
- October 2026: renamed confidence labels to describe panel support; the score formula and tier thresholds are unchanged.
- Current reference: account-wide limits, simulated respondent provenance, calibration/count distinction and interactive pause behavior documented.
MCP
MCP access is configured per Enterprise workspace. The tools, permissions, limits and deployment requirements are agreed with your team. This REST endpoint is the public integration reference; no self-serve MCP credentials are issued here.
Enterprise integrations