> ## Documentation Index
> Fetch the complete documentation index at: https://docs.levanto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI SDK

> Sage decisions and extraction, and Levanto's LLMs, in the AI SDK.

```bash theme={"theme":"github-light"}
npm install ai @levanto/ai-sdk-provider
```

It reads your key from `LEVANTO_API_KEY`.

## Decisions

```ts theme={"theme":"github-light"}
import { experimental_decide as decide } from 'ai';
import { levanto } from '@levanto/ai-sdk-provider';

const { answers } = await decide({
  model: levanto.decisionModel('sage-latest'),
  state: 'I was charged twice. Please refund the duplicate today.',
  questions: {
    refund: { type: 'boolean', instructions: 'Is the customer asking for money back?' },
    team: { type: 'choice', criteria: { billing: 'Charges and refunds', technical: 'Bugs and outages' } },
    urgency: { type: 'score', criteria: ['Can wait', 'This week', 'Today'] },
  },
});

answers.refund.probability; // 0.997
answers.team.choice;        // 'billing'
answers.urgency.score;      // 1.98, from 0 to 2
```

Every answer comes back, so set your own threshold on `probability`. To get `null` when Sage isn't sure, call [`/decide`](https://docs.levanto.ai/decision-model/quickstart). Sage's options (`reasoning`, `grounding`, `tags`, `sort`) go in `providerOptions.levanto`, as in the [SystemOne API](https://docs.levanto.ai/systemone.md).

## Extraction

```ts theme={"theme":"github-light"}
import { experimental_extract as extract } from 'ai';
import { levanto } from '@levanto/ai-sdk-provider';

const { answers } = await extract({
  model: levanto.extractionModel('sage-latest'),
  state: 'Acme Corp. signed a three (3) year lease on 2 May 2026. Rent 1.930,78 € per month.',
  fields: {
    tenant: { type: 'text', instructions: 'The company renting' },
    term: { type: 'duration', unit: 'months', integer: true },
    signed: { type: 'date' },
    rent: { type: 'number', unit: 'EUR' },
  },
});

answers.term.value; // 36
answers.rent.value; // 1930.78
```

A field the text doesn't state comes back with `value: null`. A number with a currency `unit` is read as money; an amount in another currency gives `value: null` and the amount in `guess`.

## LLMs

```ts theme={"theme":"github-light"}
import { generateText } from 'ai';
import { levanto } from '@levanto/ai-sdk-provider';

const { text } = await generateText({
  model: levanto('auto'),
  prompt: 'Summarize this ticket in one sentence: ...',
  providerOptions: { levanto: { target: 'economy' } },
});
```

`auto` lets the [router](https://docs.levanto.ai/llms/routers.md) pick. Source: [github.com/levantolabs/ai-sdk-provider](https://github.com/levantolabs/ai-sdk-provider).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.