Dike

Grounded Q&A walkthrough

End-to-end example of asking a legal question and rendering a verified answer.

This walks through a full /v1/reason call and shows how to render the result so a reader can trust every citation.

1. Ask the question

curl https://api.dike.it.com/v1/reason \
  -H "Authorization: Bearer $DIKE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "هل يجوز فسخ عقد الإيجار لتأخر المستأجر عن السداد؟",
    "filters": { "jurisdiction": "EG" },
    "top_k": 12
  }'

2. Render the answer with its markers intact

{
  "answer": "...نعم، وفقاً للمادة 157 [1] ...",
  "citations": [
    {
      "marker": 1,
      "canonical_id": "eg-leg-1948-131",
      "article_no": "157",
      "citation_string": "المادة 157 من القانون المدني رقم 131 لسنة 1948",
      "snippet": "...",
      "verified": true
    }
  ],
  "grounding": { "retrieved": 12, "used": 4, "dropped_unverified_refs": 0 }
}

Render answer as-is — [1] in the text is already a verified marker, not a placeholder you need to resolve yourself. Turn each [n] into a link/footnote using citations[n-1].

3. Handle weak grounding

If grounding.used is 0, check the response header X-Dike-Grounding: weak. Don't hide the answer — show it with a visible caveat (e.g. "Dike couldn't find a strong legal basis for this in the indexed corpus") rather than suppressing it silently, since the model may still be correctly declining to overreach.

Every citations[].canonical_id works directly with /v1/document/{canonical_id} if the reader wants the full source text, or /v1/graph/traverse if they want to see what else cites or amends it.