Skip to content
Constaia

Svelte

Validate documents with AI in Svelte

A SvelteKit form action calls the SDK on the server and returns the verdict to the form.

Install

npm i @constaia/sdk

The safe pattern

The browser or app never sees your secret key. The file goes to your server, your server calls Constaia and returns the verdict.

Full guide
src/routes/verify/+page.server.ts
import { Constaia } from "@constaia/sdk";
import { CONSTAIA_API_KEY } from "$env/static/private";
import { fail } from "@sveltejs/kit";

const constaia = new Constaia({ apiKey: CONSTAIA_API_KEY });

export const actions = {
  default: async ({ request }) => {
    const file = (await request.formData()).get("file");
    if (!(file instanceof File)) return fail(400, { error: "missing_file" });
    const analysis = await constaia.analyze(file, { expect: "es_dni", checks: { notExpired: true } });
    return { status: analysis.verdict?.status, reasons: analysis.verdict?.reasons };
  },
};

One call. An answer you can act on.

  1. 01

    Send the document and what you expect

    Photo, screenshot or PDF. Set the expected type and the rules: not expired, under 6 months old, in this person's name.

  2. 02

    We read, classify and check

    European OCR, AI classification and deterministic validators: NIF letter, MRZ, IBAN, dates and totals.

  3. 03

    Get the verdict and delete the file

    valid, invalid or review with reasons in your language. By default the file is deleted when the analysis ends.

And for the record…

Create your account, copy the test key and validate your first document in five minutes.