|
| 1 | +--- |
| 2 | +title: LMNT |
| 3 | +description: Learn how to use the LMNT provider for the AI SDK. |
| 4 | +--- |
| 5 | + |
| 6 | +# LMNT Provider |
| 7 | + |
| 8 | +The [LMNT](https://lmnt.com/) provider contains language model support for the LMNT transcription API. |
| 9 | + |
| 10 | +## Setup |
| 11 | + |
| 12 | +The LMNT provider is available in the `@ai-sdk/lmnt` module. You can install it with |
| 13 | + |
| 14 | +<Tabs items={['pnpm', 'npm', 'yarn']}> |
| 15 | + <Tab> |
| 16 | + <Snippet text="pnpm add @ai-sdk/lmnt" dark /> |
| 17 | + </Tab> |
| 18 | + <Tab> |
| 19 | + <Snippet text="npm install @ai-sdk/lmnt" dark /> |
| 20 | + </Tab> |
| 21 | + <Tab> |
| 22 | + <Snippet text="yarn add @ai-sdk/lmnt" dark /> |
| 23 | + </Tab> |
| 24 | +</Tabs> |
| 25 | + |
| 26 | +## Provider Instance |
| 27 | + |
| 28 | +You can import the default provider instance `lmnt` from `@ai-sdk/lmnt`: |
| 29 | + |
| 30 | +```ts |
| 31 | +import { lmnt } from '@ai-sdk/lmnt'; |
| 32 | +``` |
| 33 | + |
| 34 | +If you need a customized setup, you can import `createLMNT` from `@ai-sdk/lmnt` and create a provider instance with your settings: |
| 35 | + |
| 36 | +```ts |
| 37 | +import { createLMNT } from '@ai-sdk/lmnt'; |
| 38 | + |
| 39 | +const lmnt = createLMNT({ |
| 40 | + // custom settings, e.g. |
| 41 | + fetch: customFetch, |
| 42 | +}); |
| 43 | +``` |
| 44 | + |
| 45 | +You can use the following optional settings to customize the LMNT provider instance: |
| 46 | + |
| 47 | +- **apiKey** _string_ |
| 48 | + |
| 49 | + API key that is being sent using the `Authorization` header. |
| 50 | + It defaults to the `LMNT_API_KEY` environment variable. |
| 51 | + |
| 52 | +- **headers** _Record<string,string>_ |
| 53 | + |
| 54 | + Custom headers to include in the requests. |
| 55 | + |
| 56 | +- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise<Response>_ |
| 57 | + |
| 58 | + Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation. |
| 59 | + Defaults to the global `fetch` function. |
| 60 | + You can use it as a middleware to intercept requests, |
| 61 | + or to provide a custom fetch implementation for e.g. testing. |
| 62 | + |
| 63 | +## Speech Models |
| 64 | + |
| 65 | +You can create models that call the [LMNT speech API](https://docs.lmnt.com/api-reference/speech/synthesize-speech-bytes) |
| 66 | +using the `.speech()` factory method. |
| 67 | + |
| 68 | +The first argument is the model id e.g. `aurora`. |
| 69 | + |
| 70 | +```ts |
| 71 | +const model = lmnt.speech('aurora'); |
| 72 | +``` |
| 73 | + |
| 74 | +You can also pass additional provider-specific options using the `providerOptions` argument. For example, supplying a voice to use for the generated audio. |
| 75 | + |
| 76 | +```ts highlight="6" |
| 77 | +import { experimental_generateSpeech as generateSpeech } from 'ai'; |
| 78 | +import { lmnt } from '@ai-sdk/lmnt'; |
| 79 | + |
| 80 | +const result = await generateSpeech({ |
| 81 | + model: lmnt.speech('aurora'), |
| 82 | + text: 'Hello, world!', |
| 83 | + providerOptions: { lmnt: { language: 'en' } }, |
| 84 | +}); |
| 85 | +``` |
| 86 | + |
| 87 | +### Provider Options |
| 88 | + |
| 89 | +The LMNT provider accepts the following options: |
| 90 | + |
| 91 | +- **model** _'aurora' | 'blizzard'_ |
| 92 | + |
| 93 | + The LMNT model to use. Defaults to `'aurora'`. |
| 94 | + |
| 95 | +- **language** _'auto' | 'en' | 'es' | 'pt' | 'fr' | 'de' | 'zh' | 'ko' | 'hi' | 'ja' | 'ru' | 'it' | 'tr'_ |
| 96 | + |
| 97 | + The language to use for speech synthesis. Defaults to `'auto'`. |
| 98 | + |
| 99 | +- **format** _'aac' | 'mp3' | 'mulaw' | 'raw' | 'wav'_ |
| 100 | + |
| 101 | + The audio format to return. Defaults to `'mp3'`. |
| 102 | + |
| 103 | +- **sampleRate** _number_ |
| 104 | + |
| 105 | + The sample rate of the audio in Hz. Defaults to `24000`. |
| 106 | + |
| 107 | +- **speed** _number_ |
| 108 | + |
| 109 | + The speed of the speech. Must be between 0.25 and 2. Defaults to `1`. |
| 110 | + |
| 111 | +- **seed** _number_ |
| 112 | + |
| 113 | + An optional seed for deterministic generation. |
| 114 | + |
| 115 | +- **conversational** _boolean_ |
| 116 | + |
| 117 | + Whether to use a conversational style. Defaults to `false`. |
| 118 | + |
| 119 | +- **length** _number_ |
| 120 | + |
| 121 | + Maximum length of the audio in seconds. Maximum value is 300. |
| 122 | + |
| 123 | +- **topP** _number_ |
| 124 | + |
| 125 | + Top-p sampling parameter. Must be between 0 and 1. Defaults to `1`. |
| 126 | + |
| 127 | +- **temperature** _number_ |
| 128 | + |
| 129 | + Temperature parameter for sampling. Must be at least 0. Defaults to `1`. |
| 130 | + |
| 131 | +### Model Capabilities |
| 132 | + |
| 133 | +| Model | Instructions | |
| 134 | +| ---------- | ------------------- | |
| 135 | +| `aurora` | <Check size={18} /> | |
| 136 | +| `blizzard` | <Check size={18} /> | |
0 commit comments