@ai-sdk/hume 0.0.0-1c33ba03-20260114162300 → 0.0.0-4115c213-20260122152721

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,40 @@
1
1
  # @ai-sdk/hume
2
2
 
3
- ## 0.0.0-1c33ba03-20260114162300
3
+ ## 0.0.0-4115c213-20260122152721
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [261c011]
8
- - @ai-sdk/provider-utils@0.0.0-1c33ba03-20260114162300
7
+ - 4caafb2: chore: excluded tests from src folder in npm package
8
+ - Updated dependencies [4caafb2]
9
+ - @ai-sdk/provider@0.0.0-4115c213-20260122152721
10
+ - @ai-sdk/provider-utils@0.0.0-4115c213-20260122152721
11
+
12
+ ## 2.0.10
13
+
14
+ ### Patch Changes
15
+
16
+ - 2b8369d: chore: add docs to package dist
17
+
18
+ ## 2.0.9
19
+
20
+ ### Patch Changes
21
+
22
+ - 8dc54db: chore: add src folders to package bundle
23
+
24
+ ## 2.0.8
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [5c090e7]
29
+ - @ai-sdk/provider@3.0.4
30
+ - @ai-sdk/provider-utils@4.0.8
31
+
32
+ ## 2.0.7
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [46f46e4]
37
+ - @ai-sdk/provider-utils@4.0.7
9
38
 
10
39
  ## 2.0.6
11
40
 
package/dist/index.js CHANGED
@@ -236,7 +236,7 @@ var HumeSpeechModel = class {
236
236
  };
237
237
 
238
238
  // src/version.ts
239
- var VERSION = true ? "0.0.0-1c33ba03-20260114162300" : "0.0.0-test";
239
+ var VERSION = true ? "0.0.0-4115c213-20260122152721" : "0.0.0-test";
240
240
 
241
241
  // src/hume-provider.ts
