Skip to content

Score level limits: the API enforces at most 10 levels, but the OpenAPI schema has no maximum, and a single level is accepted #6

Description

@vbcherepanov

Score level limits: the API enforces at most 10 levels, but the OpenAPI schema has no maximum, and a single level is accepted

What the docs say (API reference → ScoreQuestion): "A Score should have at least two levels; the API accepts up to 10."

What the OpenAPI schema says (https://api.typesafe.ai/openapi.json, ScoreQuestion.criteria): "type": "array", "minItems": 1, with no maxItems.

What the API does (checked 2026-09-21, jev-latest → jev-1.13.0):

for n in 1 2 10 11; do
  L=$(python3 -c "import json;print(json.dumps([f'level {i}' for i in range($n)]))")
  curl -s -w " HTTP %{http_code}\n" https://api.typesafe.ai/v1/systemone \
    -H "Authorization: Bearer $TYPESAFE_API_KEY" -H "Content-Type: application/json" \
    -d "{\"model\":\"jev-latest\",\"state\":\"The service is down for all users.\",\"questions\":{\"s\":{\"type\":\"score\",\"instructions\":\"How severe?\",\"criteria\":$L}}}"
done
levels status body
1 200 "score":0.0,"confidence":1.0,"probabilities":{"0":1.0}
2 200 normal answer
10 200 normal answer
11 400 {"detail":"Too many score levels. Must have at most 10 levels."}

Why it matters

  • The maximum is enforced but absent from the schema, so clients generated from openapi.json cannot catch it, and it surfaces as a 400 that the error table does not list (see Docs report: request-body validation returns 400, but the API reference documents 422 #1).
  • A one-level Score always returns confidence: 1.0 without looking at the state. It is accepted silently, so a caller who builds levels dynamically gets a confident, meaningless answer instead of an error.
  • The SDKs disagree on the minimum: the Python SDK accepts one level (questions.py), the JS SDK requires two (questions.ts).

Suggested fix

  • Add "maxItems": 10 to ScoreQuestion.criteria.
  • Either reject fewer than two levels (and set "minItems": 2), or document that a single level is allowed and always returns confidence 1.0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions