Skip to content

Latest commit

 

History

History
137 lines (106 loc) · 3.71 KB

File metadata and controls

137 lines (106 loc) · 3.71 KB
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.

1. Get an API key

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.

2. Install an SDK

```bash pip pip install polyvia ```
npm install polyvia
Prefer raw HTTP? Every example here maps 1:1 to the REST [API Reference](/api-reference/introduction). No SDK required.

3a. Ingest & query — a single file

Ingestion 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.

```python Python from polyvia import Polyvia

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);

3b. Ingest & query — across many documents

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 Polyvia

client = Polyvia(api_key="poly_")

Ingest several files into a group (created on first use)

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)

Ask once, across the group — answers cite the exact page in each doc

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);

Next steps

Documents, groups, ingestion, citations. Async client, error handling, agent tools. Use Polyvia from Claude, Cursor and agents. **Need help?** Email [mgierlach5@gmail.com](mailto:mgierlach5@gmail.com).