242
242
  function createHume(options = {}) {
package/dist/index.mjs CHANGED
@@ -216,7 +216,7 @@ var HumeSpeechModel = class {
216
216
  };
217
217
 
218
218
  // src/version.ts
219
- var VERSION = true ? "0.0.0-1c33ba03-20260114162300" : "0.0.0-test";
219
+ var VERSION = true ? "0.0.0-4115c213-20260122152721" : "0.0.0-test";
220
220
 
221
221
  // src/hume-provider.ts
222
222
  function createHume(options = {}) {
@@ -0,0 +1,103 @@
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', 'bun']}>
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
+
25
+ <Tab>
26
+ <Snippet text="bun add @ai-sdk/hume" dark />
27
+ </Tab>
28
+ </Tabs>
29
+
30
+ ## Provider Instance
31
+
32
+ You can import the default provider instance `hume` from `@ai-sdk/hume`:
33
+
34
+ ```ts
35
+ import { hume } from '@ai-sdk/hume';
36
+ ```
37
+
38
+ If you need a customized setup, you can import `createHume` from `@ai-sdk/hume` and create a provider instance with your settings:
39
+
40
+ ```ts
41
+ import { createHume } from '@ai-sdk/hume';
42
+
43
+ const hume = createHume({
44
+ // custom settings, e.g.
45
+ fetch: customFetch,
46
+ });
47
+ ```
48
+
49
+ You can use the following optional settings to customize the Hume provider instance:
50
+
51
+ - **apiKey** _string_
52
+
53
+ API key that is being sent using the `Authorization` header.
54
+ It defaults to the `HUME_API_KEY` environment variable.
55
+
56
+ - **headers** _Record&lt;string,string&gt;_
57
+
58
+ Custom headers to include in the requests.
59
+
60
+ - **fetch** _(input: RequestInfo, init?: RequestInit) => Promise&lt;Response&gt;_
61
+
62
+ Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
63
+ Defaults to the global `fetch` function.
64
+ You can use it as a middleware to intercept requests,
65
+ or to provide a custom fetch implementation for e.g. testing.
66
+
67
+ ## Speech Models
68
+
69
+ You can create models that call the [Hume speech API](https://dev.hume.ai/docs/text-to-speech-tts/overview)
70
+ using the `.speech()` factory method.
71
+
72
+ ```ts
73
+ const model = hume.speech();
74
+ ```
75
+
76
+ You can also pass additional provider-specific options using the `providerOptions` argument. For example, supplying a voice to use for the generated audio.
77
+
78
+ ```ts highlight="6"
79
+ import { experimental_generateSpeech as generateSpeech } from 'ai';
80
+ import { hume } from '@ai-sdk/hume';
81
+
82
+ const result = await generateSpeech({
83
+ model: hume.speech(),
84
+ text: 'Hello, world!',
85
+ voice: 'd8ab67c6-953d-4bd8-9370-8fa53a0f1453',
86
+ providerOptions: { hume: {} },
87
+ });
88
+ ```
89
+
90
+ The following provider options are available:
91
+
92
+ - **context** _object_
93
+
94
+ Either:
95
+
96
+ - `{ generationId: string }` - A generation ID to use for context.
97
+ - `{ utterances: HumeUtterance[] }` - An array of utterance objects for context.
98
+
99
+ ### Model Capabilities
100
+
101
+ | Model | Instructions |
102
+ | --------- | ------------------- |
103
+ | `default` | <Check size={18} /> |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/hume",
3
- "version": "0.0.0-1c33ba03-20260114162300",
3
+ "version": "0.0.0-4115c213-20260122152721",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -8,9 +8,18 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "files": [
10
10
  "dist/**/*",
11
+ "docs/**/*",
12
+ "src",
13
+ "!src/**/*.test.ts",
14
+ "!src/**/*.test-d.ts",
15
+ "!src/**/__snapshots__",
16
+ "!src/**/__fixtures__",
11
17
  "CHANGELOG.md",
12
18
  "README.md"
13
19
  ],
20
+ "directories": {
21
+ "doc": "./docs"
22
+ },
14
23
  "exports": {
15
24
  "./package.json": "./package.json",
16
25
  ".": {
@@ -20,16 +29,16 @@
20
29
  }
21
30
  },
22
31
  "dependencies": {
23
- "@ai-sdk/provider": "3.0.3",
24
- "@ai-sdk/provider-utils": "0.0.0-1c33ba03-20260114162300"
32
+ "@ai-sdk/provider": "0.0.0-4115c213-20260122152721",
33
+ "@ai-sdk/provider-utils": "0.0.0-4115c213-20260122152721"
25
34
  },
26
35
  "devDependencies": {
27
36
  "@types/node": "20.17.24",
28
37
  "tsup": "^8",
29
38
  "typescript": "5.6.3",
30
39
  "zod": "3.25.76",
31
- "@vercel/ai-tsconfig": "0.0.0",
32
- "@ai-sdk/test-server": "1.0.1"
40
+ "@ai-sdk/test-server": "0.0.0-4115c213-20260122152721",
41
+ "@vercel/ai-tsconfig": "0.0.0"
33
42
  },
34
43
  "peerDependencies": {
35
44
  "zod": "^3.25.76 || ^4.1.8"
@@ -54,7 +63,7 @@
54
63
  "scripts": {
55
64
  "build": "tsup --tsconfig tsconfig.build.json",
56
65
  "build:watch": "tsup --tsconfig tsconfig.build.json --watch",
57
- "clean": "del-cli dist",
66
+ "clean": "del-cli dist docs",
58
67
  "lint": "eslint \"./**/*.ts*\"",
59
68
  "type-check": "tsc --noEmit",
60
69
  "prettier-check": "prettier --check \"./**/*.ts*\"",
@@ -0,0 +1,29 @@
1
+ type HumeSpeechAPIUtterances = Array<{
2
+ text: string;
3
+ description?: string;
4
+ speed?: number;
5
+ trailing_silence?: number;
6
+ voice?:
7
+ | {
8
+ id: string;
9
+ provider?: 'HUME_AI' | 'CUSTOM_VOICE';
10
+ }
11
+ | {
12
+ name: string;
13
+ provider?: 'HUME_AI' | 'CUSTOM_VOICE';
14
+ };
15
+ }>;
16
+
17
+ export type HumeSpeechAPITypes = {
18
+ utterances: HumeSpeechAPIUtterances;
19
+ context?:
20
+ | {
21
+ generation_id: string;
22
+ }
23
+ | {
24
+ utterances: HumeSpeechAPIUtterances;
25
+ };
26
+ format: {
27
+ type: 'mp3' | 'pcm' | 'wav';
28
+ };
29
+ };
@@ -0,0 +1,9 @@
1
+ import { FetchFunction } from '@ai-sdk/provider-utils';
2
+
3
+ export type HumeConfig = {
4
+ provider: string;
5
+ url: (options: { modelId: string; path: string }) => string;
6
+ headers: () => Record<string, string | undefined>;
7
+ fetch?: FetchFunction;
8
+ generateId?: () => string;
9
+ };
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod/v4';
2
+ import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';
3
+
4
+ export const humeErrorDataSchema = z.object({
5
+ error: z.object({
6
+ message: z.string(),
7
+ code: z.number(),
8
+ }),
9
+ });
10
+
11
+ export type HumeErrorData = z.infer<typeof humeErrorDataSchema>;
12
+
13
+ export const humeFailedResponseHandler = createJsonErrorResponseHandler({
14
+ errorSchema: humeErrorDataSchema,
15
+ errorToMessage: data => data.error.message,
16
+ });
@@ -0,0 +1,79 @@
1
+ import { SpeechModelV3, ProviderV3 } from '@ai-sdk/provider';
2
+ import {
3
+ FetchFunction,
4
+ loadApiKey,
5
+ withUserAgentSuffix,
6
+ } from '@ai-sdk/provider-utils';
7
+ import { HumeSpeechModel } from './hume-speech-model';
8
+ import { VERSION } from './version';
9
+
10
+ export interface HumeProvider extends Pick<ProviderV3, 'speechModel'> {
11
+ (settings?: {}): {
12
+ speech: HumeSpeechModel;
13
+ };
14
+
15
+ /**
16
+ Creates a model for speech synthesis.
17
+ */
18
+ speech(): SpeechModelV3;
19
+ }
20
+
21
+ export interface HumeProviderSettings {
22
+ /**
23
+ API key for authenticating requests.
24
+ */
25
+ apiKey?: string;
26
+
27
+ /**
28
+ Custom headers to include in the requests.
29
+ */
30
+ headers?: Record<string, string>;
31
+
32
+ /**
33
+ Custom fetch implementation. You can use it as a middleware to intercept requests,
34
+ or to provide a custom fetch implementation for e.g. testing.
35
+ */
36
+ fetch?: FetchFunction;
37
+ }
38
+
39
+ /**
40
+ Create an Hume provider instance.
41
+ */
42
+ export function createHume(options: HumeProviderSettings = {}): HumeProvider {
43
+ const getHeaders = () =>
44
+ withUserAgentSuffix(
45
+ {
46
+ 'X-Hume-Api-Key': loadApiKey({
47
+ apiKey: options.apiKey,
48
+ environmentVariableName: 'HUME_API_KEY',
49
+ description: 'Hume',
50
+ }),
51
+ ...options.headers,
52
+ },
53
+ `ai-sdk/hume/${VERSION}`,
54
+ );
55
+
56
+ const createSpeechModel = () =>
57
+ new HumeSpeechModel('', {
58
+ provider: `hume.speech`,
59
+ url: ({ path }) => `https://api.hume.ai${path}`,
60
+ headers: getHeaders,
61
+ fetch: options.fetch,
62
+ });
63
+
64
+ const provider = function () {
65
+ return {
66
+ speech: createSpeechModel(),
67
+ };
68
+ };
69
+
70
+ provider.speech = createSpeechModel;
71
+ provider.speechModel = createSpeechModel;
72
+
73
+ return provider satisfies HumeProvider;
74
+ }
75
+
76
+ /**
77
+ Default Hume provider instance.
78
+ */
79
+ export const hume = createHume();
@@ -0,0 +1,238 @@
1
+ import { SpeechModelV3, SharedV3Warning } from '@ai-sdk/provider';
2
+ import {
3
+ combineHeaders,
4
+ createBinaryResponseHandler,
5
+ parseProviderOptions,
6
+ postJsonToApi,
7
+ } from '@ai-sdk/provider-utils';
8
+ import { z } from 'zod/v4';
9
+ import { HumeConfig } from './hume-config';
10
+ import { humeFailedResponseHandler } from './hume-error';
11
+ import { HumeSpeechAPITypes } from './hume-api-types';
12
+
13
+ // https://dev.hume.ai/reference/text-to-speech-tts/synthesize-file
14
+ const humeSpeechCallOptionsSchema = z.object({
15
+ /**
16
+ * Context for the speech synthesis request.
17
+ * Can be either a generationId for retrieving a previous generation,
18
+ * or a list of utterances to synthesize.
19
+ */
20
+ context: z
21
+ .object({
22
+ /**
23
+ * ID of a previously generated speech synthesis to retrieve.
24
+ */
25
+ generationId: z.string(),
26
+ })
27
+ .or(
28
+ z.object({
29
+ /**
30
+ * List of utterances to synthesize into speech.
31
+ */
32
+ utterances: z.array(
33
+ z.object({
34
+ /**
35
+ * The text content to convert to speech.
36
+ */
37
+ text: z.string(),
38
+ /**
39
+ * Optional description or instructions for how the text should be spoken.
40
+ */
41
+ description: z.string().optional(),
42
+ /**
43
+ * Optional speech rate multiplier.
44
+ */
45
+ speed: z.number().optional(),
46
+ /**
47
+ * Optional duration of silence to add after the utterance in seconds.
48
+ */
49
+ trailingSilence: z.number().optional(),
50
+ /**
51
+ * Voice configuration for the utterance.
52
+ * Can be specified by ID or name.
53
+ */
54
+ voice: z
55
+ .object({
56
+ /**
57
+ * ID of the voice to use.
58
+ */
59
+ id: z.string(),
60
+ /**
61
+ * Provider of the voice, either Hume's built-in voices or a custom voice.
62
+ */
63
+ provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),
64
+ })
65
+ .or(
66
+ z.object({
67
+ /**
68
+ * Name of the voice to use.
69
+ */
70
+ name: z.string(),
71
+ /**
72
+ * Provider of the voice, either Hume's built-in voices or a custom voice.
73
+ */
74
+ provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),
75
+ }),
76
+ )
77
+ .optional(),
78
+ }),
79
+ ),
80
+ }),
81
+ )
82
+ .nullish(),
83
+ });
84
+
85
+ export type HumeSpeechCallOptions = z.infer<typeof humeSpeechCallOptionsSchema>;
86
+
87
+ interface HumeSpeechModelConfig extends HumeConfig {
88
+ _internal?: {
89
+ currentDate?: () => Date;
90
+ };
91
+ }
92
+
93
+ export class HumeSpeechModel implements SpeechModelV3 {
94
+ readonly specificationVersion = 'v3';
95
+
96
+ get provider(): string {
97
+ return this.config.provider;
98
+ }
99
+
100
+ constructor(
101
+ readonly modelId: '',
102
+ private readonly config: HumeSpeechModelConfig,
103
+ ) {}
104
+
105
+ private async getArgs({
106
+ text,
107
+ voice = 'd8ab67c6-953d-4bd8-9370-8fa53a0f1453',
108
+ outputFormat = 'mp3',
109
+ speed,
110
+ instructions,
111
+ language,
112
+ providerOptions,
113
+ }: Parameters<SpeechModelV3['doGenerate']>[0]) {
114
+ const warnings: SharedV3Warning[] = [];
115
+
116
+ // Parse provider options
117
+ const humeOptions = await parseProviderOptions({
118
+ provider: 'hume',
119
+ providerOptions,
120
+ schema: humeSpeechCallOptionsSchema,
121
+ });
122
+
123
+ // Create request body
124
+ const requestBody: HumeSpeechAPITypes = {
125
+ utterances: [
126
+ {
127
+ text,
128
+ speed,
129
+ description: instructions,
130
+ voice: {
131
+ id: voice,
132
+ provider: 'HUME_AI',
133
+ },
134
+ },
135
+ ],
136
+ format: { type: 'mp3' },
137
+ };
138
+
139
+ if (outputFormat) {
140
+ if (['mp3', 'pcm', 'wav'].includes(outputFormat)) {
141
+ requestBody.format = { type: outputFormat as 'mp3' | 'pcm' | 'wav' };
142
+ } else {
143
+ warnings.push({
144
+ type: 'unsupported',
145
+ feature: 'outputFormat',
146
+ details: `Unsupported output format: ${outputFormat}. Using mp3 instead.`,
147
+ });
148
+ }
149
+ }
150
+
151
+ // Add provider-specific options
152
+ if (humeOptions) {
153
+ const speechModelOptions: Omit<
154
+ HumeSpeechAPITypes,
155
+ 'utterances' | 'format'
156
+ > = {};
157
+
158
+ if (humeOptions.context) {
159
+ if ('generationId' in humeOptions.context) {
160
+ speechModelOptions.context = {
161
+ generation_id: humeOptions.context.generationId,
162
+ };
163
+ } else {
164
+ speechModelOptions.context = {
165
+ utterances: humeOptions.context.utterances.map(utterance => ({
166
+ text: utterance.text,
167
+ description: utterance.description,
168
+ speed: utterance.speed,
169
+ trailing_silence: utterance.trailingSilence,
170
+ voice: utterance.voice,
171
+ })),
172
+ };
173
+ }
174
+ }
175
+
176
+ for (const key in speechModelOptions) {
177
+ const value =
178
+ speechModelOptions[
179
+ key as keyof Omit<HumeSpeechAPITypes, 'utterances' | 'format'>
180
+ ];
181
+ if (value !== undefined) {
182
+ (requestBody as Record<string, unknown>)[key] = value;
183
+ }
184
+ }
185
+ }
186
+
187
+ if (language) {
188
+ warnings.push({
189
+ type: 'unsupported',
190
+ feature: 'language',
191
+ details: `Hume speech models do not support language selection. Language parameter "${language}" was ignored.`,
192
+ });
193
+ }
194
+
195
+ return {
196
+ requestBody,
197
+ warnings,
198
+ };
199
+ }
200
+
201
+ async doGenerate(
202
+ options: Parameters<SpeechModelV3['doGenerate']>[0],
203
+ ): Promise<Awaited<ReturnType<SpeechModelV3['doGenerate']>>> {
204
+ const currentDate = this.config._internal?.currentDate?.() ?? new Date();
205
+ const { requestBody, warnings } = await this.getArgs(options);
206
+
207
+ const {
208
+ value: audio,
209
+ responseHeaders,
210
+ rawValue: rawResponse,
211
+ } = await postJsonToApi({
212
+ url: this.config.url({
213
+ path: '/v0/tts/file',
214
+ modelId: this.modelId,
215
+ }),
216
+ headers: combineHeaders(this.config.headers(), options.headers),
217
+ body: requestBody,
218
+ failedResponseHandler: humeFailedResponseHandler,
219
+ successfulResponseHandler: createBinaryResponseHandler(),
220
+ abortSignal: options.abortSignal,
221
+ fetch: this.config.fetch,
222
+ });
223
+
224
+ return {
225
+ audio,
226
+ warnings,
227
+ request: {
228
+ body: JSON.stringify(requestBody),
229
+ },
230
+ response: {
231
+ timestamp: currentDate,
232
+ modelId: this.modelId,
233
+ headers: responseHeaders,
234
+ body: rawResponse,
235
+ },
236
+ };
237
+ }
238
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { createHume, hume } from './hume-provider';
2
+ export type { HumeProvider, HumeProviderSettings } from './hume-provider';
3
+ export { VERSION } from './version';
package/src/version.ts ADDED
@@ -0,0 +1,6 @@
1
+ // Version string of this package injected at build time.
2
+ declare const __PACKAGE_VERSION__: string | undefined;
3
+ export const VERSION: string =
4
+ typeof __PACKAGE_VERSION__ !== 'undefined'
5
+ ? __PACKAGE_VERSION__
6
+ : '0.0.0-test';