Quickstart

Quickstart

Get a first grounded answer back from the chatbot in a few minutes.

Audience: developers integrating the HTTP API. What you will accomplish: send a question to POST /api/v1/chat and read the answer, its citations, and its grounding verdict. Estimated time: about 15 minutes.

Prerequisites

  • A running server reachable at the base URL http://127.0.0.1:8000. (To start one, follow the project README: uvicorn main:app --reload, or docker-compose up --build.)
  • At least one ingested document if you want a grounded answer in strict mode — see Ingesting documents. With no documents, strict mode will politely decline, which is expected behavior, not an error.
  • curl (or any HTTP client).

Send your first question

  1. Step 1: Confirm the server is up

    A healthy server responds to a health check. A degraded result means Redis or ChromaDB is unreachable — chat may still work, but retrieval can be impaired.

  2. Step 2: Post a question to /api/v1/chat

    Send a stable X-User-Id so the bot can remember the conversation, and ask a question your documents can answer.

  3. Step 3: Read the answer, sources, and grounding

    The response includes answer, structured sources[], and meta (including grounded and correlation_id). Quote the correlation_id if you ever need support.

1. Check health

curl
curl http://127.0.0.1:8000/health

If it fails: connection refused means the server is not running — start it first. A degraded body means a dependency (Redis / ChromaDB) is down.

2. Ask a question

curl
curl -X POST http://127.0.0.1:8000/api/v1/chat \
-H "Content-Type: application/json" \
-H "X-User-Id: alice" \
-d '{"q":"How long do I have to return an item?","mode":"strict","top_k":4}'

If it fails: A 422 means the body failed validation (e.g. empty q); a 429 means you are rate limited — wait for the Retry-After seconds.

Expected result

A successful call returns JSON shaped like this:

{
  "answer": "You can return any item within 30 days of purchase.",
  "sources": [
    {
      "label": "return_policy.pdf",
      "doc_id": "return_policy",
      "score": 0.86,
      "page": 1,
      "snippet": "Customers may return any item within 30 days..."
    }
  ],
  "meta": {
    "mode": "strict",
    "lang": "en",
    "self_ingested": false,
    "grounded": "supported",
    "grounded_score": 0.86,
    "correlation_id": "b1f3…",
    "model": "gpt-4o-mini"
  }
}

Verify your result

  • Verify: The HTTP status is 200 and the body contains a non-empty answer.
  • Verify: sources[] lists at least one citation with a score and a snippet you can verify against the answer.
  • Verify: meta.grounded reads supported (or partial) for an on-topic question.
  • Verify: The response carries an X-Correlation-Id header matching meta.correlation_id.

Common failure modes