Getting started
Implement Dex with an AI assistant
A copy-paste system prompt, the machine-readable docs and an AI kit for Claude Code, Codex and Cursor, so your coding assistant implements Dex correctly the first time.
Coding assistants such as Claude, GPT, Gemini, Codex and Cursor can wire Dex into your code base in minutes, if they read the right material first. Give your assistant the system prompt below: it points the assistant at our complete reference in one file, llms-full.txt, and at the API contract, and it states the rules models most often get wrong, such as paying for input tokens only, pinning exact versions, reading typed answers instead of prose, and never acting on an answer that abstained. For Claude Code, Codex and Cursor, the AI kit adds the same rules as a skill and as editor rules, with a validator for request bodies.
The system prompt
Paste this into your assistant's system prompt, project instructions or first message. It is plain text and works with any 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.
What your assistant can read
| File | What it holds |
|---|---|
| /llms.txt | A short index of every page, in the llms.txt format. |
| /llms-full.txt | Everything in one file: the implementation guide for AI assistants, the ten use cases with their live request and response pairs, the cookbook, every docs page and the API reference. |
| /openapi.yaml | The API contract (OpenAPI 3.1). Where anything disagrees, the contract wins. |
| /schemas/dex-request.schema.json | The JSON schema of a POST /v1/decide body, for editors and validators. |
.md twins |
Every docs page as Markdown at the same path with .md, for example /docs/quickstart.md. |
If your assistant can fetch web pages, the system prompt is enough: it tells the assistant to read llms-full.txt first. If it cannot, download llms-full.txt and add it to the assistant's context or project files.
The AI kit
thinqit-dex-ai-kit-1.0.1.zip holds:
skills/dex/: a skill for Claude Code and Codex.SKILL.mdholds the decision rules and worked examples,reference.mdthe compact API reference, andscripts/validate.mjsa validator that checks a request body offline with the same error codes the API returns, and warns about secrets in the state, labels JavaScript would reorder and unpinned versions.cursor/rules/dex.mdc: the same rules as a Cursor project rule.AGENTS.md: the rules for any assistant that reads anAGENTS.mdfile.
Download it and check it against 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; on macOS: shasum -a 256 -c thinqit-dex-ai-kit-1.0.1.zip.sha256
unzip thinqit-dex-ai-kit-1.0.1.zip
Then install the part your tool reads. The kit's README.md has the same steps.
| Tool | Install |
|---|---|
| Claude Code | Copy skills/dex to .claude/skills/dex in your repository (for everyone who works on it) or to ~/.claude/skills/dex (for you). Claude loads the skill when your task involves Dex. |
| Codex | Copy skills/dex to .agents/skills/dex in your repository (Codex reads repository skills in a project you trust) or to ~/.codex/skills/dex. |
| Cursor | Copy cursor/rules/dex.mdc to .cursor/rules/dex.mdc in your repository. |
| Any other assistant | Add the contents of AGENTS.md to your assistant's instructions, or use the system prompt above. |
To check a request body your assistant wrote, run the validator with Node.js 18 or newer:
node skills/dex/scripts/validate.mjs request.json
Recipes to start from
The cookbook has ten use cases as complete programs in curl, Python and TypeScript, each with the answer the live API gave, and patterns for routing between an LLM and Dex, gating an agent's tool calls, batch scoring, retries, version pins in CI and cost estimates. Point your assistant at the recipe closest to your task: "Implement the pattern from https://thinqit.ai/docs/cookbook/gate-agent-tool-calls.md in our agent."
Check what your assistant built
- Run it against a test key. Test keys are free up to 250,000 tokens a day per account, and every response shows the exact token count, so you see what the code will cost before you switch to a live key.
- Or against a mock first.
npx @stoplight/prism-cli mock https://thinqit.ai/openapi.yamlchecks every request against the contract. See the Quickstart. - Review the three places models slip. Is
min_confidenceset, and is everyabstainedanswer routed to a person? Is the API key read from the environment on the server? Are the questions about one state in one request?
An MCP server that lets assistants call Dex directly is next on our list.