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

# Vercel AI SDK

> Use Lokutor text-to-speech and speech-to-text from the Vercel AI SDK with the @lokutor/ai-sdk-provider package.

[`@lokutor/ai-sdk-provider`](https://www.npmjs.com/package/@lokutor/ai-sdk-provider) ([source](https://github.com/lokutor-ai/ai-sdk-provider-lokutor)) adds Lokutor to the [Vercel AI SDK](https://ai-sdk.dev) as a speech model and a transcription model. It targets AI SDK 7; it does not work with `ai` 6.

```bash theme={null}
npm install ai @lokutor/ai-sdk-provider
```

```ts theme={null}
import { experimental_generateSpeech as generateSpeech, transcribe } from "ai"; // `generateSpeech` in recent versions
import { lokutor } from "@lokutor/ai-sdk-provider";

const { audio } = await generateSpeech({
  model: lokutor.speech("versa-2.0"),
  text: "Hello, this is Lokutor.",
  voice: "F1",
  language: "en",
});

const { text } = await transcribe({
  model: lokutor.transcription("lokutor-stt"),
  audio: audio.uint8Array,
  providerOptions: { lokutor: { languageCode: "en" } },
});
```

Set `LOKUTOR_API_KEY` in the environment, or create the provider yourself with `createLokutor({ apiKey })`.

## Behaviour to know

* Speech is always WAV. `outputFormat`, `speed` and `instructions` are not supported and produce a warning instead of being sent.
* Transcription takes WAV audio only, as the [speech-to-text API](https://docs.lokutor.com/api-reference/speech-to-text.md) does.
* Speaker labels and the language are set through `providerOptions.lokutor`.
* Voices and languages are those of the [Lokutor API](https://docs.lokutor.com/voices-languages-models.md).


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