| title | Quickstart |
|---|---|
| description | Ingest your first document and query it in a couple of minutes |
Polyvia turns visual & multimodal documents into a queryable knowledge graph. This guide takes you from zero to a cited answer.
Open the **Polyvia Platform** and sign up or log in. Open **API** in the sidebar of the **Polyvia Platform**, then **Create API Key**. Copy it — it's shown only once. All keys start with `poly_`. In the snippets below you can paste your key straight into `api_key` to get going. For real projects, keep it out of code instead — run `export POLYVIA_API_KEY=poly_` and call `Polyvia()` (or `new Polyvia()`) with no arguments; the SDK reads the variable automatically. An explicit `api_key` always takes precedence over the environment variable. ```bash pip pip install polyvia ```npm install polyviaIngestion is asynchronous: upload returns a task_id, then you poll (or
wait) until it's completed. Once indexed, query in natural language and get
an answer grounded in the exact source page.
client = Polyvia(api_key="poly_")
result = client.ingest.file("q4-report.pdf") client.ingest.wait(result.task_id) # blocks until completed
answer = client.query("What was Q4 revenue, and which chart shows it?") print(answer.answer)
```ts TypeScript
import { Polyvia } from "polyvia";
const client = new Polyvia({ apiKey: "poly_<key>" });
const result = await client.ingest.file("q4-report.pdf");
await client.ingest.wait(result.task_id); // resolves when completed
const answer = await client.query("What was Q4 revenue, and which chart shows it?");
console.log(answer.answer);
The power of Polyvia is querying a whole corpus jointly. Ingest a batch into a group, then ask one question across all of it.
```python Python from polyvia import Polyviaclient = Polyvia(api_key="poly_")
items = client.ingest.batch( ["q1.pdf", "q2.pdf", "q3.pdf", "q4.pdf"], group="FY24 Earnings", ) for item in items: client.ingest.wait(item.task_id)
print(client.query("How did revenue trend across the four quarters?", group="FY24 Earnings").answer)
```ts TypeScript
import { Polyvia } from "polyvia";
const client = new Polyvia({ apiKey: "poly_<key>" });
const items = await client.ingest.batch(
["q1.pdf", "q2.pdf", "q3.pdf", "q4.pdf"],
{ group: "FY24 Earnings" },
);
await Promise.all(items.map((i) => client.ingest.wait(i.task_id)));
const answer = await client.query(
"How did revenue trend across the four quarters?",
{ group: "FY24 Earnings" },
);
console.log(answer.answer);