Quickstart

Create a collection, generate an API key, add a document from code, wait for it to be read, and ask a question about it.

1. Create a collection in the app

Open Document Intelligence and sign in. Click Create document collection:

  1. Describe — pick the kind of documents (résumés, invoices, contracts, support tickets, or something else) and say what you want pulled out of them.
  2. Check the fields — review the fields the collection will extract.
  3. Add documents — add some now, or click Create it empty to feed it entirely from your code.

Collections are created in the app because that is where you decide their fields; everything after that can be done from the API.

2. Generate an API key

Open the collection, then Share, expand API and click Generate API key. Copy the key straight away — it starts with sk- and is shown only once. Copy the collection's id from its card on the app's home screen.

Shell
export DOCUMENT_INTELLIGENCE_API_KEY="sk-your-key"
export DOCUMENT_INTELLIGENCE_COLLECTION_ID="your-collection-id"

On Windows PowerShell use $env:DOCUMENT_INTELLIGENCE_API_KEY = "sk-your-key" instead.

3. Add a document

Upload a PDF, Word file, text or Markdown file of up to 5 MB. Processing runs in the background; the call returns an object_id straight away.

Python
import os
import requests

API_ROOT = "https://futuresmart.ai/document-intelligence/api"
COLLECTION_ID = os.environ["DOCUMENT_INTELLIGENCE_COLLECTION_ID"]
HEADERS = {"x-api-key": os.environ["DOCUMENT_INTELLIGENCE_API_KEY"]}

with open("invoice.pdf", "rb") as f:
    r = requests.post(
        f"{API_ROOT}/v1/{COLLECTION_ID}/documents",
        headers=HEADERS,
        files={"file": ("invoice.pdf", f, "application/pdf")},
        timeout=120,
    )
r.raise_for_status()
print(r.json())  # {"object_id": "…", "status": "processing", "message": "…"}

4. Wait until it is read

Poll the document's status until it is completed (or failed). A one-page PDF usually takes 10–30 seconds.

Shell
curl -sS "https://futuresmart.ai/document-intelligence/api/v1/$DOCUMENT_INTELLIGENCE_COLLECTION_ID/documents/$OBJECT_ID/status" \
  -H "x-api-key: $DOCUMENT_INTELLIGENCE_API_KEY"
JSON
{ "knowledge_id": "…", "object_id": "…", "status": "completed", "error_detail": null }

5. Ask a question

Chat streams by default. Send "stream": false to get one JSON response.

Python
import os
import requests

API_ROOT = "https://futuresmart.ai/document-intelligence/api"
COLLECTION_ID = os.environ["DOCUMENT_INTELLIGENCE_COLLECTION_ID"]

r = requests.post(
    f"{API_ROOT}/v1/{COLLECTION_ID}/chat",
    headers={"x-api-key": os.environ["DOCUMENT_INTELLIGENCE_API_KEY"]},
    json={"query": "What is the total due on the invoice, and when is it due?", "stream": False},
    timeout=120,
)
r.raise_for_status()
answer = r.json()

print(answer["response"])
for source in answer["data"]["knowledge"]["relevant_sources"]["data"]:
    print("-", source["title"])
JSON
{
  "response": "The total due on invoice **INV-2026-0142** is **$1,769.04 USD**, due on **October 15, 2026**.",
  "session_id": "82e92fad-0875-4165-91ea-50c861e69e74",
  "data": {
    "knowledge": {
      "relevant_sources": {
        "data": [{ "id": "d1962692-…", "title": "invoice.pdf", "context": "This document is an invoice from …" }],
        "tool_name": "rag"
      }
    }
  },
  "is_answered": "yes"
}

The JavaScript samples use top-level await: save them as .mjs files and run them with Node.js 18 or later.

Next steps