LMNT
This page adapts the original AI SDK documentation: LMNT (https://github.com/vercel/ai/blob/main/content/providers/01-ai-sdk-providers/140-lmnt.mdx).
The LMNT provider contains language model support for the LMNT transcription API.
Add the library via Swift Package Manager and include these products:
// Package.swift (excerpt)dependencies: [ .package(url: "https://github.com/teunlao/swift-ai-sdk", from: "1.0.0")],targets: [ .target( name: "YourTarget", dependencies: [ .product(name: "SwiftAISDK", package: "swift-ai-sdk"), .product(name: "LMNTProvider", package: "swift-ai-sdk") ] )]Provider Instance
Section titled “Provider Instance”You can import the default provider instance lmnt:
import LMNTProvider
// Uses LMNT_API_KEY by defaultlet model = lmnt.speech(.aurora)If you need a customized setup, you can create a provider instance with your settings:
import LMNTProvider
let provider = createLMNT(settings: LMNTProviderSettings( apiKey: "your-api-key", headers: ["X-Custom": "value"]))
let model = provider.speech(.aurora)You can use the following optional settings to customize the LMNT provider instance:
-
apiKey string
API key that is being sent using the
Authorizationheader. It defaults to theLMNT_API_KEYenvironment variable. -
headers Record<string,string>
Custom headers to include in the requests.
-
fetch (input: RequestInfo, init?: RequestInit) => Promise<Response>
Custom fetch implementation. Defaults to the global
fetchfunction. You can use it as a middleware to intercept requests, or to provide a custom fetch implementation for e.g. testing.
Speech Models
Section titled “Speech Models”You can create models that call the LMNT speech API
using the .speech() factory method.
The first argument is the model id e.g. aurora.
let model = lmnt.speech(.aurora)You can also pass additional provider-specific options using the providerOptions argument. For example, supplying a voice to use for the generated audio.
import SwiftAISDKimport LMNTProvider
let result = try await generateSpeech( model: lmnt.speech(.aurora), text: "Hello, world!", language: "en" // standardized language parameter)Provider Options
Section titled “Provider Options”The LMNT provider accepts the following options:
-
model ‘aurora’ | ‘blizzard’
The LMNT model to use. Defaults to
'aurora'. -
language ‘auto’ | ‘en’ | ‘es’ | ‘pt’ | ‘fr’ | ‘de’ | ‘zh’ | ‘ko’ | ‘hi’ | ‘ja’ | ‘ru’ | ‘it’ | ‘tr’
The language to use for speech synthesis. Defaults to
'auto'. -
format ‘aac’ | ‘mp3’ | ‘mulaw’ | ‘raw’ | ‘wav’
The audio format to return. Defaults to
'mp3'. -
sampleRate number
The sample rate of the audio in Hz. Defaults to
24000. -
speed number
The speed of the speech. Must be between 0.25 and 2. Defaults to
1. -
seed number
An optional seed for deterministic generation.
-
conversational boolean
Whether to use a conversational style. Defaults to
false. -
length number
Maximum length of the audio in seconds. Maximum value is 300.
-
topP number
Top-p sampling parameter. Must be between 0 and 1. Defaults to
1. -
temperature number
Temperature parameter for sampling. Must be at least 0. Defaults to
1.
Model Capabilities
Section titled “Model Capabilities”| Model | Instructions |
|---|---|
aurora | ✓ |
blizzard | ✓ |