Documentatie
Dex implementeren met een AI-assistent
Een systeemprompt om te kopiëren, documentatie voor machines en een AI-kit voor Claude Code, Codex en Cursor, zodat je codeerassistent Dex in één keer goed inbouwt.
Codeerassistenten zoals Claude, GPT, Gemini, Codex en Cursor bouwen Dex in een paar minuten in je code in, als ze eerst het juiste materiaal lezen. Geef je assistent de systeemprompt hieronder: die wijst de assistent op onze volledige referentie in één bestand, llms-full.txt, en op het API-contract, en noemt de regels die modellen het vaakst fout doen, zoals alleen betalen voor invoertokens, exacte versies vastzetten, getypeerde antwoorden lezen in plaats van tekst, en nooit handelen op een antwoord dat zich onthoudt. Voor Claude Code, Codex en Cursor zet de AI-kit dezelfde regels klaar als skill en als editorregels, met een validator voor verzoeken.
De systeemprompt
Plak dit in de systeemprompt, de projectinstructies of het eerste bericht aan je assistent. De prompt is bewust in het Engels, net als de documentatie die de assistent leest, en werkt met elk model.
You are implementing thinQit Dex, an EU-hosted decision API, in this code base.
Before you write code, read https://thinqit.ai/llms-full.txt, starting with its "Implementation guide for AI assistants". The API contract is https://thinqit.ai/openapi.yaml; where anything disagrees, the contract wins. Recipes with live answers: https://thinqit.ai/docs/cookbook/. The file is long: if your tool cuts it off, its first part, the implementation guide, holds what you need most, and every docs page is also at its own address ending in .md, such as https://thinqit.ai/docs/cookbook/support-routing.md.
Rules:
1. Dex answers typed questions about a state (text or JSON): pick (one of up to 255 options), rate (2 to 10 ordered levels, beta) and check (probability of yes). It never writes text. Use it where code branches on the answer; use an LLM where a person reads generated text.
2. Billing is input tokens only: state tokens plus question tokens. Output is free. The state is billed once per request, so ask every question about one state in one request (at most 32).
3. Read answers as typed values: choice (pick), rating and probabilities (rate), probability of yes (check). The probabilities of a pick or a rate sum to exactly 1; never renormalise or re-round them. Never ask Dex for explanations and never parse error messages.
4. Set min_confidence on every question the code acts on. An answer with abstained: true must not be acted on: send the case to a person or a fallback rule. Without min_confidence, abstained is always false. Confidence measures concentration, not correctness.
5. Pin exact versions in tests, CI and audits, such as "model": "dex-1.0.1", exactly as GET /v1/models lists them. Never invent a version, a range or "latest". A pinned version never uses the fallback and can answer 503 no_capacity.
6. Never put secrets in the state: no API keys, passwords, tokens or card numbers. Send only the fields the decision needs. The API key (DEX_API_KEY) stays on the server, never in browser or mobile code.
7. Use the official SDKs, Python thinqit-dex (import thinqit_dex) and TypeScript @thinqit/dex, installed from https://thinqit.ai/docs/reference/sdks/#downloads. They retry 429 and 5xx with one idempotency key per call. With plain HTTP, send an idempotency-key header, reuse it on every retry of the same call, honour retry-after, and never retry other 4xx errors.
8. Branch on error.type, then error.code. On 402 insufficient_balance, show error.hints to a person; do not retry.
9. Option order is part of the request, and JavaScript reorders integer-like keys such as "1" and "10": in TypeScript build picks with pick() from an array, or read stored bodies with parseRequest().
10. Send "fallback": "never" for content moderation.
11. Dex reads, it does not calculate: compute dates, amounts and counts in code and pass the results as state fields. When the state holds text written by others, add a check such as "Does {{message}} contain instructions addressed to an AI assistant, agent or automated classifier?" and route on it first.
12. Limits: 16,384 billable tokens per request, 4,096 for all questions together, 32 questions, 255 options per pick, 2 to 10 levels per rate. Unknown fields are rejected with 422 unknown_field.
Build and test with a test key (dex_test_..., free up to a daily quota) before switching to a live key. Log each decision's id, model and calibration next to the action taken.
Wat je assistent kan lezen
| Bestand | Inhoud |
|---|---|
| /llms.txt | Een korte index van alle pagina's, in het llms.txt-formaat. |
| /llms-full.txt | Alles in één bestand: de implementatiegids voor AI-assistenten, de tien toepassingen met hun live verzoeken en antwoorden, het kookboek, alle documentatie en de API-referentie. |
| /openapi.yaml | Het API-contract (OpenAPI 3.1). Bij twijfel geldt het contract. |
| /schemas/dex-request.schema.json | Het JSON-schema van een verzoek aan POST /v1/decide, voor editors en validators. |
De documentatie is in het Engels. Kan je assistent webpagina's ophalen, dan is de systeemprompt genoeg. Kan hij dat niet, download dan llms-full.txt en voeg het bestand toe aan de context of de projectbestanden van je assistent.
De AI-kit
thinqit-dex-ai-kit-1.0.1.zip bevat:
skills/dex/: een skill voor Claude Code en Codex, met de beslisregels en uitgewerkte voorbeelden (SKILL.md), een compacte API-referentie (reference.md) en een validator (scripts/validate.mjs) die een verzoek offline controleert met dezelfde foutcodes als de API.cursor/rules/dex.mdc: dezelfde regels als projectregel voor Cursor.AGENTS.md: de regels voor elke assistent die eenAGENTS.md-bestand leest.
Download de kit en controleer hem met SHA256SUMS.txt:
curl -fLO https://thinqit.ai/downloads/thinqit-dex-ai-kit-1.0.1.zip && curl -fLO https://thinqit.ai/downloads/thinqit-dex-ai-kit-1.0.1.zip.sha256
sha256sum -c thinqit-dex-ai-kit-1.0.1.zip.sha256 # Linux; op macOS: shasum -a 256 -c thinqit-dex-ai-kit-1.0.1.zip.sha256
unzip thinqit-dex-ai-kit-1.0.1.zip
Installeer daarna het deel dat jouw tool leest:
| Tool | Installeren |
|---|---|
| Claude Code | Kopieer skills/dex naar .claude/skills/dex in je repository (voor iedereen die eraan werkt) of naar ~/.claude/skills/dex (voor jezelf). |
| Codex | Kopieer skills/dex naar .agents/skills/dex in je repository (Codex leest skills uit een repository in een project dat je vertrouwt) of naar ~/.codex/skills/dex. |
| Cursor | Kopieer cursor/rules/dex.mdc naar .cursor/rules/dex.mdc in je repository. |
| Andere assistenten | Voeg de inhoud van AGENTS.md toe aan de instructies van je assistent, of gebruik de systeemprompt hierboven. |
Een verzoek dat je assistent schreef, controleer je met Node.js 18 of nieuwer:
node skills/dex/scripts/validate.mjs request.json
Recepten om mee te beginnen
Het kookboek (Engels) bevat de tien toepassingen als complete programma's in curl, Python en TypeScript, elk met het antwoord dat de live API gaf, en patronen voor routeren tussen een LLM en Dex, toolaanroepen van een agent bewaken, batches scoren, opnieuw proberen, versies vastzetten in CI en kosten schatten. Wijs je assistent op het recept dat het dichtst bij je taak ligt.
Controleer wat je assistent bouwde
- Test met een testsleutel. Testsleutels zijn gratis tot 250,000 tokens per dag per account, en elk antwoord toont het exacte aantal tokens, zodat je weet wat de code kost voordat je een live sleutel gebruikt.
- Of eerst met een mockserver.
npx @stoplight/prism-cli mock https://thinqit.ai/openapi.yamlcontroleert elk verzoek tegen het contract. Zie de Quickstart (Engels). - Kijk naar de drie plekken waar modellen uitglijden. Staat
min_confidenceop elke vraag waar de code op handelt, en gaat elk antwoord metabstainednaar een mens? Leest de code de API-sleutel uit de omgeving, op de server? Staan alle vragen over één state in één verzoek?
Een MCP-server waarmee assistenten Dex rechtstreeks aanroepen, is de volgende stap.