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:
- 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.
- Check the fields — review the fields the collection will extract.
- 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.
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.
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": "…"}import { readFile } from "node:fs/promises";
const API_ROOT = "https://futuresmart.ai/document-intelligence/api";
const COLLECTION_ID = process.env.DOCUMENT_INTELLIGENCE_COLLECTION_ID;
const form = new FormData();
form.append("file", new Blob([await readFile("invoice.pdf")], { type: "application/pdf" }), "invoice.pdf");
const res = await fetch(`${API_ROOT}/v1/${COLLECTION_ID}/documents`, {
method: "POST",
headers: { "x-api-key": process.env.DOCUMENT_INTELLIGENCE_API_KEY },
body: form,
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
console.log(await res.json());curl -sS -X POST "https://futuresmart.ai/document-intelligence/api/v1/$DOCUMENT_INTELLIGENCE_COLLECTION_ID/documents" \
-H "x-api-key: $DOCUMENT_INTELLIGENCE_API_KEY" \
-F "file=@invoice.pdf;type=application/pdf"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.
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"{ "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.
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"])const API_ROOT = "https://futuresmart.ai/document-intelligence/api";
const COLLECTION_ID = process.env.DOCUMENT_INTELLIGENCE_COLLECTION_ID;
const res = await fetch(`${API_ROOT}/v1/${COLLECTION_ID}/chat`, {
method: "POST",
headers: {
"x-api-key": process.env.DOCUMENT_INTELLIGENCE_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({ query: "What is the total due on the invoice, and when is it due?", stream: false }),
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const answer = await res.json();
console.log(answer.response);
for (const source of answer.data.knowledge.relevant_sources.data) console.log("-", source.title);curl -sS -X POST "https://futuresmart.ai/document-intelligence/api/v1/$DOCUMENT_INTELLIGENCE_COLLECTION_ID/chat" \
-H "x-api-key: $DOCUMENT_INTELLIGENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "What is the total due on the invoice, and when is it due?", "stream": false}'{
"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
- Extracted fields: read the vendor, total and line items as data.
- Ask questions: follow-ups, sources and every response field.
- End-to-end examples: ingest a folder and export a table.