|
| 1 | +--- |
| 2 | +title: Hume |
| 3 | +description: Learn how to use the Hume provider for the AI SDK. |
| 4 | +--- |
| 5 | + |
| 6 | +# Hume Provider |
| 7 | + |
| 8 | +The [Hume](https://hume.ai/) provider contains language model support for the Hume transcription API. |
| 9 | + |
| 10 | +## Setup |
| 11 | + |
| 12 | +The Hume provider is available in the `@ai-sdk/hume` module. You can install it with |
| 13 | + |
| 14 | +<Tabs items={['pnpm', 'npm', 'yarn']}> |
| 15 | + <Tab> |
| 16 | + <Snippet text="pnpm add @ai-sdk/hume" dark /> |
| 17 | + </Tab> |
| 18 | + <Tab> |
| 19 | + <Snippet text="npm install @ai-sdk/hume" dark /> |
| 20 | + </Tab> |
| 21 | + <Tab> |
| 22 | + <Snippet text="yarn add @ai-sdk/hume" dark /> |
| 23 | + </Tab> |
| 24 | +</Tabs> |
| 25 | + |
| 26 | +## Provider Instance |
| 27 | + |
| 28 | +You can import the default provider instance `hume` from `@ai-sdk/hume`: |
| 29 | + |
| 30 | +```ts |
| 31 | +import { hume } from '@ai-sdk/hume'; |
| 32 | +``` |
| 33 | + |
| 34 | +If you need a customized setup, you can import `createHume` from `@ai-sdk/hume` and create a provider instance with your settings: |
| 35 | + |
| 36 | +```ts |
| 37 | +import { createHume } from '@ai-sdk/hume'; |
| 38 | + |
| 39 | +const hume = createHume({ |
| 40 | + // custom settings, e.g. |
| 41 | + fetch: customFetch, |
| 42 | +}); |
| 43 | +``` |
| 44 | + |
| 45 | +You can use the following optional settings to customize the Hume provider instance: |
| 46 | + |
| 47 | +- **apiKey** _string_ |
| 48 | + |
| 49 | + API key that is being sent using the `Authorization` header. |
| 50 | + It defaults to the `HUME_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 [Hume speech API](https://dev.hume.ai/docs/text-to-speech-tts/overview) |
| 66 | +using the `.speech()` factory method. |
| 67 | + |
| 68 | +```ts |
| 69 | +const model = hume.speech(); |
| 70 | +``` |
| 71 | + |
| 72 | +You can also pass additional provider-specific options using the `providerOptions` argument. For example, supplying a voice to use for the generated audio. |
| 73 | + |
| 74 | +```ts highlight="6" |
| 75 | +import { experimental_generateSpeech as generateSpeech } from 'ai'; |
| 76 | +import { hume } from '@ai-sdk/hume'; |
| 77 | + |
| 78 | +const result = await generateSpeech({ |
| 79 | + model: hume.speech(), |
| 80 | + text: 'Hello, world!', |
| 81 | + voice: 'd8ab67c6-953d-4bd8-9370-8fa53a0f1453', |
| 82 | + providerOptions: { hume: {} }, |
| 83 | +}); |
| 84 | +``` |
| 85 | + |
| 86 | +The following provider options are available: |
| 87 | + |
| 88 | +- **context** _object_ |
| 89 | + |
| 90 | + Either: |
| 91 | + |
| 92 | + - `{ generationId: string }` - A generation ID to use for context. |
| 93 | + - `{ utterances: HumeUtterance[] }` - An array of utterance objects for context. |
| 94 | + |
| 95 | +### Model Capabilities |
| 96 | + |
| 97 | +| Model | Instructions | |
| 98 | +| --------- | ------------------- | |
| 99 | +| `default` | <Check size={18} /> | |
0 commit comments