Hume
The Hume provider contains support for the Hume text-to-speech (TTS) API.
Hume models are not currently available through AI Gateway, so the opening example uses @ai-sdk/hume directly. See Using AI Gateway below for supported alternatives.
Using AI Gateway
The current AI Gateway model catalog does not list Hume models. Use @ai-sdk/hume for the APIs on this page. To use other speech models through Gateway, install ai and configure a Gateway API key:
$ pnpm add ai
$ npm install ai
$ yarn add ai
$ bun add ai
Set an AI Gateway API key in your environment:
Vercel deployments can also use OIDC authentication. See the Gateway documentation for supported models and APIs.
Using @ai-sdk/hume
For direct access to Hume, install ai and @ai-sdk/hume:
$ pnpm add ai @ai-sdk/hume
$ npm install ai @ai-sdk/hume
$ yarn add ai @ai-sdk/hume
$ bun add ai @ai-sdk/hume
Set your Hume API credential in the HUME_API_KEY environment variable:
The following sections document the direct @ai-sdk/hume provider, including
its model factories and settings. Gateway model and feature availability can
differ.
Provider Instance
You can import the default provider instance hume from @ai-sdk/hume:
If you need a customized setup, you can import createHume from @ai-sdk/hume and create a provider instance with your settings:
You can use the following optional settings to customize the Hume provider instance:
-
apiKey string | PromiseLike<string> | (() => string | PromiseLike<string>)
Pass a synchronous or asynchronous callback to resolve the key before each request. The callback is responsible for caching and refreshing credentials.
API key that is being sent using the
X-Hume-Api-Keyheader. It defaults to theHUME_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
You can create models that call the Hume speech API
using the .speech() factory method.
You can pass standard speech generation options like voice, speed, instructions, and outputFormat:
Supported Parameters
-
text string (required)
The text to convert to speech.
-
voice string
The voice ID to use for the generated audio. Defaults to
'd8ab67c6-953d-4bd8-9370-8fa53a0f1453'. -
speed number
Speech rate multiplier.
-
instructions string
Description or instructions for how the text should be spoken.
-
outputFormat string
The audio format to generate. Supported values:
'mp3','pcm','wav'. Defaults to'mp3'.
The language parameter is not supported by Hume speech models and will be
ignored with a warning.
Provider Options
You can pass additional provider-specific options using the providerOptions argument:
The following provider options are available:
-
context object
Context for the speech synthesis request. Can be either:
{ generationId: string }- ID of a previously generated speech synthesis to use as context.{ utterances: Utterance[] }- An array of utterance objects for context, where each utterance has:textstring (required) - The text content.descriptionstring - Instructions for how the text should be spoken.speednumber - Speech rate multiplier.trailingSilencenumber - Duration of silence to add after the utterance in seconds.voiceobject - Voice configuration, either{ id: string, provider?: 'HUME_AI' | 'CUSTOM_VOICE' }or{ name: string, provider?: 'HUME_AI' | 'CUSTOM_VOICE' }.
Model Capabilities
| Model | Instructions | Speed | Output Formats |
|---|---|---|---|
default | mp3, pcm, wav |