Skip to content

Files ​

Agents can read PDFs, images, Office documents and text files. You upload a file once, get an id, and pass the id in the files array of a run or conversation message.

Upload ​

POST /v1/files (scope files:write) takes a multipart body with one field named file:

bash
curl "$HEVKAR_BASE_URL/v1/files" \
  -H "Authorization: Bearer $HEVKAR_API_KEY" \
  -F "file=@scan.pdf"
ts
import { readFile } from 'node:fs/promises';
import { createReadStream } from 'node:fs';

const a = await hevkar.files.upload(await readFile('scan.pdf'), { name: 'scan.pdf' }); // Buffer
const b = await hevkar.files.upload(createReadStream('photo.jpg')); // stream, name from the path
const c = await hevkar.files.upload(new File([bytes], 'notes.txt')); // File or Blob
ts
const form = new FormData();
form.append('file', new Blob([bytes]), 'scan.pdf');
const file = await fetch(`${baseUrl}/v1/files`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${apiKey}` },
  body: form,
}).then((r) => r.json());

Response 201:

json
{
  "id": "0b8f9a43-6f55-4a8e-8f43-0d1b1c7e2a11",
  "name": "scan.pdf",
  "mimeType": "application/pdf",
  "size": 182044,
  "pages": 3,
  "sha256": "9f2c…",
  "purpose": "input",
  "expiresAt": "2026-11-28T10:15:00.000Z",
  "createdAt": "2026-11-21T10:15:00.000Z"
}
  • The type is detected from the file's bytes, not from the name or the Content-Type the client sends. Text formats are recognized by being valid UTF-8; the extension then picks Markdown, CSV, HTML or JSON.
  • pages is set for PDFs. A PDF whose page count cannot be read (damaged or unusual files) is refused with 422 PDF_PAGE_COUNT_UNKNOWN, since it could not be checked against page limits.
  • Uploaded run inputs expire (by default after 7 days) and are deleted.
  • Uploads count toward the organization's storage limit (402 STORAGE_LIMIT_REACHED).

Supported types and upload limits ​

KindMIME types
PDFapplication/pdf
Imagesimage/png, image/jpeg, image/webp, image/gif, image/tiff
OfficeDOCX (application/vnd.openxmlformats-officedocument.wordprocessingml.document), PPTX (...presentationml.presentation)
Texttext/plain, text/markdown, text/html, text/csv, application/json

Other types answer 415 FILE_TYPE_NOT_SUPPORTED. Files above the platform's upload limit (50 MB by default) answer 413 FILE_TOO_LARGE; a missing file field answers 400 FILE_REQUIRED.

Read and delete ​

ts
const detail = await hevkar.files.get(file.id);
// FileObject + { url, urlExpiresAt }: a signed download URL valid for a few minutes
await hevkar.files.delete(file.id); // { deleted: true }

Use files in runs ​

ts
const result = await hevkar.agents.run('letter-analyzer', { files: [file.id] });

Up to 20 file ids per run or message. Each file is checked against the agent's files settings before the run starts:

SettingDefaultError when violated
acceptedMimeTypesapplication/pdf, image/png, image/jpeg400 FILE_TYPE_NOT_ACCEPTED
maxSizeMb20 (max 100)413 FILE_TOO_LARGE
maxPages30 (max 500)400 FILE_TOO_MANY_PAGES
(PDF without a known page count)422 PDF_PAGE_COUNT_UNKNOWN
strategyauto

acceptedMimeTypes entries may use wildcards such as image/*. An unknown id (or a file of another project) answers 404 FILE_NOT_FOUND.

Workflow agents take run files too: their files settings apply, and nodes see the files as $files and pass them on to agents with their files expression (see Workflows).

Vision vs OCR ​

The strategy decides how a file reaches the model:

StrategyImagesPDFsOther documents
visionsent as imageseach page rendered as an image (up to maxPages)text
ocrtext recognized by OCRtext extracted; OCR for scanned pagestext
autovision when the model has the vision capability, else ocrtext
  • vision needs a model with the vision capability; with another model the file falls back to text extraction.
  • Text extraction is done by the platform's document worker. Pages that needed OCR are metered as ocr_pages with the run. Plain text, Markdown, CSV and JSON are read directly.
  • Extracted text is wrapped as <file name="…">…</file> in the user message and cut at 200 000 characters per file.
  • Vision is better for layout-heavy documents (forms, tables, handwriting, photos). OCR is cheaper for long text documents and works with any model.

The run detail (GET /v1/runs/{id}) shows the strategy used for each file in files[].strategy.

Files in knowledge ​

Files for data sources are uploaded to the data source itself (POST /v1/datasources/{id}/documents, multipart, up to 20 files), not through /v1/files.

Hevkar public API v1