LLARS v1 Scenario API¶
Version: 1.0 | Last updated: May 2026
Programmatic REST API for creating and managing complete scenarios — config, items, assessors, and referral links — in a single POST. Built for external clients (CI seeders, study pipelines, notebooks) that need to drive the scenario wizard from outside the browser.
All endpoints live under /api/v1/*.
Authentication¶
| Method | Header | When |
|---|---|---|
| Personal API key | X-API-Key: <key> |
External clients, CI |
| System admin key | X-API-Key: $SYSTEM_ADMIN_API_KEY |
Server-to-server |
| OAuth bearer | Authorization: Bearer <token> |
Browser sessions (Authentik) |
Mint API keys under Settings → API Keys. The key value is shown exactly once — copy it immediately.
Permission to mint keys¶
POST /api/auth/api-keys is gated by feature:api_keys:create (admin + researcher by default). The admin:* scope additionally requires feature:api_keys:admin_scope (admin only).
Bootstrap requires a browser session
POST /api/auth/api-keys itself is decorated with @authentik_required (OAuth) — it does not accept X-API-Key. External CI clients therefore cannot bootstrap their own scoped keys via API key auth: they need a one-time Authentik browser session as a user holding feature:api_keys:create. Each account is capped at 10 keys.
Allowed scopes when minting: scenario:read, scenario:write, chatbot:read, chatbot:write, conference:read, conference:write, tickets:read, tickets:write, admin:* (see ALLOWED_API_KEY_SCOPES in app/routes/auth/api_key_routes.py). Anything else is rejected with 400. A key only gets a scope if its owner holds the permission behind it, and every call checks that again (scope ∧ permission).
Scopes¶
API keys can be restricted to a scope list. An empty list means the key inherits the owner's permissions (legacy behaviour). OAuth bearer tokens carry no scopes; they fall back to the regular RBAC system.
| Scope | Allows | RBAC fallback (OAuth) |
|---|---|---|
scenario:read |
GET /api/v1/scenarios* |
feature:rating:view, feature:ranking:view, data:manage_scenarios |
scenario:write |
POST / PUT / PATCH / DELETE on /api/v1/scenarios* |
data:manage_scenarios |
tickets:read |
Read support tickets (GET /api/tickets*, since 12.11.2026) |
feature:tickets:view |
tickets:write |
Report, change and comment on tickets, add files (since 12.11.2026) | feature:tickets:view |
admin:* |
Everything. Overrides every other scope check | admin:permissions:manage |
A …:write scope also covers the matching …:read. The chatbot and conference
scopes are described in the chatbot API and
conference API guides.
Endpoints¶
| Method | Path | Scope | Purpose |
|---|---|---|---|
GET |
/api/v1/scenarios |
scenario:read |
List scenarios visible to the caller |
POST |
/api/v1/scenarios |
scenario:write |
One-shot create (scenario + items + assessors + referral link) |
GET |
/api/v1/scenarios/{id} |
scenario:read |
Read a single scenario |
PATCH |
/api/v1/scenarios/{id} |
scenario:write |
Patch name / description / archive flag / time window (begin, end) |
PUT |
/api/v1/scenarios/{id}/config |
scenario:write + creator/admin only (else 404) |
Replace the config of the current type, with the same checks as the UI (section) |
GET |
/api/v1/me |
any valid key | Who am I: person, roles, permissions, scopes, key name (section) |
GET |
/api/v1/models |
scenario:read or chatbot:read + feature:llm:view |
Language models the person may use (no provider data) |
DELETE |
/api/v1/scenarios/{id} |
scenario:write |
Hard delete (cascade) |
POST |
/api/v1/scenarios/{id}/archive |
scenario:write |
Soft archive (toggle) |
POST |
/api/v1/scenarios/{id}/items |
scenario:write |
Append items; not for paper review, anonymization and online experiment (400 not_supported_for_paper_review / not_supported_for_anonymization / not_supported_for_experiment — use the upload routes of that type) |
DELETE |
/api/v1/scenarios/{id}/items/{item_id} |
scenario:write |
Detach a single item |
GET |
/api/v1/scenarios/{id}/assessors |
scenario:read + owner/editor/viewer/admin |
List members (else 404) |
POST |
/api/v1/scenarios/{id}/assessors |
scenario:write |
Invite an assessor |
PATCH |
/api/v1/scenarios/{id}/assessors/{user_id} |
scenario:write |
Patch roles / status |
DELETE |
/api/v1/scenarios/{id}/assessors/{user_id} |
scenario:write |
Remove a membership |
GET |
/api/v1/scenarios/{id}/referral-link |
scenario:read + owner/editor/viewer/admin |
Read attached link (else 404) |
POST |
/api/v1/scenarios/{id}/referral-link |
scenario:write |
Sync link to scenario (idempotent on slug) |
DELETE |
/api/v1/scenarios/{id}/referral-link |
scenario:write |
Detach link (link itself stays) |
GET |
/api/v1/scenarios/{id}/results |
scenario:read + owner/editor/viewer/admin |
Results export (json/csv/jsonl, long format; else 404) |
GET |
/api/v1/scenarios/{id}/leaderboard |
scenario:read + owner/editor/viewer/admin |
Leaderboard of a comparison scenario (Bradley-Terry on the Elo scale; ?n_boot=0..5000, ?seed=; else 404) |
GET |
/api/v1/scenarios/{id}/metrics |
scenario:read + owner/editor/viewer/admin |
IRR block (filters: ?copilot=, ?part=; else 404) |
GET |
/api/v1/scenarios/{id}/span-events |
scenario:read + owner/editor/viewer/admin |
Protocol of span splits and merges with actor and deleted votes (labeling 7/9, json/csv, ?rows=events\|votes; else 404) |
POST |
/api/v1/scenarios/{id}/items/{item_id}/messages/{index}/make-context |
scenario:write + creator/admin only (else 404) |
Take a message of a type-9 conversation out of labeling: remove its spans, votes and measurements with a protocol entry, optionally correct the sender; dry run is the default (section) |
GET |
/api/v1/scenarios/{id}/copilot |
scenario:read |
Co-pilot status (labeling, owner only) |
PUT |
/api/v1/scenarios/{id}/copilot |
scenario:write |
Update co-pilot config |
POST |
/api/v1/scenarios/{id}/copilot/generate |
scenario:write |
(Re-)start suggestion generation |
PUT |
/api/v1/scenarios/{id}/labeling-config |
scenario:write |
Toggle question-first labeling (questions) and the second choice (second_choice) (labeling, owner only) |
GET |
/api/v1/scenarios/{id}/parts |
scenario:read |
Parts status incl. per-assessor progress (labeling, owner only) |
PUT |
/api/v1/scenarios/{id}/parts |
scenario:write |
Define the parts of a running scenario without parts (every item exactly once; owner/admin only) |
PUT |
/api/v1/scenarios/{id}/parts/{part_id} |
scenario:write |
Update a part: locked / copilot / name / order |
POST |
/api/v1/scenarios/{id}/derive |
scenario:write |
Derive a new conversation-labeling scenario from this one (conversations copied, e.g. with the OnCoCo tree; owner/admin only) |
POST |
/api/v1/scenarios/{id}/ai-suggestions |
scenario:write |
Import AI suggestions of one external model (labeling type 7 per item, conversation labeling type 9 per span; ≤ 500 per call, upsert; owner/admin only) |
GET |
/api/v1/scenarios/{id}/ai-suggestions |
scenario:read |
AI suggestion status: config, counts per model, gate |
PUT |
/api/v1/scenarios/{id}/ai-suggestions/config |
scenario:write |
AI suggestions on/off, control ratio, display name/order per model |
DELETE |
/api/v1/scenarios/{id}/ai-suggestions?model_key= |
scenario:write |
Remove one model's suggestions (logs are kept) |
POST |
/api/v1/scenarios/{id}/papers |
scenario:write |
Paper review: upload one PDF as a new paper (multipart, optional label, metadata, abstract; owner/admin only) |
POST |
/api/v1/scenarios/{id}/items/{item_id}/document |
scenario:write |
Paper review: set or replace an item's PDF (only without reviews) |
DELETE |
/api/v1/scenarios/{id}/items/{item_id}/document |
scenario:write |
Paper review: remove only an item's PDF (only without reviews) |
GET |
/api/v1/scenarios/{id}/paper-review/documents |
scenario:read |
Paper review: which items have a PDF, extraction status, reviews per item |
PUT |
/api/v1/scenarios/{id}/paper-review/config |
scenario:write |
Paper review: replace the codebook; after the first review only additions (409 CODEBOOK_LOCKED) |
POST / GET / DELETE |
/api/v1/scenarios/{id}/paper-review/prefill |
scenario:write / scenario:read |
Paper review: import, read or remove the AI prefill |
POST |
/api/v1/scenarios/{id}/paper-review/prefill/run |
scenario:write |
Paper review: start the AI prefill (202; 409 ALREADY_RUNNING) |
GET |
/api/v1/scenarios/{id}/anonymization/export |
scenario:read |
Anonymization: anonymized export as a file (?status=done\|all, ?format=json\|csv; owner/admin only, otherwise 404) |
One-shot example¶
curl -X POST https://llars.example.org/api/v1/scenarios \
-H "X-API-Key: $LLARS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "EMNLP Pilot v4",
"description": "Turing-Test 40 items",
"eval_config": {
"type": "comparison",
"config": {
"question": {"de": "Welche Antwort ist besser?", "en": "Which response is better?"},
"allow_tie": true,
"show_source": false,
"gamification_enabled": true,
"gamification_first_milestone": 10,
"gamification_recurring_milestone": 5
}
},
"items": {
"schema_version": "1.0",
"items": [
{
"id": "case_001",
"label": "Case 001",
"source": {"type": "human"},
"content": {
"type": "conversation",
"messages": [
{"role": "Klient", "content": "I cannot sleep ..."},
{"role": "Berater", "content": "Tell me more ..."}
]
},
"features": [
{"type": "candidate", "content": "Empathic counsellor reply", "generated_by": "human"},
{"type": "candidate", "content": "GPT-5 generated reply", "generated_by": "Global/OpenAI/gpt-5-nano"}
]
}
]
},
"assessors": [
{"username": "researcher", "manager_role": "editor", "evaluation_role": "none"},
{"username": "evaluator", "manager_role": "none", "evaluation_role": "assessor"}
],
"referral_link": {
"slug": "human-comparison-emnlp",
"label": "EMNLP Turing-Test 2026",
"auto_enroll": true
}
}'
Response (201 Created):
{
"success": true,
"scenario": {
"id": 42,
"name": "EMNLP Pilot v4",
"evaluation_type": "comparison",
"function_type_id": 4,
"item_count": 1,
"assessor_count": 2,
"items_imported": {
"items_created": 1,
"features_created": 2,
"item_ids": [517]
},
"referral_link": {
"id": 7,
"slug": "human-comparison-emnlp",
"code": "voVXDi0G7AJm",
"target_scenario_id": 42
}
}
}
Time window and time zones¶
begin and end are optional. Without begin the scenario starts at once,
without end it ends three weeks after begin. The server stores both
timestamps in UTC:
- A timestamp with an offset or
Z(2026-11-20T16:20:41+01:00) is converted to UTC and kept exactly, even if it lies in the future. This is how you plan a later start. - A timestamp without a time zone (
2026-11-20T16:20:41) counts as UTC. - Exception: if a
beginwithout a time zone lies at most 15 hours in the future, it is almost always local time (for exampledatetime.now().isoformat()in Python). The server then setsbeginto now, so that assessors see the scenario at once.endstays as it is. - A
beginwithout a time zone that lies further in the future or in the past stays unchanged.
If the server adjusted begin, the response also carries warnings, a list of
short English sentences:
{
"success": true,
"scenario": {"id": 43, "begin": "2026-11-20T15:20:42.118930", "...": "..."},
"warnings": ["`begin` 2026-11-20T16:20:41 has no time zone and lies 1.0 h ahead of the server's UTC clock, so it was set to now (2026-11-20T15:20:42Z). Naive datetimes are read as UTC; send a planned start with an explicit offset (e.g. +01:00) or 'Z'."]
}
Without an adjustment warnings is absent. The same rules apply to
POST /api/v1/scenarios/{id}/derive. A script is safest sending UTC with a
zone, in Python for example datetime.now(timezone.utc).isoformat().
Curl quickref¶
# List (?limit=&offset=)
curl -H "X-API-Key: $K" https://llars/api/v1/scenarios?limit=20
# Read a single scenario
curl -H "X-API-Key: $K" https://llars/api/v1/scenarios/42
# Update description
curl -X PATCH -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"description":"Updated via API"}' \
https://llars/api/v1/scenarios/42
# Archive
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"archived": true}' https://llars/api/v1/scenarios/42/archive
# Invite assessor
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"username":"evaluator","evaluation_role":"assessor"}' \
https://llars/api/v1/scenarios/42/assessors
# Re-point referral link (idempotent)
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"slug":"human-comparison-emnlp","auto_enroll":true}' \
https://llars/api/v1/scenarios/42/referral-link
# Cascade delete
curl -X DELETE -H "X-API-Key: $K" https://llars/api/v1/scenarios/42
Changing config and time window¶
Since 12.11.2026 the config of an existing scenario can be changed with a key.
PUT /api/v1/scenarios/{id}/config replaces the config of the type the scenario
already has; there is no type change. The body is the object that sits under
eval_config.config on create (an AnonymizationConfig for type 11), optionally
wrapped as {"config": {...}}. It is validated against the config class of the
type; unknown fields give 400 where the class forbids them (types 10 and 11).
After that the same rules apply as when saving in the UI, because both paths use
the same service (app/services/scenario_config_service.py):
- Type 10: after the first review the codebook may only be extended, otherwise
409 CODEBOOK_LOCKEDwithdetails.violations. - Type 11: with
engine: "hybrid",llm_modelmust be active (400 llm_model_inactive), it must not be an OpenAI model (400 llm_model_not_allowed, since 13.11.2026: counselling content never goes to OpenAI), and the person who owns the scenario must have access to it (403 llm_model_forbidden).required_reviewsmay change at any time; the case status is recomputed immediately. - Type 11 with a personal key (since 13.11.2026): a key may not open a new way
for original counselling text to reach a language model. These ways are
engine: "hybrid",llm_suggestions: true,llm_auto: trueand anotherllm_modelon one of them. The server then answers403 HUMAN_REQUIREDand names the ways indetails.destinations(detection,suggestions,auto). Switching off and all other fields keep working with a key. A signed-in person switches them on in the UI, where they see the notice "plain text goes to". - Co-pilot and LLM evaluators (since 13.11.2026): a new or changed model in
copilot.model_idor inllm_evaluators/selected_llmsmust be usable by the person who owns the scenario, otherwise403 llm_model_forbiddenwithdetails.models. Unchanged models are not checked again. The same rule applies toPUT …/copilotand the internalPUT /api/scenarios/{id}. - Rating (types 2 and 3): the server drops old flat scale fields (
min,max,step,labelsat the top level and ineval_config) on replace. Otherwise they would have shadowed the newscale. - Co-pilot and parts are normalized as on create.
- A body above 1 MiB gets
413 config_too_large. A label set has at most 2,000 labels and a scenario at most 500 parts. These limits apply on create as well.
Only the person who created the scenario (created_by) and admins may call it;
everyone else gets 404. The response is {"success": true, "scenario": {...}}
in the same shape as GET.
# Type 11: split future conversations as interview transcripts
curl -X PUT -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"required_reviews": 2, "conversation_format": "transcript"}' \
https://llars/api/v1/scenarios/42/config
# Set the time window (ISO timestamps, end after begin)
curl -X PATCH -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"begin": "2027-01-01T00:00:00Z", "end": "2027-03-31T23:59:00Z"}' \
https://llars/api/v1/scenarios/42
The whole config of the type is replaced: fields missing from the body get their
default value. To change a single field, read the config first with
GET /api/v1/scenarios/{id} (config_json.eval_config.config) and send it back
changed.
Since 12.11.2026 PATCH also takes begin and end. If only one of them is
sent, the server checks it against the stored other one (end must lie after
begin, otherwise 400). Timestamps with a time zone are stored as UTC without
zone; the response carries begin and end as ISO text. A timestamp that
leaves the value range when converted to UTC (such as
9999-12-31T23:30:00-01:00) gives 400.
Who am I and which models¶
GET /api/v1/me answers every valid key and every session, whatever its scope.
The LLARS MCP uses it to detect its profile.
{
"success": true,
"username": "researcher",
"user_id": 7,
"display_name": "Researcher",
"access_expires_at": null,
"roles": ["researcher"],
"permissions": ["data:import", "data:manage_scenarios", "…"],
"auth_method": "user_api_key",
"system_key": false,
"key_name": "MCP laptop",
"scopes": ["scenario:read", "tickets:write"],
"effective_scopes": ["scenario:read", "tickets:read", "tickets:write"]
}
auth_methodisuser_api_key,system_api_keyoroauth_token.scopesare the key's scopes:[]means "no scope, the person's permissions"; a session hasnull, the system key["admin:*"].effective_scopesare the scopes the call can actually use right now: covered by the key and backed by a permission of the person.- The response never contains the key itself, its prefix or its hash, only the
name the person gave it. For the system key
key_nameisnull.
GET /api/v1/models returns the language models the person may use (like the
model picker in the UI, including the per-model allowlist). It needs
scenario:read or chatbot:read and the permission feature:llm:view. Filters:
?active_only=true|false, ?model_type=llm|embedding|reranker,
?vision_only=true, ?reasoning_only=true.
{"success": true, "count": 1, "models": [{
"model_id": "Global/Qwen/Qwen3.8-Flash-Next-FP8",
"display_name": "Qwen3.8 Flash Next (FP8)", "description": null, "model_type": "llm",
"supports_vision": true, "supports_reasoning": false,
"supports_function_calling": true, "supports_streaming": true,
"context_window": 131072, "max_output_tokens": 8192, "is_default": true
}]}
Provider, provider id, costs and creator are deliberately left out.
Appending items later¶
POST /api/v1/scenarios/{id}/items expects a bare LlarsNativeEnvelope as the body — not wrapped in {"items": {...}}. This is the most common stumbling block: a wrapper object is rejected with 400 (extra='forbid' + missing schema_version).
curl -X POST https://llars.example.org/api/v1/scenarios/42/items \
-H "X-API-Key: $LLARS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"schema_version": "1.0",
"reference": null,
"items": [
{
"id": "case_002",
"label": "Case 002",
"source": {"type": "human"},
"content": "Plain text content for this item.",
"features": [
{"type": "candidate", "content": "Reply A", "generated_by": "human"},
{"type": "candidate", "content": "Reply B", "generated_by": "Global/OpenAI/gpt-5-nano"}
]
}
]
}'
Response (201 Created):
reference is optional and may be omitted. An empty items: [] is accepted and returns 200 with items_created: 0.
Parts / Phases (labeling)¶
Labeling scenarios (type: "labeling") can optionally be partitioned into
ordered parts — the study gate for calibration designs (P1 → IRR +
alignment meeting → unlock P2 → …). The partitioning is invisible to
raters: locked parts simply don't exist for them yet, and the parts
section is stripped server-side from every config delivered to assessors.
Create via the parts section inside eval_config.config — the items must
be part of the same request, because size specs ("the next N items in
upload order", last part without size = rest) are resolved into item ids in
the same transaction:
"eval_config": {
"type": "labeling",
"config": {
"mode": "single",
"labels": [{"id": "disclosure", "label": {"de": "Disclosure", "en": "Disclosure"}}],
"copilot": {"enabled": true, "model_id": "Global/Qwen/Qwen3.8-Flash-Next-FP8", "hidden_control_ratio": 0.2},
"parts": {
"enabled": true,
"list": [
{"name": "Calibration 1", "size": 100, "order": "sequential", "copilot": false},
{"name": "Calibration 2", "size": 50, "order": "sequential", "copilot": false, "locked": true},
{"name": "Main phase", "order": "sequential", "copilot": true, "locked": true}
]
}
}
}
Per-part semantics: order (sequential = identical order for every rater,
random = deterministic per-user shuffle), copilot (per-part override under
the copilot.enabled master switch — the runner only generates for co-pilot
parts), locked (not delivered until the owner unlocks).
# Status incl. per-assessor progress
curl -H "X-API-Key: $K" https://llars/api/v1/scenarios/42/parts
# Unlock a phase (the IRR gate between calibration phases)
curl -X PUT -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"locked": false}' https://llars/api/v1/scenarios/42/parts/p2
# Add items later: part_id is REQUIRED while parts are active
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"schema_version": "1.0", "part_id": "p3", "items": [...]}' \
https://llars/api/v1/scenarios/42/items
# IRR per phase (combinable with ?copilot=with|without)
curl -H "X-API-Key: $K" "https://llars/api/v1/scenarios/42/metrics?part=p1"
The results export (GET .../results) carries a part column on every row;
copilot_metrics is additionally aggregated per part (per_part).
item_ids of existing parts are not editable via PUT (partition
invariant + audit trail); redistributing before study start = recreate the
scenario.
Defining parts in a running scenario¶
Since 15 Oct 2026 parts can also be added later — for a scenario that has
no resolved parts yet (e.g. conversation labeling 1038: the first 42
conversations without AI, the rest with AI suggestions). The route writes
only the parts section (in eval_config.config and in the config
mirror); every other config key stays untouched. That is the difference to
the generic UI PUT /api/scenarios/{id}, which merges config_json flatly.
Labeling type 7 and type 9, owners and admins only (everybody else gets 404,
like the other parts routes).
curl -X PUT -H "X-API-Key: $K" -H "Content-Type: application/json" \
https://llars/api/v1/scenarios/1038/parts -d '{
"parts": [
{"id": "p1", "name": "Ohne KI", "size": 42, "copilot": false, "locked": false, "order": "sequential"},
{"id": "p2", "name": "Mit KI-Vorschlägen", "copilot": true, "locked": false, "order": "sequential"}
]
}'
# → 200, same answer as GET …/parts:
# {"success": true, "scenario_id": 1038, "enabled": true, "resolved": true,
# "parts": [{"id": "p1", "name": "Ohne KI", "order": "sequential", "copilot": false,
# "locked": false, "item_count": 42, "size": null, "resolved": true,
# "assessors": [{"user_id": …, "username": …, "labeled": …, "total": 42}]}, …]}
| Field per part | Meaning |
|---|---|
id |
optional (A–Z a–z 0–9 _ . -, ≤ 64), otherwise p1 … pn; appears in the export (part) |
name |
optional, otherwise the id |
order |
sequential (default) or random |
copilot |
part gate for the co-pilot and the AI suggestions of external models |
locked |
true = assessors do not see the part |
size |
the next N items in upload order (item_id ascending) |
item_ids |
explicit items instead (internal ids as numbers, external ids as text) |
The last part may omit both size and item_ids and takes the rest. The
partition is checked in full: every item of the scenario in exactly one
part, no foreign ids, no size beyond the remaining items — otherwise 400 and
the config stays unchanged. If the scenario already has resolved parts the
route answers 409 (re-partitioning mid-study would move already labeled
items between parts); flags of existing parts are changed via
PUT …/parts/{part_id}.
AI suggestions of external models (labeling)¶
Since 13 Oct 2026 the labeling interface (type 7) can show the suggestions of several models that ran outside LLARS — one row per model with display name, label, second choice, answers to the decision questions and the rationale on hover. Nothing is preselected; a suggestion is only applied by a click. The suggestions enter the scenario through these routes; raters never see the full model id, only the display name.
Who sees suggestions? Only for items in parts with copilot: true (all
items when parts are inactive), while enabled holds and the (rater, item) pair
is not in the covert control subset (hidden_control_ratio, default 0). The
control subset has its own server-side salt and is independent of the co-pilot.
The Mistral co-pilot (…/copilot) is unaffected.
# Import one model's suggestions (≤ 500 per call; chunk larger runs)
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
https://llars/api/v1/scenarios/758/ai-suggestions -d '{
"model_key": "opus5",
"display_name": "Opus 5.5",
"model_id": "claude-opus-5-5",
"prompt_version": "oncoco-ai-v1",
"suggestions": [
{"item_id": 4711, "label": "D", "second_choice": "E",
"answers": {"q1": "S", "q2": "S", "q3": "S"}, "flips": "q3",
"why": "The speaker reports her own experience …"}
]
}'
# → 201 {"imported": 1, "updated": 0, "rejected": [], "totals": {"opus5": 1}, …}
# Status: config (without salt), counts per model, gate
curl -H "X-API-Key: $K" https://llars/api/v1/scenarios/758/ai-suggestions
# Order / display name per model, control ratio, on/off
curl -X PUT -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"models": {"fable51": {"sort_order": 1}}, "hidden_control_ratio": 0}' \
https://llars/api/v1/scenarios/758/ai-suggestions/config
# Remove one model's suggestions (logs are kept)
curl -X DELETE -H "X-API-Key: $K" \
"https://llars/api/v1/scenarios/758/ai-suggestions?model_key=fable51"
| Field (import) | Meaning |
|---|---|
model_key |
Stable key (A–Z a–z 0–9 _ . -, ≤ 64), upsert axis, appears in the export |
display_name |
What raters see; if omitted the previous name stays, on the first import the model_key |
model_id |
Full model id, owner and export only |
prompt_version |
Required (≤ 64 characters), e.g. oncoco-ai-v1 |
sort_order |
Position in the bar; default = after the models imported so far |
suggestions[] |
item_id (internal item id), label, optional second_choice, answers ({question id: option}), flips, why (≤ 2,000 characters) |
Re-importing the same model_key overwrites the entries (e.g. a new prompt
version); what raters have already seen is snapshotted in the log and does not
change. Invalid entries do not reject the whole call but are listed with a
reason in rejected: item_not_in_scenario, unknown_label,
unknown_second_choice, second_choice_equals_label,
answers_without_questions, unknown_question, unknown_answer_option,
span_id_not_supported, duplicate_in_request. The server computes
consistent per entry (does the answer key map to the label; empty for labels
outside the mapping such as X). The first import switches suggestions on
(enabled: true, control ratio 0).
The results export (GET …/results) carries six columns at the end of every
labeling row: ai_shown, ai_models_shown (keys in display order),
ai_suggestions_json (snapshot per model: label, second choice, answers,
flips, prompt_version), ai_agree_models (models with the final label),
ai_agree_any and ai_applied_model. The JSON envelope additionally contains
ai_suggestion_metrics: per model the agreement with the final label (overall,
per annotator, per suggested label), the share of second-choice hits, the apply
rate and shown_items.
Conversation labeling (type 9): suggestions per span¶
Since 15 Oct 2026 the same routes work for conversation labeling. The unit of decision there is the span, hence:
- Import: every entry needs a
span_idfrom its item's span index (the same id as in the export columnspan_id, e.g.m2-s001). Upsert per (item, span,model_key). Additional reasons inrejected:span_required(emptyspan_id),span_not_in_item(the id does not exist in this item, e.g. after a split/merge) and — for hierarchical label sets —label_not_allowed_for_role(label or second choice does not fit the span's speaker role; the same rule as on save). Rejected type-9 entries additionally carry thespan_id, e.g.{"item_id": 16821, "reason": "span_not_in_item", "detail": "m1-s001", "span_id": "m1-s001"}. Type 7 still rejects aspan_idwithspan_id_not_supported. - Status:
GET …/ai-suggestionsadditionally containsspans_with_suggestions(distinct item–span pairs with at least one suggestion);items_with_suggestionscounts conversations. - Delivery to the interface (internal,
GET /api/evaluation/session/{id}/items/{item_id}/ai-suggestions): one call per conversation.spanscontains only the spans for which the rater sees suggestions;shownistrueas soon as at least one span is visible. The entries are the same as for type 7, withoutmodel_id. The parts gate and theenabledswitch apply to the whole conversation; the hidden control subset is drawn per span. Suggestions for spans that no longer exist after a split/merge stay stored but are no longer delivered. - Log and export: one log row per (rater, item, span); the
ai_*columns sit on the respective span row. Inai_suggestion_metrics,logged_items,shown_itemsandnot_shown_itemscount spans for type 9, not conversations (the field names are the same for both types).
Delivery answer for one conversation (type 9). The interface looks up each
span id; do not rely on the key order inside spans:
{"success": true, "item_id": 16821, "shown": true, "suggestions": [],
"spans": {"m2-s001": {"shown": true, "suggestions": [
{"model_key": "opus5", "display_name": "Opus 5.5", "color_slot": 1, "label": "D",
"second_choice": "E", "answers": {"q1": "S", "q2": "S", "q3": "S"},
"flips": "q3", "why": "…", "prompt_version": "gemco-ai-v1"}]}}}
Deriving a scenario (conversation labeling)¶
POST /api/v1/scenarios/{id}/derive creates a new scenario from an existing
conversation-labeling scenario (type 9) — for example, from the VRM annotation
of the GEMCo conversations a scenario in which the same spans are annotated
with OnCoCo labels level by level down to a leaf (T-37, 07 Oct 2026).
- Conversations are copied, not linked. Splitting or merging spans in the new scenario therefore never changes the source.
- Source spans keep their
span_id(join key between both annotation layers), including already split (+a/+b) or merged (+m) ones. - Client messages get spans of their own:
sentencecuts at the end of a sentence (.!?…, also with a closing quote) before whitespace and at blank lines, without ML;satcuts with the neural segmenter SaT-12l-sm, the one that also produced the counselor spans of the GEMCo conversations (seesatmode);messagemakes the whole message one span;nonekeeps them as context. Ids follow the source pattern, e.g.gemco_A/1/m1/c001. - Every span carries
speaker_role(counselor/client); with an active tree it only offers the labels of its role. oncoco_*metadata of the source items is not copied; every item carriesderived_from: {scenario_id, item_id}.- Only the creator of the source or an admin; otherwise
404.
| Field | Default | Meaning |
|---|---|---|
name |
— | Required |
description |
null |
Description |
label_scheme |
null |
"oncoco-1.0" builds the OnCoCo tree (90 nodes, DE/EN, hierarchy block). Exactly one of label_scheme and labels |
labels |
null |
Flat label set (list of LabelOption) when no scheme is used |
client_segmentation |
"sentence" |
sentence · sat · message · none |
copy_source_spans |
true |
false = re-cut the labelable source messages by sentence (ids …/r001) |
examples_from_scenario_ids |
[] |
Scenarios whose items carry an OnCoCo gold label; their texts become hover examples (anchors). The caller must be allowed to read them |
n_examples |
3 |
At most this many examples per node (0–10), each at most 200 characters |
examples_lang |
"de" |
Language the examples are stored under |
assessors |
[] |
Usernames of the annotators. An unknown name → 400 with the list, nothing is created |
second_choice |
true |
Allow a second choice |
copilot |
false |
true only switches the co-pilot block on; the model is set with PUT …/copilot |
context_window |
3 |
Visible preceding messages |
role_by_speaker |
null |
Extra Message.sender → counselor/client mapping on top of the default names (Berater:in, Beratende, Klient:in, Ratsuchende, …) |
begin / end |
now / +3 weeks | Evaluation window; time zones and warnings as on create (section "Time window and time zones") |
The new scenario takes future_spans and no_future_messages from the source.
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{
"name": "OnCoCo × GEMCo",
"label_scheme": "oncoco-1.0",
"client_segmentation": "sentence",
"copy_source_spans": true,
"examples_from_scenario_ids": [758, 791],
"n_examples": 3,
"examples_lang": "de",
"assessors": ["<username-1>", "<username-2>"],
"second_choice": true,
"copilot": false,
"context_window": 3
}' \
https://llars/api/v1/scenarios/1038/derive
Response 201 from the route test (one conversation with two counselor and two client spans, shortened):
{
"success": true,
"scenario": { "id": 2, "evaluation_type": "conversation_labeling", "function_type_id": 9,
"item_count": 1, "assessor_count": 2, "config_json": { "...": "..." } },
"summary": {
"source_scenario_id": 1,
"items": 1, "items_skipped": [],
"spans_counselor": 2, "spans_client": 2, "spans_other": 0, "spans_invalid": 0,
"labels": 90,
"examples_filled": 7, "examples_missing": ["CO-IF-AC-RF-RPD", "..."],
"examples_gold_key": null, "examples_items_with_gold": 0, "examples_unknown_labels": 0,
"unknown_assessors": [],
"speaker_roles_stamped": true,
"client_segmentation": "sentence", "segmenter": "regex"
}
}
segmenter names the tool that cut the client messages: sat-12l-sm in sat mode, otherwise regex (the rule-based modes sentence, message and none); client_segmentation repeats the mode. examples_filled counts leaves with at least one example in examples_lang; without example scenarios these are only the built-in examples from the papers. examples_gold_key names the metadata key the gold labels were read from (null = only the ground_truth_label column); examples_unknown_labels counts gold values that are not OnCoCo codes — a high value usually means the key is wrong. Errors: 400 for a schema
violation, with details.unknown_assessors or details.unknown_speakers
(senders without a role → extend role_by_speaker) or details.segmenter in
sat mode (see below); 404 for a foreign or missing source or an example
scenario the caller cannot read. Background on the
label tree, the export columns label_*/speaker_role and IRR per depth:
Evaluation data formats › Hierarchical labels.
sat mode (SaT-12l-sm)¶
"client_segmentation": "sat" cuts the client messages with
Segment any Text (wtpsplit,
model segment-any-text/sat-12l-sm), i.e. with the same segmenter as the
counselor spans of the GEMCo pipeline (T-37, 08 Oct 2026). Unlike the rule in
sentence, SaT finds sentence boundaries even without punctuation and does not
cut after abbreviations such as "z.B." or after list numbers such as "1.".
- Units: SaT runs with its defaults — no language code, because the model
is multilingual, and the model's default threshold. Every line break and
every blank line stays a boundary, punctuation stays with its sentence, and
every unit is trimmed. Offsets refer to the original text:
text[start:end]is the unit verbatim, and every visible character of the message lies in exactly one unit. - No silent fallback: If
wtpsplitis not installed or the model cannot be loaded (no network, no cache), the route answers400withdetails.segmenter = "sat-unavailable". The message names the cause, and nothing is created. Thesentencerule does not step in; sendsentenceif you want it.details.segmenter = "sat-offset-mismatch"(withdetails.item_id) means that a SaT sentence could not be mapped onto the text. This should not happen, because SaT returns verbatim slices of the text; if it does, you get an error instead of a shifted unit. - Model and duration: The model loads once per server process on the
first
satcall and then stays in memory (roughly 0.6 to 0.9 GB extra). Weights (about 1 GB) and tokenizer live in the model directory of the embeddings (HF_HOME, default/app/storage/modelsin the volume) and so survive a container rebuild. Without a cache, the first call downloads the weights from Hugging Face. Depending on the connection this takes one to several minutes, and the route only answers afterwards. With a cache, loading takes a few seconds and a 150-character message about 20 to 30 ms on the CPU (measured on a development machine; the server may be slower). No GPU is needed. - Preloading: Before the first call, preload the model once per server,
as
flaskuserso that the files belong to the service:
docker exec -u flaskuser -w /app llars_flask_service \
python -c "from services.evaluation.scenario_derive_service import load_sat_model; load_sat_model()"
The command puts model and tokenizer into the same cache the route uses; the
Flask process then only reads them from disk on the first derivation. With
blue-green the container is called llars_flask_blue or llars_flask_green;
both colors share the llars_rag_storage volume, so one preload is enough.
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"name": "OnCoCo × GEMCo (SaT)", "label_scheme": "oncoco-1.0",
"client_segmentation": "sat", "assessors": ["<username-1>"]}' \
https://llars/api/v1/scenarios/1038/derive
# → 201, summary.segmenter = "sat-12l-sm", summary.client_segmentation = "sat"
Arena mode (comparison)¶
A comparison scenario becomes an arena when eval_config.config.randomize_order is true. Then:
- Every rater sees A and B in an own, fixed order. The order depends only on scenario, rater and item, so a reload does not change it.
- Every vote stores which feature stood in A and which in B. The v1 results show it in
option_a_model,option_b_modelandwinner_model(empty on a tie). The system is the candidate'sgenerated_by. - Without
show_sourcethe server sends no system names to the rater's browser. GET /api/v1/scenarios/{id}/leaderboardreturns the leaderboard: Bradley-Terry over all votes, ties as half wins, on the Elo scale (1000 = geometric mean, 400 points = 10:1), 95% item bootstrap intervals, win rate with Wilson interval, head-to-head counts and the position effect (share of decided votes for A). If the systems split into groups that were never compared,connectedisfalse.
A candidate may also be a whole conversation, for example a pre-generated chat:
{"type": "candidate", "generated_by": "model-x",
"content": {"type": "conversation", "messages": [
{"role": "Klient", "content": "Hallo", "timestamp": "2026-01-01T00:00:00"},
{"role": "Berater", "content": "Hallo, schön, dass Sie schreiben.", "timestamp": "2026-01-01T00:00:10"}]}}
Always send timestamps, LLARS orders messages by them. The uploading script fixes the pairings (every system pair equally often), the server does not pair by itself.
Span re-segmentation protocol¶
In conversation labeling (type 9) a rater can split a span or merge several.
That changes the units for everyone and deletes the votes of every rater on the
old spans (see
Conversation Labeling).
Since 23 October 2026 every such change writes one row to
labeling_span_events, and this endpoint returns them.
GET /api/v1/scenarios/{id}/span-events?format=json|csv&rows=events|votes
Access as for /results and /labeling-events: scope scenario:read and
owner, editor, viewer or admin of the scenario, otherwise the same 404 as for a
missing scenario. Labeling types 7 and 9 are allowed; type 7 never splits and
returns an empty list, any other type answers 400, as does an unknown format
or rows.
rows=events (default) returns one row per change:
| Column | Content |
|---|---|
id, scenario_id, item_id |
event, scenario, conversation |
actor_user_id, actor_username |
who split or merged |
kind, offset |
split, merge or remove (since 11 November 2026, see below); for a split the absolute character position in the message |
removed_span_ids, created_span_ids |
old and new span ids in reading order (CSV: joined with \|) |
removed_spans, created_spans |
the complete span records before and after (CSV: JSON string) |
dropped_votes |
every deleted vote of every rater with user_id, username, span_id, category_id, second_choice_id, is_unsure, feedback, answers_json, created_at, updated_at (CSV: JSON string) |
votes_removed, created_at |
number of deleted votes, time of the change |
dropped_measurements |
Last column (since 25 October 2026): object with timings, copilot_logs, ai_suggestion_logs; complete rows for all raters before deletion, every database column and timestamps as ISO strings. CSV: JSON string; null for older events without a snapshot. |
details |
Last column (since 11 November 2026): only for remove an object {operation: "make_context", message_index, sender_before, sender_after, labelable_before: true, labelable_after: false}; for split/merge null in JSON and empty in CSV. |
rows=votes returns the long form, one row per deleted vote:
event_id, item_id, kind, actor_user_id, actor_username,
event_created_at, user_id, username, span_id, category_id,
second_choice_id, is_unsure, feedback, answers_json (JSON string),
vote_created_at, vote_updated_at.
The JSON answer is {success, scenario_id, rows_kind, row_count, rows, citation}.
CSV cells get the same formula protection as the other exports. In the
/labeling-events export every resegmented row additionally carries
span_event_id (last column), which joins the two exports.
curl -H "X-API-Key: $K" "https://llars/api/v1/scenarios/1038/span-events" | jq '.rows[0]'
curl -H "X-API-Key: $K" -o resegmentation_votes.csv \
"https://llars/api/v1/scenarios/1038/span-events?format=csv&rows=votes"
A remove event comes from taking a message out of labeling:
removed_spans are all spans of the message, created_spans is empty,
dropped_votes and dropped_measurements as for a split.
Taking a message out of labeling¶
When an import delivered a message of the help-seeking person as a labelable
counselor turn (type 9), this endpoint turns it into context (since 11 November
2026). It removes all spans of the message, drops its index from
labelable_messages, deletes the votes, timings, co-pilot and AI logs of ALL
raters on those spans and first writes a remove event to the
span re-segmentation protocol. On request it
also sets a new sender for the message. Afterwards the spans appear neither in
/results nor in the agreement (/metrics), and anyone who has the
conversation open sees the message as context right away.
POST /api/v1/scenarios/{id}/items/{item_id}/messages/{index}/make-context
Access: scope scenario:write, and only the creator of the scenario, an admin
or the system key. Everyone else — scenario members included — gets the same
404 as for a missing scenario. index is the position of the message in the
conversation (0-based, same order as in the interface), not the import id on
the span.
Body:
| Field | Meaning |
|---|---|
dry_run |
Default true: nothing changes, the answer shows the consequences. Only false executes. |
sender |
New sender or null (unchanged). Only a value carried by a non-labelable message of the same conversation is allowed. |
expected_span_ids |
Required with dry_run: false: exactly the span_ids from the dry run. If the conversation changed in between (split/merge), the call answers 409. |
Answer (both modes, without text and without names): success, dry_run,
scenario_id, item_id, message_index, message_count, sender_before,
sender_after, messages (per message index, sender, labelable,
span_count, length = number of characters; after an execution the new
state), span_ids (of the message, in order), span_total_before,
span_total_after, labelable_messages_before, labelable_messages_after,
affected (votes, raters, decided_votes, timings, copilot_logs,
ai_suggestion_logs, ai_suggestions) and derived_copies (copies of the
conversation in derived scenarios with scenario_id, item_id,
message_index, span_count, speaker_roles). An execution also returns
span_event_id. Imported AI suggestions (ai_suggestions) stay as history;
copies in derived scenarios are only listed, never changed — they need a call
of their own.
| Status | details.code |
When |
|---|---|---|
| 404 | — | scenario foreign or unknown, conversation not in the scenario |
| 400 | not_conversation_labeling |
scenario is not type 9 |
| 400 | message_index_out_of_range |
index outside 0 … message_count-1 |
| 409 | message_not_labelable |
message is already context (nothing to do) |
| 400 | unknown_sender |
sender is not used by any context message; details.context_senders lists the allowed values |
| 400 | invalid_payload |
wrong type for dry_run, sender or expected_span_ids (details.field) |
| 409 | spans_changed |
execution without or with differing expected_span_ids; details.current_span_ids |
# 1. Dry run: look at structure and consequences
curl -s -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"sender": "<sender of the context messages>"}' \
"https://llars/api/v1/scenarios/<SCENARIO>/items/<ITEM>/messages/<INDEX>/make-context" | jq .
# 2. Execute with the span_ids from the dry run
curl -s -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"sender": "<sender of the context messages>", "dry_run": false, "expected_span_ids": ["<SPAN_1>", "<SPAN_2>"]}' \
"https://llars/api/v1/scenarios/<SCENARIO>/items/<ITEM>/messages/<INDEX>/make-context" | jq .
Paper review (type 10)¶
Since 23.10.2026 the v1 API also creates paper review scenarios: one PDF per
item, next to it a codebook questionnaire. The guide for study teams is
Paper Review. All routes in this section may only be called
by the person who created the scenario (created_by) and by admins; everybody
else gets 404. Only after that does the route check the type: a scenario of
another type answers 400.
Creating the scenario¶
Creation stays POST /api/v1/scenarios. eval_config.type is
"paper_review", eval_config.config is the codebook (questions, optional
sections, notes switch, ai_prefill block). The codebook is fully validated on
creation; a violation yields 400, with the error code in square brackets in
the message (e.g. [showIfForward]). Leave items out — the papers follow one
by one through POST …/papers.
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
https://llars/api/v1/scenarios -d '{
"name": "SLR Screening",
"eval_config": {"type": "paper_review", "config": {
"questions": [
{"id": "include", "type": "single",
"title": {"de": "Wird das Paper eingeschlossen?", "en": "Is the paper included?"},
"options": [{"id": "yes", "label": {"de": "Ja", "en": "Yes"}},
{"id": "no", "label": {"de": "Nein", "en": "No"}}]},
{"id": "exclusion_reason", "type": "text",
"title": {"de": "Grund für den Ausschluss", "en": "Reason for exclusion"},
"show_if": {"question": "include", "equals": "no"}}
]}},
"assessors": [{"username": "evaluator", "evaluation_role": "assessor"}]
}'
# → 201, scenario.evaluation_type = "paper_review", scenario.function_type_id = 10
Uploading papers¶
POST /api/v1/scenarios/{id}/papers (multipart) creates a new paper from
one PDF. Several PDFs are uploaded in several calls, so that every file
gets its own error.
| Field | Required | Meaning |
|---|---|---|
file |
yes | exactly one PDF file, at most 10 MB |
label |
no | title of the paper (≤ 500 characters); without it, the file name without .pdf |
metadata |
no | JSON object (≤ 8 KB) for the item metadata. The interface shows title, authors (list or text), year and doi |
abstract |
no | abstract (≤ 20,000 characters and ≤ 65,535 bytes UTF-8); stored as a message of the item and expandable in the interface |
curl -X POST -H "X-API-Key: $K" https://llars/api/v1/scenarios/42/papers \
-F "file=@smith2025.pdf" \
-F "label=Prompting Strategies for Counselling Chatbots" \
-F 'metadata={"authors": ["A. Smith", "B. Jones"], "year": 2025, "doi": "10.1234/abcd.5678"}' \
-F "abstract=We compare zero-shot and few-shot prompting ..."
Response 201:
{"success": true, "item_id": 517, "subject": "Prompting Strategies for Counselling Chatbots",
"document": {"id": 9, "item_id": 517, "filename": "smith2025.pdf", "mime_type": "application/pdf",
"size_bytes": 812345, "sha256": "…", "page_count": 14, "text_chars": 61234,
"extraction_status": "ok", "extraction_meta": {"…": "…"}, "uploaded_by": "researcher",
"created_at": "…", "updated_at": "…"}}
extraction_status is ok, truncated (text shortened after 500 pages or
600,000 characters), empty (scan without a text layer, accepted) or failed
(text not readable, PDF accepted). No v1 response returns bytes or full text.
Setting, replacing or removing a PDF¶
| Method & path | Response |
|---|---|
POST /api/v1/scenarios/{id}/items/{item_id}/document (multipart file) |
{success, item_id, outcome, document}; outcome is attached (the item had no PDF), replaced or unchanged (the same PDF again, no error) |
DELETE /api/v1/scenarios/{id}/items/{item_id}/document |
{success, item_id}; only the PDF goes, the item stays |
Both only work while there is no review of this item in any scenario
(otherwise 409 REVIEWS_EXIST): the PDF belongs to the item, and copied
scenarios share items. Replacing and removing also delete the item's AI
prefill, because its evidence names pages of the old PDF. A whole paper is
removed with DELETE /api/v1/scenarios/{id}/items/{item_id}, as for every
other type.
Reading the coverage¶
GET /api/v1/scenarios/{id}/paper-review/documents shows which items have a
PDF — without bytes and without full text:
{"success": true, "scenario_id": 42, "total": 3, "with_document": 2, "without_document": 1,
"by_extraction_status": {"ok": 1, "truncated": 0, "empty": 1, "failed": 0},
"items": [{"item_id": 517, "subject": "…", "document": {"filename": "smith2025.pdf", "…": "…"},
"review_count": 2},
{"item_id": 518, "subject": "…", "document": null, "review_count": 0}]}
document has the shape of the upload response. review_count counts the
review records of this scenario.
Changing the codebook¶
PUT /api/v1/scenarios/{id}/paper-review/config replaces the codebook. The body
is the codebook itself or {"config": {...}}.
{"success": true, "scenario_id": 42, "codebook_version": 2, "changed": true,
"locked": true, "reviews_recomputed": 3, "config": {"…": "…"}}
- Without reviews every valid change is allowed (
locked: false). - With reviews only additions are allowed: new questions and options, texts,
sections, a wider number range, a larger
max_length, a newallows_text. Anything else answers409 CODEBOOK_LOCKEDwithdetails.violations: [{question_id, reason, option_id?}]. reasonisquestion_removed,type_changed,option_removed,allows_text_removed,required_changed,show_if_changed,range_narrowedormax_length_reduced.- The server sets
codebook_version: + 1 when questions or sections change, otherwise unchanged. It then recomputes the status of every review (reviews_recomputed) without moving theirupdated_at.
AI prefill¶
The prefill only runs on an explicit start, never automatically. It needs
ai_prefill.enabled: true in the codebook.
| Method & path | Purpose |
|---|---|
POST /api/v1/scenarios/{id}/paper-review/prefill |
import the prefill of one external model for up to 500 papers (upsert per paper and model_key, source = import) → 201 {success, scenario_id, model_key, imported, updated, rejected} |
GET /api/v1/scenarios/{id}/paper-review/prefill |
prefill status (see below) |
DELETE /api/v1/scenarios/{id}/paper-review/prefill[?model_key=] |
delete one model's prefill, without model_key all of them → {success, scenario_id, model_key, deleted}; 409 ALREADY_RUNNING while an affected run is queued or running |
POST /api/v1/scenarios/{id}/paper-review/prefill/run |
queue a run inside LLARS, body {model_id?, item_ids?, force?} → 202 |
Import. The body has the fields model_key (A–Z a–z 0–9 _ . -, ≤ 64),
display_name (optional, ≤ 120), model_id (optional), prompt_version
(required, ≤ 64) and prefills (1–500 entries {item_id, answers,
input_chars?, input_truncated?}).
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
https://llars/api/v1/scenarios/42/paper-review/prefill -d '{
"model_key": "opus5", "display_name": "Opus 5.5", "model_id": "claude-opus-5-5",
"prompt_version": "slr-prefill-v1",
"prefills": [
{"item_id": 517, "input_truncated": false,
"answers": {"include": {"value": "yes", "confidence": "high",
"evidence": [{"page": 3, "quote": "We include all studies that"}]}}}
]
}'
Per question an entry has the shape {value, evidence: [{page, quote}], confidence}:
value is an answer value as when saving, or null (“the paper says nothing
about it”), at most five pieces of evidence with a page (from 1) and a quote
(≤ 300 characters), and confidence is high, medium or low. Only the
server sets verified, after checking every quote against the text of the
stated page; quotes shorter than 8 characters are never confirmed. Validation
is strict per entry: an invalid entry does not reject the whole call; it is
listed in rejected as {item_id, index, reason, questions?} with reason
duplicate_item, item_not_in_scenario, invalid_answers (with questions)
or no_answers.
Run. The choice is the KIZ models that the creator of the scenario may use
in the chat. Without model_id the run takes the model with the largest
context window, without item_ids all papers. Every start first deletes this
model's error rows (so a start is a retry); force: true also deletes the
finished rows and recomputes them. Papers without a text layer and papers that
are already prefilled (without force) are skipped. The 202 response carries
{queued, model_id, model_key, display_name, force, item_count, removed,
run_status}.
| Code | Status | Meaning |
|---|---|---|
no_config |
400 | the scenario has no codebook |
prefill_disabled |
400 | ai_prefill.enabled is off |
no_model |
400 | no KIZ model available |
model_not_allowed |
400 | model_id is not in the model choice |
no_items |
400 | none of the item_ids belongs to the scenario, or the scenario has no papers |
ALREADY_RUNNING |
409 | a run with this model is already queued or running |
Status. GET …/paper-review/prefill returns enabled, show_to_reviewers,
configured_model_key, prompt_version, total_items, eligible_items,
no_text_items, default_model_id, models (model_id, display_name,
context_window, model_key, is_default), runs per model_key (ok,
errors, pending, input_truncated, last_updated, running, …) and
running.
The model_key of a LLARS run is the slug of the model id without Global/,
e.g. Global/Mistral/Mistral-Medium-3.5-128B → mistral-medium-3.5-128b.
Reviewers only see display_name, never model_id. The AI never counts as a
rater in the agreement.
Error codes¶
The code is in details.code.
| Code | Status | Meaning |
|---|---|---|
not_pdf |
400 | not a .pdf file or no PDF signature |
corrupt |
400 | the PDF cannot be opened or has no pages |
encrypted |
400 | the PDF is password-protected |
too_large |
413 | larger than 10 MB or more than 2,000 pages |
DUPLICATE_DOCUMENT |
409 | the same PDF is already in the scenario; details.existing_item_id names the item |
REVIEWS_EXIST |
409 | reviews already exist for this item |
NO_DOCUMENT |
404 | the item has no PDF (when removing) |
CODEBOOK_LOCKED |
409 | a codebook change after the first review that is not an addition |
not_supported_for_paper_review |
400 | existing items on create via the legacy route POST /api/admin/create_scenario (since 13.11.2026); papers come in via POST /api/scenarios/<id>/papers |
A call without exactly one file in the file field, a label that is too
long, metadata that is too large or invalid and an abstract that is too
long answer 400.
Export¶
GET …/results keeps the long format without new columns. For each reviewer
and paper there is one row with vote_type = review (status, notes,
answers_json = {answers, answer_meta, codebook_version, document_sha256},
time_on_item_ms, active_time_on_item_ms) and, for each answered visible
question, one row with vote_type = question_answer (dimension_id = question
id, vote_value_str, vote_value_num, notes = extra text of an option, the
ai_* columns). Multiple choice appears as prompting_only;dpo in codebook
order, yes/no as true/false. Empty reviews are left out, reviews in
progress are included with status = in_progress. The AI prefill appears as
rows with voter_kind = llm (prefill + question_answer).
The JSON envelope also carries paper_review_metrics with documents (PDF
coverage, pages, bytes, extraction status), codebook_version,
review_codebook_versions (non-empty reviews per version) and ai (AI versus
human). The agreement per question is in metrics.per_question, and likewise
in GET …/metrics: per question question_id, type, n_units_total,
n_units_pairable, n_raters, headline (metric, level, value,
reason), the measures, the distribution and, for multiple choice,
per_option. Which measure counts for which question type is explained in
Paper Review › Evaluation.
Anonymization (type 11)¶
Since 02.11.2026 the v1 API also creates anonymization scenarios and delivers
their anonymized export. A case is a counselling thread that members paste,
review and sign off in the UI; the guide is
Anonymize cases. The v1 API does not create cases:
they only come from "Paste case" (internal routes below), because the server
splits the thread and starts detection at that point. Since 12.11.2026 a personal
key reaches these internal routes for pasting and checking status (section
Cases with a personal key); reviewing and signing
off stays with people. The config is changed with
PUT /api/v1/scenarios/{id}/config (section).
Create a scenario¶
Creation stays POST /api/v1/scenarios. eval_config.type is
"anonymization", eval_config.config an AnonymizationConfig.
required_reviews is required and distinguishes the config from all other
types; unknown fields give 400. Leave out items.
| Field | Values | Default |
|---|---|---|
required_reviews |
1 or 2 (four-eyes principle) — required |
— |
engine |
offline or hybrid (additionally a language model that receives the plain text) |
offline |
llm_model |
model id, required for hybrid |
null |
name_origin |
German, Swiss_DE, Swiss_FR, Swiss_IT, Swiss_RM |
German |
allow_member_import |
false: only owner, editor and admin paste cases |
true |
labels_enabled |
subset of PER, LOC, ORG, MISC, DATE, AGE, DURATION, PHONE, MAIL, PLZ, STREET, URL, IBAN, AHV, SVN, TIME, SECRET, EDU, KVNR, at least one, no duplicates; a stored list that contains all older labels automatically gains labels introduced later (DURATION) when read |
all 19 |
org_allowlist |
organizations that are kept (≤ 200 entries of ≤ 200 characters) | [] |
domain_allowlist |
domains whose URLs are kept (≤ 200 entries of ≤ 200 characters) | [] |
view_mode_default |
list or kanban |
list |
suggestion_mode |
list: realistic, invented replacements from lists (one substitute identity per person, drama numbers, example.org, identifiers with a valid check digit, invented organization names of the same kind since 2026-11-03) · placeholder: category placeholders such as [Telefon] (since 2026-11-02, T-158 wave 2) |
list |
llm_suggestions |
true allows replacement suggestions from the language model on click in the review UI (original values of people, places, streets and organizations with short excerpts are sent to the model); only a real JSON true, not "true" or 1 |
false |
llm_auto |
true fetches the language-model suggestions automatically after each detection of a case and applies the verified ones (mode llm); only effective together with llm_suggestions: true. The model is checked with the access of the person who owns the scenario; if nothing arrives, the case carries the warning LLM_AUTO_FAILED and the list values apply. Only a real JSON true (since 2026-11-03, T-169) |
false |
conversation_format |
Format of the threads: mail · chat · transcript (transcribed conversation with speaker codes such as I:/B: and time marks #00:01:02-3#). With transcript, every new case is split as a transcript: time marks are removed from the text, the time offset is stored per message as time_offset_ms and the speaker code as speaker_code; text before the first speaker (preface) is neither reviewed nor exported. Can be changed at any time; applies to future imports, not retroactively. Exactly this spelling (since 2026-11-12) |
mail |
A violation gives 400; the code is in square brackets in the message
([requiredReviews], [llmModelMissing], [unknownLabel], [noLabels],
[invalidField], [allowlistTooLong]).
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
https://llars/api/v1/scenarios -d '{
"name": "Online counselling data donation",
"eval_config": {"type": "anonymization", "config": {
"required_reviews": 2,
"engine": "offline",
"name_origin": "German",
"org_allowlist": ["Beratungsstelle Nord"],
"domain_allowlist": ["caritas.de"]
}},
"assessors": [{"username": "evaluator", "evaluation_role": "assessor"}]
}'
# → 201, scenario.evaluation_type = "anonymization", scenario.function_type_id = 11
Hybrid model
The scenario wizard and PUT /api/scenarios/<id> check for
engine: "hybrid" that llm_model is an active language model
(400 llm_model_inactive) and that the scenario owner may use it
(403 llm_model_forbidden). Since 13.11.2026 v1 creation and
PUT /api/v1/scenarios/{id}/config check the same way, and an OpenAI model
is excluded everywhere (400 llm_model_not_allowed). In hybrid mode the
plain text of every case goes to this model; that is why a personal key
neither creates a hybrid scenario nor switches on hybrid,
llm_suggestions or llm_auto (403 HUMAN_REQUIRED).
Replacement suggestions from the language model
With llm_suggestions: true the UI fetches suggestions through the internal
route POST /api/scenarios/<sid>/anonymization/cases/<iid>/suggest
({mode: "list"|"llm", group_keys?, version}; nothing is saved, 10 requests
per person and minute). The model is llm_model, otherwise the server
variable ANONYMIZE_SUGGEST_LLM_MODEL, otherwise the default LLM; the route
rejects OpenAI models. The v1 API does not call the route itself. See
Anonymize cases › Replacement values and suggestions.
Export¶
curl -H "X-API-Key: $K" -o donation.json \
"https://llars/api/v1/scenarios/42/anonymization/export?status=done&format=json"
curl -H "X-API-Key: $K" -o donation.csv \
"https://llars/api/v1/scenarios/42/anonymization/export?status=all&format=csv"
| Parameter | Values | Default |
|---|---|---|
status |
done: signed-off cases only · all: every case with finished detection, whatever its sign-off state. Cases still detecting or failed are always left out. |
done |
format |
json or csv |
json |
The response is a download (Content-Disposition: attachment;
filename="anonymization_<id>_<status>.json|csv", Cache-Control: private,
no-store). Only the person who created the scenario (created_by) and admins
may call it; everybody else gets 404, as does a scenario of another type.
JSON (schema llars-anonymization-export-v1):
{
"schema": "llars-anonymization-export-v1",
"scenario_id": 42,
"exported_at": "2026-11-02T20:15:00Z",
"status_filter": "done",
"required_reviews": 2,
"case_count": 1,
"cases": [{
"case_id": 1501,
"case_status": "done",
"subject": "Stress am Arbeitsplatz",
"message_count": 3,
"messages": [{"index": 0, "role": "client", "timestamp_shifted": "2023-08-14T18:00:00",
"content_anonymized": "Guten Abend, …", "time_offset": null}],
"entities_summary": {"total": 9, "dismissed": 1, "by_label": {"ORG": 3, "PER": 5}},
"signoffs": [{"username": "evaluator", "signed_at": "2026-11-02T19:40:12"}]
}]
}
case_idis the item id,case_statusone ofto_review(untouched),editing(someone saved a decision since detection, nobody has signed off yet),partially_signed,done. Withstatus=donethe export only holdsdonecases.subjectandcontent_anonymizedare computed freshly from the current decision state;roleisclientorcounselor.timestamp_shiftedis the message timestamp plus a random shift per case (one day to about five years back; intervals are preserved) ornull. Transcripts have no timestamp (null).time_offset(since 2026-11-12) is, for transcripts, the offset of the turn since the start of the conversation as"HH:MM:SS.t"(tenths of a second, from the last time mark of the turn), otherwisenull. It is not shifted.entities_summary: all markings (total), discarded ones (dismissed) and active ones per label (by_label).signoffslists only sign-offs of the current version.- Never in the export: original text, original values, group table, the date shift, participant names, signatures, speaker codes, the preface of a transcript and the remaining parser metadata.
CSV: UTF-8 with BOM, separator ;, one row per message:
case_id;case_status;message_index;role;timestamp_shifted;subject;content_anonymized;time_offset
(time_offset since 2026-11-12 as the last column, empty for e-mail and chat).
For type 11, GET …/results returns no votes but rows: [] with
note: "use /anonymization/export".
Cases with a personal key¶
Since 12.11.2026 these internal routes also accept a personal key (base
/api/scenarios/{sid}/anonymization):
| Method & path | Scope | Purpose |
|---|---|---|
GET /api/anonymization-cases/scenarios |
scenario:read + feature:anonymization:view |
The person's type-11 scenarios with counts per status |
GET …/cases |
scenario:read |
Cases as summaries with counts (?status=) |
GET …/cases/{iid}?summary=1 |
scenario:read |
Summary of one case |
POST …/parse |
scenario:write |
Preview of a thread (JSON {text, mode?} or file file); nothing is stored |
POST …/cases |
scenario:write |
Create a case ({raw_text, source_format, mode, fingerprint, roles?, subject?} from the preview) → 201 |
POST …/cases/{iid}/redetect |
scenario:write |
Restart detection ({force?}) → 202 |
After that the same rights apply as in the UI: member of the scenario (otherwise
403), item in the scenario (otherwise 404), write and import rights for
pasting (403 READ_ONLY or IMPORT_NOT_ALLOWED). Whoever pastes a case with the
key appears as that person on the case. The scope scenario:write requires the
permission data:manage_scenarios; assessors without it keep pasting cases in
the UI only. A case pasted with a key earns no points for pasting in the level
system (since 13.11.2026); a person's sign-off on it counts like any other.
These limits apply to keys only:
- Summaries contain no case text for ANY key, including the system key (since
13.11.2026).
preview_line(first line of the conversation),subject(original subject),source_filenameanddetection_errorare missing;detection_error_codestays. This applies to the case list,?summary=1and the answers ofPOST …/casesand…/redetect. It is the same selection the socket leaves out. The UI gets the fields unchanged. - The case detail with original texts (
GET …/cases/{iid}withoutsummary=1) answers a personal key with403 SUMMARY_ONLY. - Saving decisions, rolling a replacement, fetching suggestions and sign-offs
(
PUT …/decisions,POST …/replacement,POST …/suggest,POST/DELETE …/signoff) are human review work. Every key, including the system key, gets403 HUMAN_REQUIREDthere; an invalid key gets401. POST …/redetectwith{"force": true}deletes all sign-offs and manual decisions. A personal key gets403 HUMAN_REQUIREDfor it (since 13.11.2026). Withoutforce,409 MANUAL_DECISIONS_EXISTstill applies when there are manual decisions or sign-offs.
The lock on review work stops keys as a channel, not someone who holds the system key. With it, accounts with a password can be created and password links generated, and whoever signs in with them is a signed-in person for LLARS. That limit rests on operational discipline and the record of new accounts, not on the code.
Deleting a case and the internal export stay with sessions and the system key; for the export there is the v1 route above.
Error codes¶
The code is in details.code. The v1 export only knows 400 invalid_request
(details.field = status or format) and 404. The other codes come from
the internal UI routes under /api/scenarios/<sid>/anonymization/… (paste,
review, sign off); they are listed here so that scripts and bug reports can
place them.
| Code | Status | Meaning |
|---|---|---|
empty_text, text_too_long, too_many_messages, message_too_long |
400 | text empty, > 200,000 characters, > 400 messages, one message > 60,000 bytes |
multiple_cases, invalid_json |
400 | JSON file with several threads, or invalid JSON |
text_unsupported |
400 | more than 30 combining characters (accents etc.) in a row in the text (details.max = 30, since 13 Nov 2026); for the subject of …/cases additionally details.field = "subject" |
unsupported_file |
400 | file type not TXT/PDF/DOCX/JSON, or content does not match the extension |
extraction_failed |
400 | file text not readable; details.reason = too_large (too many entries, too large when unpacked, PDF with too many pages), too_complex (DOCX above a structure cap), corrupt (broken or encrypted) or empty (no text, e.g. a scan); when a DOCX is rejected before reading, details.limit names the cap (elements, paragraphs, table_cells, grid_cells, vmerge_steps, reread_elements, styles, relationships, entries, uncompressed_bytes, zip, encrypted); on an unexpected read error details.reason is missing |
file_too_large |
413 | file > 10 MiB (details.max) |
DUPLICATE_CASE |
409 | the same thread is already in the scenario (details.existing_item_id) |
PARSE_CHANGED |
409 | on import the text splits differently than in the preview |
READ_ONLY, IMPORT_NOT_ALLOWED, DELETE_NOT_ALLOWED |
403 | read access only · pasting reserved for managers · deletion not allowed |
HUMAN_REQUIRED |
403 | decisions, rolling, suggestions and sign-offs with an API key (system or personal) — UI only (since 12.11.2026); since 13.11.2026 also …/redetect with force and switching on a language-model way (hybrid, llm_suggestions, llm_auto, another llm_model) with a personal key (details.destinations) |
SUMMARY_ONLY |
403 | case detail with a personal key; only ?summary=1 (since 12.11.2026) |
VERSION_CONFLICT |
409 | someone saved the case in the meantime (details.current_version, details.updated_by) |
DETECTION_NOT_DONE, DETECTION_RUNNING |
409 | detection not finished yet, or running right now |
MANUAL_DECISIONS_EXIST |
409 | "Detect again" without force while manual decisions or sign-offs exist |
LEAKS_PRESENT |
409 | sign-off with open leaks (details.leak_count) |
entity_offset_mismatch, entity_overlap, unknown_label, invalid_decisions, too_many_entities, decisions_too_large, replacement_too_long |
400 | invalid decision state (offsets, overlap, label, shape, > 5,000 markings, > 2 MB, replacement > 200 characters) |
not_randomizable |
400 | "Randomize" only for PER, LOC, AGE |
not_anonymization_scenario, invalid_request |
400 | scenario is not type 11, or the request has the wrong shape (details.field) |
use_anonymization_routes |
400 | POST /api/evaluation/session/<sid>/items/<iid>/evaluate for a type-11 scenario |
not_supported_for_anonymization |
400 | batch generation (also type-11 scenarios or cases as the source of a generation job, since 13.11.2026), duplicating, adding items, existing items on create via POST /api/admin/create_scenario and the generic UI export do not support type 11 (for the schema export the code is in the message) |
invalid_config |
400 | invalid config when creating in the wizard, on PUT /api/scenarios/<id> or through the legacy routes POST /api/admin/create_scenario and /api/admin/edit_scenario (details.errors = codes such as requiredReviews); PUT /api/v1/scenarios/<id>/config reports schema errors in the v1 format instead (details.errors with loc/msg) |
llm_model_inactive, llm_model_forbidden |
400 / 403 | hybrid model not active, or the owner has no access (wizard, v1 create, PUT /api/scenarios/<id>, PUT /api/v1/scenarios/<id>/config, legacy routes); for …/suggest the same for the suggestion model and the requesting person |
LLM_SUGGESTIONS_DISABLED |
403 | …/suggest with mode: "llm" while llm_suggestions is off |
llm_model_not_allowed |
400 | an OpenAI model as hybrid model (since 13.11.2026: on create and every config change) or as suggestion model for …/suggest — counselling content never goes to OpenAI |
unknown_group, too_many_groups |
400 | …/suggest: unknown group key, or more than 80 groups |
rate_limited |
429 | …/suggest: more than 10 requests per person and minute; …/parse and …/cases (create): more than 120 requests each per person and minute (since 13 Nov 2026). Counted per server process |
Support tickets with a personal key¶
Since 12.11.2026 a personal key reaches the ticket routes under /api/tickets
(guide: Support tickets). Reading needs tickets:read
(list, counters, detail, history, downloading attachments), writing needs
tickets:write (report, change, comment, add files). Both scopes require the
permission feature:tickets:view; the support-team routes (/assignees,
/transcriptions/retry, /{ref}/ai-title) additionally require
feature:tickets:manage.
Whoever reports or comments with their own key acts as themselves: creator and
author are the person, author_type and actor_type are human. Only the
system key writes as agent. Other people's tickets answer 404, as in the UI.
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"title": "Export fails", "description": "…", "category": "bug"}' \
https://llars/api/tickets
curl -H "X-API-Key: $K" "https://llars/api/tickets?scope=mine&status=new"
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
-d '{"body": "Addendum: only happens with CSV."}' https://llars/api/tickets/T-42/comments
Online experiment (type 12)¶
Since 2026-11-12 the study module (anonymous participation via invite links) is
scenario type 12 online_experiment; the guide is
Online experiment. The v1 API knows the type but does not
create it:
POST /api/v1/scenarioswitheval_config.type = "online_experiment"answers 400 (the message namesnot_supported_for_experiment). An online experiment is created only in the scenario wizard ("Empty online experiment").GET /api/v1/scenariosandGET /api/v1/scenarios/{id}report the type asonline_experiment(function_type_id = 12).GET /api/v1/scenarios/{id}/resultsreturns no rows butrows: []withnote: "use /api/scenarios/<id>/experiment/export".DELETE /api/v1/scenarios/{id}answers 409EXPERIMENT_HAS_DATAas long as a collection of the experiment has a participation or a withdrawal; without data only the bindings go, the collections stay.
Scripts fetch the data through the scenario routes
/api/scenarios/<id>/experiment/export… with the bearer token of a signed-in
session as owner or editor of the experiment (overview under
Online experiment › For scripts); a v1 key
with a scope is not enough there. Only operations uses the system API key: it
counts as an admin across LLARS and does not belong in researchers' scripts.
Conversation annotation (type 13)¶
Since 20.11.2026 the v1 API creates scenarios of type 13
conversation_annotation. An item is a whole conversation, optionally with a
profile from the item metadata next to it. Raters mark passages with labels and
answer questions per conversation. The guide for study teams is
Conversation annotation. The v1 API is the only way
to create such a scenario. The scenario wizard does not offer the type.
Creating the scenario¶
Creation is POST /api/v1/scenarios with eval_config.type =
"conversation_annotation". eval_config.config is a
ConversationAnnotationConfig. Unknown fields give 400. The example creates a
scenario with two labels. Only messages of the role Klient can be marked. The
profile lives in metadata.persona_profile, and the label
contradiction_profile may have passages in the profile. Both questions have
their own answer texts. The one conversation has three messages.
{
"name": "ViKl Brauchbarkeit Pilot",
"description": "Simulierte Klient:innen: brauchbar als Simulation der Person?",
"eval_config": {
"type": "conversation_annotation",
"config": {
"instructions": {
"de": "Lies das ganze Gespräch und das Profil. Markiere jede Stelle, an der die Klientin aus der Rolle fällt oder dem Profil widerspricht.",
"en": "Read the whole conversation and the profile. Mark every passage where the client breaks role or contradicts the profile."
},
"annotation": {
"labels": [
{
"id": "repetition",
"name": {"de": "Wiederholung", "en": "Repetition"},
"description": {"de": "Die Person wiederholt sich fast wörtlich.", "en": "The person repeats themselves almost verbatim."},
"color": "#E8A087",
"max_spans": 20
},
{
"id": "contradiction_profile",
"name": {"de": "Widerspruch zum Profil", "en": "Contradicts the profile"},
"description": {"de": "Markiere die Stelle im Chat und die Stelle im Profil.", "en": "Mark the passage in the chat and the passage in the profile."},
"color": "#7FA7D9",
"allow_context_spans": true
}
],
"annotatable_roles": ["Klient"],
"max_annotations": 200,
"notes": true
},
"context_panel": {
"enabled": true,
"metadata_key": "persona_profile",
"title": {"de": "Profil der ratsuchenden Person", "en": "Client persona"},
"format": "markdown",
"annotatable": true,
"default_open": true
},
"questions": [
{
"id": "usable",
"type": "single",
"title": {"de": "Ist das Gespräch als Simulation dieser Person brauchbar?", "en": "Is the conversation usable as a simulation of this person?"},
"help": {"de": "Denke an eine Schulung: Würdest du es dort einsetzen?", "en": "Think of a training session: would you use it there?"},
"options": [
{"id": "yes", "label": {"de": "Ja, brauchbar", "en": "Yes, usable"}},
{"id": "with_edits", "label": {"de": "Nur mit Änderungen", "en": "Only with edits"}},
{"id": "no", "label": {"de": "Nein, nicht brauchbar", "en": "No, not usable"}}
]
},
{
"id": "role_breaks",
"type": "single",
"title": {"de": "Wie oft fällt die Person aus der Rolle?", "en": "How often does the person break role?"},
"options": [
{"id": "never", "label": {"de": "Nie", "en": "Never"}},
{"id": "once", "label": {"de": "Einmal", "en": "Once"}},
{"id": "often", "label": {"de": "Mehrmals", "en": "Several times"}}
]
}
],
"notes_enabled": true
}
},
"items": {
"schema_version": "1.0",
"items": [
{
"id": "G001",
"label": "Gespräch G001",
"source": {"type": "llm", "name": "client-simulator-v3"},
"content": {
"type": "conversation",
"messages": [
{"role": "Berater", "content": "Hallo, schön, dass du schreibst. Was beschäftigt dich gerade?"},
{"role": "Klient", "content": "Ich unterrichte seit zehn Jahren an derselben Schule und schlafe seit Wochen schlecht."},
{"role": "Berater", "content": "Das klingt anstrengend. Was hält dich nachts wach?"}
]
},
"metadata": {
"persona_profile": "# Profil\n\n- **Alter:** 34\n- **Beruf:** Pflegekraft, seit zwei Monaten in einer neuen Klinik\n- **Anliegen:** Schlafprobleme und Überforderung"
}
}
]
},
"assessors": [
{"username": "evaluator", "evaluation_role": "assessor"}
]
}
curl -X POST -H "X-API-Key: $K" -H "Content-Type: application/json" \
https://llars/api/v1/scenarios -d @scenario.json
# → 201, scenario.evaluation_type = "conversation_annotation", scenario.function_type_id = 13
Config rules:
| Part | Rule |
|---|---|
annotation.labels |
1–20 labels. id from a–z, 0–9, _, - (at most 40 characters, unique), name with de and en, description optional (at most 2,000 characters), color optional #RRGGBB, max_spans 1–50 (default 20), allow_context_spans default false |
annotation.annotatable_roles |
roles whose messages can be marked (at most 20, compared without case and surrounding spaces). Empty means all roles |
annotation.max_annotations |
1–500 per conversation and person, default 200 |
annotation.notes |
note per annotation allowed, default true |
context_panel |
optional. metadata_key from A–Z, a–z, 0–9, _, ., - (at most 64 characters), format only markdown, annotatable default false, default_open default true |
questions, sections |
the same questions and rules as the paper review codebook, at least one required question without show_if |
instructions |
optional, Markdown with de and en, at most 20,000 characters |
notes_enabled |
note on the conversation (at most 8,000 characters), default true |
Passages in the profile are only possible if context_panel.annotatable is set
AND the label has allow_context_spans.
Items¶
Every item is a conversation with content.type = "conversation" and at least
one message. With an active context_panel, every item needs the profile text
as a non-empty string in metadata[metadata_key]. The order of messages is
the reading order. The position of a message in it (from 0) is later called
message_index.
LLARS checks all items before it writes anything and reports all errors at once:
{
"success": false,
"error": "conversation_annotation items invalid (invalid_items): metadata['persona_profile'] must be a non-empty string — items: G002, G007",
"error_type": "validation_error",
"details": {
"code": "invalid_items",
"items": [
{"item_id": "G002", "reason": "missing_context"},
{"item_id": "G007", "reason": "missing_context"}
]
}
}
reason is not_a_conversation (content is not a conversation), no_messages
(no message) or missing_context (profile text missing or empty).
POST /api/v1/scenarios/{id}/items adds more conversations. The body is the bare
LlarsNativeEnvelope as in Appending items later, the
check is the same. Since 20.11.2026 this route answers rejected items with 400
instead of 500.
Changing the config¶
PUT /api/v1/scenarios/{id}/config replaces the config and checks it as on
creation (section). There is no lock after
the first annotations yet. Stored annotations of a removed label are kept and
appear in the agreement with in_config: false.
Rating (interface)¶
Raters work in the interface under /scenarios/{id}/evaluate. The interface
uses two internal routes of the rating session. Both are for members of the
scenario only and show every person only their own state.
| Route | Purpose |
|---|---|
GET /api/evaluation/session/{id}/items/{item_id}/conversation-annotation |
Load one conversation: all messages (index, message_id, role, content, timestamp, annotatable), the profile as raw Markdown (context) and the own state (state) |
POST /api/evaluation/session/{id}/items/{item_id}/evaluate |
Save the whole state: {function_type: "conversation_annotation", answers, answer_meta, annotations, notes, timing} |
A passage in the body is {source: "message", message_index, start, end, text}
or {source: "context", start, end, text}. The server computes text itself
from content and offsets. A text sent along that does not match gives
400 span_text_mismatch. Other error codes in details.code:
invalid_annotation, duplicate_uid, unknown_label, too_many_annotations,
too_many_spans, message_index_out_of_range, role_not_annotatable,
span_out_of_range, context_not_annotatable, payload_too_large
(annotations above 256 KB), notes_too_long, invalid_answer,
unknown_question, answers_too_large and function_type_mismatch.
Export¶
GET /api/v1/scenarios/{id}/results keeps the long format without new columns.
Per person and conversation with status in_progress or done there are these
rows:
vote_type |
Important columns |
|---|---|
review |
exactly one per person and conversation: status, notes = note on the conversation, answers_json = {answers, answer_meta, annotation_count}, active_time_on_item_ms, created_at/updated_at of the state |
question_answer |
per answered visible question: dimension_id = question id, vote_value_str, vote_value_num, notes = extra text of an option with allows_text |
annotation |
per annotation: vote_value_str = label_id, notes = note of the annotation, answers_json = annotation as JSON text, created_at/updated_at of the annotation, status = status of the conversation |
All rows carry scenario_id, function_type = "conversation_annotation",
item_id, item_label, voter_id, voter_username and time_on_item_ms. An
annotation row in JSON format looks like this (excerpt, empty columns left
out):
{
"scenario_id": 1321,
"function_type": "conversation_annotation",
"item_id": 9001,
"item_label": "Gespräch G001",
"voter_kind": "human",
"voter_id": 17,
"voter_username": "evaluator",
"vote_type": "annotation",
"vote_value_str": "contradiction_profile",
"status": "done",
"notes": "Im Profil Pflegekraft, im Chat Lehrerin.",
"answers_json": "{\"uid\": \"8c0e4f6a-1d2b-4c3d-9e8f-0a1b2c3d4e5f\", \"label_id\": \"contradiction_profile\", \"note\": \"Im Profil Pflegekraft, im Chat Lehrerin.\", \"spans\": [{\"source\": \"message\", \"message_index\": 1, \"message_id\": 5121, \"role\": \"Klient\", \"start\": 0, \"end\": 52, \"text\": \"Ich unterrichte seit zehn Jahren an derselben Schule\"}, {\"source\": \"context\", \"start\": 39, \"end\": 91, \"text\": \"Pflegekraft, seit zwei Monaten in einer neuen Klinik\"}], \"created_at\": \"2026-11-20T14:03:12.123\", \"updated_at\": \"2026-11-20T14:05:40.871\"}",
"created_at": "2026-11-20T14:03:12.123",
"updated_at": "2026-11-20T14:05:40.871"
}
start and end count Unicode code points. For source = "context" they count
in the raw Markdown text from metadata[metadata_key]. The row columns
message_id, span_id and span_index stay empty. The passages are only in
answers_json.
The JSON envelope also carries conversation_annotation_metrics:
{
"scenario_id": 1321,
"task_type": "conversation_annotation",
"rater_count": 2,
"raters": ["human:17", "human:18"],
"item_count": 103,
"metrics": {"n_units_pairable": {"value": 40}, "n_labels_computable": {"value": 2}},
"questions": [{"question_id": "usable", "type": "single", "n_units_pairable": 40, "n_raters": 2,
"headline": {"metric": "krippendorff_alpha", "level": "nominal", "value": 0.52, "reason": null}}],
"labels": [
{"label_id": "contradiction_profile", "name": {"de": "Widerspruch zum Profil", "en": "Contradicts the profile"},
"in_config": true, "level": "nominal", "krippendorff_alpha": 0.41, "percent_agreement": 77.5,
"prevalence": 0.3125, "n_items": 40, "n_positive": 25, "n_annotations": 61, "n_raters": 2,
"computable": true, "reason": null}
]
}
The example is shortened. Every question block has the same shape as
metrics.per_question for paper review (see
Paper review › v1 API). Per label it counts
whether a person set at least one annotation with this label in the
conversation. n_items are the conversations with at least two finished
judgements. reason is too_few_units, no_variation or null. Only finished
conversations of active raters count. Without any finished judgement it holds
{"error": "No evaluations found"}. The same lists are under
metrics.questions and metrics.labels and in GET /api/v1/scenarios/{id}/metrics.
Validation & errors¶
Failed requests follow the LLARS standard envelope:
{
"error": "Invalid request body — eval_config.config: ...",
"details": {"errors": [{"loc": ["eval_config", "config"], "msg": "...", "type": "value_error"}]}
}
details.errors lists every error. For POST /api/v1/scenarios, errors outside the config (e.g. a missing name) come first, then those of the requested type (eval_config.type, e.g. RatingConfig), then those of the other config classes; the headline names the first of them (since 13.11.2026).
| Status | Trigger |
|---|---|
| 400 | Body violates schema (e.g. type=rating with SimpleRankingConfig) |
| 401 | Missing / invalid API key or token |
| 403 | Scope insufficient (scenario:read key tries POST); also HUMAN_REQUIRED and SUMMARY_ONLY (type 11) and llm_model_forbidden (a model for the co-pilot, LLM evaluators or hybrid that the owner may not use) |
| 404 | Scenario / user / slug not found |
| 409 | Owner conflict (member already exists; cannot demote last owner) |
| 413 | PUT …/config with a body above 1 MiB (config_too_large, since 13.11.2026) |
eval_config.config must match eval_config.type (rating ↔ RatingConfig, comparison ↔ ComparisonConfig, …). The schema cross-validates both.
Notes¶
- Items follow the LLARS-Native format (
schema_version: "1.0"). Reference + item structure are documented inapp/schemas/evaluation_data_schemas.py. - The API key owner is automatically added as
manager_role='owner'when one-shot-creating a scenario. referral_link.slugis the idempotency axis: the same slug repointed across re-seedings keeps the external URL stable.DELETE /scenarios/{id}cleans up orphanEvaluationItems(and their features + messages); items still linked to other scenarios are preserved.