API docs

Migrating from Jev

Use this checklist before switching traffic:

  1. Set TYPESAFE_BASE_URL to your Jein origin and TYPESAFE_API_KEY to a Jein API key. Keep your existing systemOne or system_one call.
  2. Use jev-latest (the SDK default), jev-preview, jev-1.13.0, or laya-latest for language routing. English resolves to laya-0.3.20; detected non-English resolves to laya-multilingual-0.3.20. To select a checkpoint explicitly use laya-0.3.20, laya-multilingual, or laya-multilingual-0.3.20. See models.
  3. Measure every question's state room. English has a 512-token sequence; the exact room is 511 − len(head + options sequence) for that question. Simple choice and noul questions leave about 476 state tokens. Multilingual has a 2048-token window and about 1975–2014 state tokens of room. Longer instructions and options reduce either limit.
  4. Split long state into smaller, self-contained chunks and send only the relevant chunk per call. Jein rejects state that would truncate; it never silently cuts it.
  5. Keep each call at or below 32 questions and the selected model's processed-token cap: 3,500 English or 6,000 multilingual. The processed cost is number of questions × longest per-question Laya sequence length, so many questions with long states hit the cap sooner. A 32-question call can exceed the SDK's 10-second default timeout on a busy CPU worker; prefer smaller batches.
  6. Handle 402 monthly free allowance exhaustion by checking /app/usage and waiting for the UTC reset, or email [email protected]. Jev does not have this response.
  7. Handle 429 account rate/in-flight limits and 529 worker busy/startup with Retry-After and retry-after-ms; branch on x-jein-error-code. The SDK retries these by default, so set an overall deadline.
  8. Compare outputs: Jein answers carry no Jev action object (action.act_probability), and noul answers carry no confidence; read noul directly. Multilingual confidence is uncalibrated, and its English quality was lower in a 12-case check. The two checkpoints use different tokenizers, so token counts and state limits differ. The model card evaluates about 50 languages; its “100+” claim is unverified.
  9. Pin SDK versions while migrating: Python typesafe-sdk==0.7.1; JavaScript @typesafe-ai/[email protected]. Roll back by restoring the previous Jev base URL and Jev key; keep keys separate.

GET /v1/models lists every name a request may use, including the jev-latest (SDK default), jev-preview, and jev-1.13.0 compatibility aliases, so a client can validate against it. Existing SDK calls and the /v1/systemone route are unchanged.

To check a state before switching, paste it into the Sandbox for a token count, or send the request: if the state does not fit, the state_too_long error tells you the room each question leaves.

Try the migrated request locally:

curl --fail --silent "$TYPESAFE_BASE_URL/v1/systemone" -H "Authorization: Bearer $TYPESAFE_API_KEY" -H 'Content-Type: application/json' -d '{"model":"jev-latest","state":"Hi, I was billed twice for March. Please refund the duplicate.","questions":{"department":{"type":"choice","instructions":"Which team should handle this?","criteria":{"billing":"Payment issues","technical":"Bugs","sales":"Sales questions"}}}}' | python3 -c 'import json,sys; r=json.load(sys.stdin); assert r["model"] == "laya-multilingual-0.3.20" and "department" in r["answers"]'
Next: Limits