@ai-sdk/hume 3.0.64 → 3.0.66

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,5 +1,22 @@
1
1
  # @ai-sdk/hume
2
2
 
3
+ ## 3.0.66
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [10026d1]
8
+ - @ai-sdk/provider@4.0.32
9
+ - @ai-sdk/provider-utils@5.0.66
10
+
11
+ ## 3.0.65
12
+
13
+ ### Patch Changes
14
+
15
+ - 489a00d: Defer construction of provider validation schemas until first use to reduce package import time.
16
+ - Updated dependencies [b089ce8]
17
+ - Updated dependencies [39a776b]
18
+ - @ai-sdk/provider-utils@5.0.65
19
+
3
20
  ## 3.0.64
4
21
 
5
22
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { ProviderV4, SpeechModelV4 } from "@ai-sdk/provider";
2
- import { FetchFunction, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "@ai-sdk/provider-utils";
3
- import { z } from "zod/v4";
2
+ import { FetchFunction, InferSchema, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "@ai-sdk/provider-utils";
4
3
  //#region src/hume-config.d.ts
5
4
  type HumeConfig = {
6
5
  provider: string;
@@ -72,32 +71,26 @@ export declare function createHume(options?: HumeProviderSettings): HumeProvider
72
71
  export declare const hume: HumeProvider;
73
72
  //#endregion
74
73
  //#region src/hume-speech-model-options.d.ts
75
- declare const humeSpeechModelOptionsSchema: z.ZodObject<{
76
- context: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
77
- generationId: z.ZodString;
78
- }, z.core.$strip>, z.ZodObject<{
79
- utterances: z.ZodArray<z.ZodObject<{
80
- text: z.ZodString;
81
- description: z.ZodOptional<z.ZodString>;
82
- speed: z.ZodOptional<z.ZodNumber>;
83
- trailingSilence: z.ZodOptional<z.ZodNumber>;
84
- voice: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
85
- id: z.ZodString;
86
- provider: z.ZodOptional<z.ZodEnum<{
87
- HUME_AI: "HUME_AI";
88
- CUSTOM_VOICE: "CUSTOM_VOICE";
89
- }>>;
90
- }, z.core.$strip>, z.ZodObject<{
91
- name: z.ZodString;
92
- provider: z.ZodOptional<z.ZodEnum<{
93
- HUME_AI: "HUME_AI";
94
- CUSTOM_VOICE: "CUSTOM_VOICE";
95
- }>>;
96
- }, z.core.$strip>]>>;
97
- }, z.core.$strip>>;
98
- }, z.core.$strip>]>>>;
99
- }, z.core.$strip>;
100
- type HumeSpeechModelOptions = z.infer<typeof humeSpeechModelOptionsSchema>;
74
+ declare const humeSpeechModelOptionsSchema: import("@ai-sdk/provider-utils").LazySchema<{
75
+ context?: {
76
+ generationId: string;
77
+ } | {
78
+ utterances: {
79
+ text: string;
80
+ description?: string | undefined;
81
+ speed?: number | undefined;
82
+ trailingSilence?: number | undefined;
83
+ voice?: {
84
+ id: string;
85
+ provider?: "HUME_AI" | "CUSTOM_VOICE" | undefined;
86
+ } | {
87
+ name: string;
88
+ provider?: "HUME_AI" | "CUSTOM_VOICE" | undefined;
89
+ } | undefined;
90
+ }[];
91
+ } | null | undefined;
92
+ }>;
93
+ type HumeSpeechModelOptions = InferSchema<typeof humeSpeechModelOptionsSchema>;
101
94
  //#endregion
102
95
  //#region src/version.d.ts
103
96
  export declare const VERSION: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/hume-config.ts","../src/hume-speech-model.ts","../src/hume-provider.ts","../src/hume-speech-model-options.ts","../src/version.ts"],"mappings":";;;;KAEY;EACV;EACA,MAAM;IAAW;IAAiB;;EAClC,gBAAgB;EAChB,QAAQ;EACR;;;;UCQQ,8BAA8B;EACtC;IACE,oBAAoB;;;cAIX,2BAA2B;WAsB3B;mBACQ;WAtBV;MAEL;UAII,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B;IACA,QAAQ;MACT;EAKU,YAAA,aACQ,QAAQ;UAGb;EAgGR,WACJ,SAAS,WAAW,kCACnB,QAAQ,QAAQ,WAAW;;;;UCpIf,qBAAqB;GACnC;IACC,QAAQ;;;;;EAMV,UAAU;;UAGK;;;;EAIf;;;;EAKA,UAAU;;;;;EAMV,QAAQ;;;;;wBAMM,WAAW,UAAS,uBAA4B;;;;qBA8DnD,MAAI;;;cCxGJ,8BAA4B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;GAqEvC,EAAA,KAAA;KAEU,yBAAyB,EAAE,aAC9B;;;qBCzEI"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/hume-config.ts","../src/hume-speech-model.ts","../src/hume-provider.ts","../src/hume-speech-model-options.ts","../src/version.ts"],"mappings":";;;KAEY;EACV;EACA,MAAM;IAAW;IAAiB;;EAClC,gBAAgB;EAChB,QAAQ;EACR;;;;UCQQ,8BAA8B;EACtC;IACE,oBAAoB;;;cAIX,2BAA2B;WAsB3B;mBACQ;WAtBV;MAEL;UAII,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B;IACA,QAAQ;MACT;EAKU,YAAA,aACQ,QAAQ;UAGb;EAgGR,WACJ,SAAS,WAAW,kCACnB,QAAQ,QAAQ,WAAW;;;;UCpIf,qBAAqB;GACnC;IACC,QAAQ;;;;;EAMV,UAAU;;UAGK;;;;EAIf;;;;EAKA,UAAU;;;;;EAMV,QAAQ;;;;;wBAMM,WAAW,UAAS,uBAA4B;;;;qBA8DnD,MAAI;;;cCnGJ,+DAA4B;;;;;;;;;;;;;;;;;;;KA2E7B,yBAAyB,mBAC5B;;;qBClFI"}
package/dist/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import { NoSuchModelError } from "@ai-sdk/provider";
2
- import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, createBinaryResponseHandler, createJsonErrorResponseHandler, loadApiKey, parseProviderOptions, postJsonToApi, serializeModelOptions, withUserAgentSuffix } from "@ai-sdk/provider-utils";
2
+ import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, createBinaryResponseHandler, createJsonErrorResponseHandler, lazySchema, loadApiKey, parseProviderOptions, postJsonToApi, serializeModelOptions, withUserAgentSuffix, zodSchema } from "@ai-sdk/provider-utils";
3
3
  import { z } from "zod/v4";
4
4
  //#region src/hume-error.ts
5
- const humeErrorDataSchema = z.object({ error: z.object({
5
+ const humeErrorDataSchema = lazySchema(() => zodSchema(z.object({ error: z.object({
6
6
  message: z.string(),
7
7
  code: z.number()
8
- }) });
8
+ }) })));
9
9
  const humeFailedResponseHandler = createJsonErrorResponseHandler({
10
10
  errorSchema: humeErrorDataSchema,
11
11
  errorToMessage: (data) => data.error.message
12
12
  });
13
13
  //#endregion
14
14
  //#region src/hume-speech-model-options.ts
15
- const humeSpeechModelOptionsSchema = z.object({
15
+ const humeSpeechModelOptionsSchema = lazySchema(() => zodSchema(z.object({
16
16
  /**
17
17
  * Context for the speech synthesis request.
18
18
  * Can be either a generationId for retrieving a previous generation,
@@ -66,7 +66,7 @@ utterances: z.array(z.object({
66
66
  */
67
67
  provider: z.enum(["HUME_AI", "CUSTOM_VOICE"]).optional()
68
68
  })).optional()
69
- })) })).nullish() });
69
+ })) })).nullish() })));
70
70
  //#endregion
71
71
  //#region src/hume-speech-model.ts
72
72
  var HumeSpeechModel = class HumeSpeechModel {
@@ -175,7 +175,7 @@ var HumeSpeechModel = class HumeSpeechModel {
175
175
  };
176
176
  //#endregion
177
177
  //#region src/version.ts
178
- const VERSION = "3.0.64";
178
+ const VERSION = "3.0.66";
179
179
  //#endregion
180
180
  //#region src/hume-provider.ts
181
181
  /**
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/hume-error.ts","../src/hume-speech-model-options.ts","../src/hume-speech-model.ts","../src/version.ts","../src/hume-provider.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';\n\nexport const humeErrorDataSchema = z.object({\n error: z.object({\n message: z.string(),\n code: z.number(),\n }),\n});\n\nexport type HumeErrorData = z.infer<typeof humeErrorDataSchema>;\n\nexport const humeFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: humeErrorDataSchema,\n errorToMessage: data => data.error.message,\n});\n","import { z } from 'zod/v4';\n\n// https://dev.hume.ai/reference/text-to-speech-tts/synthesize-file\nexport const humeSpeechModelOptionsSchema = z.object({\n /**\n * Context for the speech synthesis request.\n * Can be either a generationId for retrieving a previous generation,\n * or a list of utterances to synthesize.\n */\n context: z\n .object({\n /**\n * ID of a previously generated speech synthesis to retrieve.\n */\n generationId: z.string(),\n })\n .or(\n z.object({\n /**\n * List of utterances to synthesize into speech.\n */\n utterances: z.array(\n z.object({\n /**\n * The text content to convert to speech.\n */\n text: z.string(),\n /**\n * Optional description or instructions for how the text should be spoken.\n */\n description: z.string().optional(),\n /**\n * Optional speech rate multiplier.\n */\n speed: z.number().optional(),\n /**\n * Optional duration of silence to add after the utterance in seconds.\n */\n trailingSilence: z.number().optional(),\n /**\n * Voice configuration for the utterance.\n * Can be specified by ID or name.\n */\n voice: z\n .object({\n /**\n * ID of the voice to use.\n */\n id: z.string(),\n /**\n * Provider of the voice, either Hume's built-in voices or a custom voice.\n */\n provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),\n })\n .or(\n z.object({\n /**\n * Name of the voice to use.\n */\n name: z.string(),\n /**\n * Provider of the voice, either Hume's built-in voices or a custom voice.\n */\n provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),\n }),\n )\n .optional(),\n }),\n ),\n }),\n )\n .nullish(),\n});\n\nexport type HumeSpeechModelOptions = z.infer<\n typeof humeSpeechModelOptionsSchema\n>;\n","import type { SpeechModelV4, SharedV4Warning } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createBinaryResponseHandler,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n} from '@ai-sdk/provider-utils';\nimport type { HumeConfig } from './hume-config';\nimport { humeFailedResponseHandler } from './hume-error';\nimport { humeSpeechModelOptionsSchema } from './hume-speech-model-options';\nimport type { HumeSpeechAPITypes } from './hume-api-types';\n\ninterface HumeSpeechModelConfig extends HumeConfig {\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class HumeSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: HumeSpeechModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: '';\n config: HumeSpeechModelConfig;\n }) {\n return new HumeSpeechModel(options.modelId as '', options.config);\n }\n\n constructor(\n readonly modelId: '',\n private readonly config: HumeSpeechModelConfig,\n ) {}\n\n private async getArgs({\n text,\n voice = 'd8ab67c6-953d-4bd8-9370-8fa53a0f1453',\n outputFormat = 'mp3',\n speed,\n instructions,\n language,\n providerOptions,\n }: Parameters<SpeechModelV4['doGenerate']>[0]) {\n const warnings: SharedV4Warning[] = [];\n\n // Parse provider options\n const humeOptions = await parseProviderOptions({\n provider: 'hume',\n providerOptions,\n schema: humeSpeechModelOptionsSchema,\n });\n\n // Create request body\n const requestBody: HumeSpeechAPITypes = {\n utterances: [\n {\n text,\n speed,\n description: instructions,\n voice: {\n id: voice,\n provider: 'HUME_AI',\n },\n },\n ],\n format: { type: 'mp3' },\n };\n\n if (outputFormat) {\n if (['mp3', 'pcm', 'wav'].includes(outputFormat)) {\n requestBody.format = { type: outputFormat as 'mp3' | 'pcm' | 'wav' };\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'outputFormat',\n details: `Unsupported output format: ${outputFormat}. Using mp3 instead.`,\n });\n }\n }\n\n // Add provider-specific options\n if (humeOptions) {\n const speechModelOptions: Omit<\n HumeSpeechAPITypes,\n 'utterances' | 'format'\n > = {};\n\n if (humeOptions.context) {\n if ('generationId' in humeOptions.context) {\n speechModelOptions.context = {\n generation_id: humeOptions.context.generationId,\n };\n } else {\n speechModelOptions.context = {\n utterances: humeOptions.context.utterances.map(utterance => ({\n text: utterance.text,\n description: utterance.description,\n speed: utterance.speed,\n trailing_silence: utterance.trailingSilence,\n voice: utterance.voice,\n })),\n };\n }\n }\n\n for (const key in speechModelOptions) {\n const value =\n speechModelOptions[\n key as keyof Omit<HumeSpeechAPITypes, 'utterances' | 'format'>\n ];\n if (value !== undefined) {\n (requestBody as Record<string, unknown>)[key] = value;\n }\n }\n }\n\n if (language) {\n warnings.push({\n type: 'unsupported',\n feature: 'language',\n details: `Hume speech models do not support language selection. Language parameter \"${language}\" was ignored.`,\n });\n }\n\n return {\n requestBody,\n warnings,\n };\n }\n\n async doGenerate(\n options: Parameters<SpeechModelV4['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { requestBody, warnings } = await this.getArgs(options);\n\n const {\n value: audio,\n responseHeaders,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: this.config.url({\n path: '/v0/tts/file',\n modelId: this.modelId,\n }),\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body: requestBody,\n failedResponseHandler: humeFailedResponseHandler,\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n audio,\n warnings,\n request: {\n body: JSON.stringify(requestBody),\n },\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawResponse,\n },\n };\n }\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import {\n NoSuchModelError,\n type SpeechModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { HumeSpeechModel } from './hume-speech-model';\nimport { VERSION } from './version';\n\nexport interface HumeProvider extends ProviderV4 {\n (settings?: {}): {\n speech: HumeSpeechModel;\n };\n\n /**\n * Creates a model for speech synthesis.\n */\n speech(): SpeechModelV4;\n}\n\nexport interface HumeProviderSettings {\n /**\n * API key for authenticating requests.\n */\n apiKey?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\n * Create an Hume provider instance.\n */\nexport function createHume(options: HumeProviderSettings = {}): HumeProvider {\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n 'X-Hume-Api-Key': loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'HUME_API_KEY',\n description: 'Hume',\n }),\n ...options.headers,\n },\n `ai-sdk-hume/${VERSION}`,\n );\n\n const createSpeechModel = () =>\n new HumeSpeechModel('', {\n provider: `hume.speech`,\n url: ({ path }) => `https://api.hume.ai${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = function () {\n return {\n speech: createSpeechModel(),\n };\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n provider.languageModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'languageModel',\n message: 'Hume does not provide language models',\n });\n };\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n message: 'Hume does not provide embedding models',\n });\n };\n\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'imageModel',\n message: 'Hume does not provide image models',\n });\n };\n\n return provider as HumeProvider;\n}\n\n/**\n * Default Hume provider instance.\n */\nexport const hume = createHume();\n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ACX,CAAC;CACH;CAEA,OAAO;AACT;;;;AAKA,MAAa,OAAO,WAAW"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/hume-error.ts","../src/hume-speech-model-options.ts","../src/hume-speech-model.ts","../src/version.ts","../src/hume-provider.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport {\n lazySchema,\n zodSchema,\n type InferSchema,\n createJsonErrorResponseHandler,\n} from '@ai-sdk/provider-utils';\n\nexport const humeErrorDataSchema = lazySchema(() =>\n zodSchema(\n z.object({\n error: z.object({\n message: z.string(),\n code: z.number(),\n }),\n }),\n ),\n);\n\nexport type HumeErrorData = InferSchema<typeof humeErrorDataSchema>;\n\nexport const humeFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: humeErrorDataSchema,\n errorToMessage: data => data.error.message,\n});\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://dev.hume.ai/reference/text-to-speech-tts/synthesize-file\nexport const humeSpeechModelOptionsSchema = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * Context for the speech synthesis request.\n * Can be either a generationId for retrieving a previous generation,\n * or a list of utterances to synthesize.\n */\n context: z\n .object({\n /**\n * ID of a previously generated speech synthesis to retrieve.\n */\n generationId: z.string(),\n })\n .or(\n z.object({\n /**\n * List of utterances to synthesize into speech.\n */\n utterances: z.array(\n z.object({\n /**\n * The text content to convert to speech.\n */\n text: z.string(),\n /**\n * Optional description or instructions for how the text should be spoken.\n */\n description: z.string().optional(),\n /**\n * Optional speech rate multiplier.\n */\n speed: z.number().optional(),\n /**\n * Optional duration of silence to add after the utterance in seconds.\n */\n trailingSilence: z.number().optional(),\n /**\n * Voice configuration for the utterance.\n * Can be specified by ID or name.\n */\n voice: z\n .object({\n /**\n * ID of the voice to use.\n */\n id: z.string(),\n /**\n * Provider of the voice, either Hume's built-in voices or a custom voice.\n */\n provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),\n })\n .or(\n z.object({\n /**\n * Name of the voice to use.\n */\n name: z.string(),\n /**\n * Provider of the voice, either Hume's built-in voices or a custom voice.\n */\n provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),\n }),\n )\n .optional(),\n }),\n ),\n }),\n )\n .nullish(),\n }),\n ),\n);\n\nexport type HumeSpeechModelOptions = InferSchema<\n typeof humeSpeechModelOptionsSchema\n>;\n","import type { SpeechModelV4, SharedV4Warning } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n createBinaryResponseHandler,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n} from '@ai-sdk/provider-utils';\nimport type { HumeConfig } from './hume-config';\nimport { humeFailedResponseHandler } from './hume-error';\nimport { humeSpeechModelOptionsSchema } from './hume-speech-model-options';\nimport type { HumeSpeechAPITypes } from './hume-api-types';\n\ninterface HumeSpeechModelConfig extends HumeConfig {\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class HumeSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: HumeSpeechModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: '';\n config: HumeSpeechModelConfig;\n }) {\n return new HumeSpeechModel(options.modelId as '', options.config);\n }\n\n constructor(\n readonly modelId: '',\n private readonly config: HumeSpeechModelConfig,\n ) {}\n\n private async getArgs({\n text,\n voice = 'd8ab67c6-953d-4bd8-9370-8fa53a0f1453',\n outputFormat = 'mp3',\n speed,\n instructions,\n language,\n providerOptions,\n }: Parameters<SpeechModelV4['doGenerate']>[0]) {\n const warnings: SharedV4Warning[] = [];\n\n // Parse provider options\n const humeOptions = await parseProviderOptions({\n provider: 'hume',\n providerOptions,\n schema: humeSpeechModelOptionsSchema,\n });\n\n // Create request body\n const requestBody: HumeSpeechAPITypes = {\n utterances: [\n {\n text,\n speed,\n description: instructions,\n voice: {\n id: voice,\n provider: 'HUME_AI',\n },\n },\n ],\n format: { type: 'mp3' },\n };\n\n if (outputFormat) {\n if (['mp3', 'pcm', 'wav'].includes(outputFormat)) {\n requestBody.format = { type: outputFormat as 'mp3' | 'pcm' | 'wav' };\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'outputFormat',\n details: `Unsupported output format: ${outputFormat}. Using mp3 instead.`,\n });\n }\n }\n\n // Add provider-specific options\n if (humeOptions) {\n const speechModelOptions: Omit<\n HumeSpeechAPITypes,\n 'utterances' | 'format'\n > = {};\n\n if (humeOptions.context) {\n if ('generationId' in humeOptions.context) {\n speechModelOptions.context = {\n generation_id: humeOptions.context.generationId,\n };\n } else {\n speechModelOptions.context = {\n utterances: humeOptions.context.utterances.map(utterance => ({\n text: utterance.text,\n description: utterance.description,\n speed: utterance.speed,\n trailing_silence: utterance.trailingSilence,\n voice: utterance.voice,\n })),\n };\n }\n }\n\n for (const key in speechModelOptions) {\n const value =\n speechModelOptions[\n key as keyof Omit<HumeSpeechAPITypes, 'utterances' | 'format'>\n ];\n if (value !== undefined) {\n (requestBody as Record<string, unknown>)[key] = value;\n }\n }\n }\n\n if (language) {\n warnings.push({\n type: 'unsupported',\n feature: 'language',\n details: `Hume speech models do not support language selection. Language parameter \"${language}\" was ignored.`,\n });\n }\n\n return {\n requestBody,\n warnings,\n };\n }\n\n async doGenerate(\n options: Parameters<SpeechModelV4['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { requestBody, warnings } = await this.getArgs(options);\n\n const {\n value: audio,\n responseHeaders,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: this.config.url({\n path: '/v0/tts/file',\n modelId: this.modelId,\n }),\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body: requestBody,\n failedResponseHandler: humeFailedResponseHandler,\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n audio,\n warnings,\n request: {\n body: JSON.stringify(requestBody),\n },\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawResponse,\n },\n };\n }\n}\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import {\n NoSuchModelError,\n type SpeechModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { HumeSpeechModel } from './hume-speech-model';\nimport { VERSION } from './version';\n\nexport interface HumeProvider extends ProviderV4 {\n (settings?: {}): {\n speech: HumeSpeechModel;\n };\n\n /**\n * Creates a model for speech synthesis.\n */\n speech(): SpeechModelV4;\n}\n\nexport interface HumeProviderSettings {\n /**\n * API key for authenticating requests.\n */\n apiKey?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\n/**\n * Create an Hume provider instance.\n */\nexport function createHume(options: HumeProviderSettings = {}): HumeProvider {\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n 'X-Hume-Api-Key': loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'HUME_API_KEY',\n description: 'Hume',\n }),\n ...options.headers,\n },\n `ai-sdk-hume/${VERSION}`,\n );\n\n const createSpeechModel = () =>\n new HumeSpeechModel('', {\n provider: `hume.speech`,\n url: ({ path }) => `https://api.hume.ai${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = function () {\n return {\n speech: createSpeechModel(),\n };\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n provider.languageModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'languageModel',\n message: 'Hume does not provide language models',\n });\n };\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'embeddingModel',\n message: 'Hume does not provide embedding models',\n });\n };\n\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({\n modelId,\n modelType: 'imageModel',\n message: 'Hume does not provide image models',\n });\n };\n\n return provider as HumeProvider;\n}\n\n/**\n * Default Hume provider instance.\n */\nexport const hume = createHume();\n"],"mappings":";;;;AAQA,MAAa,sBAAsB,iBACjC,UACE,EAAE,OAAO,EACP,OAAO,EAAE,OAAO;CACd,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO;AACjB,CAAC,EACH,CAAC,CACH,CACF;AAIA,MAAa,4BAA4B,+BAA+B;CACtE,aAAa;CACb,iBAAgB,SAAQ,KAAK,MAAM;AACrC,CAAC;;;AChBD,MAAa,+BAA+B,iBAC1C,UACE,EAAE,OAAO;;;;;;AAMP,SAAS,EACN,OAAO;;;;AAIN,cAAc,EAAE,OAAO,EACzB,CAAC,CAAC,CACD,GACC,EAAE,OAAO;;;;AAIP,YAAY,EAAE,MACZ,EAAE,OAAO;;;;CAIP,MAAM,EAAE,OAAO;;;;CAIf,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;;;;CAIjC,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;;;;CAI3B,iBAAiB,EAAE,OAAO,CAAC,CAAC,SAAS;;;;;CAKrC,OAAO,EACJ,OAAO;;;;EAIN,IAAI,EAAE,OAAO;;;;EAIb,UAAU,EAAE,KAAK,CAAC,WAAW,cAAc,CAAC,CAAC,CAAC,SAAS;CACzD,CAAC,CAAC,CACD,GACC,EAAE,OAAO;;;;EAIP,MAAM,EAAE,OAAO;;;;EAIf,UAAU,EAAE,KAAK,CAAC,WAAW,cAAc,CA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,OAAO,QAAQ;CACjB,CAAC;CAEH,MAAM,WAAW,WAAY;EAC3B,OAAO,EACL,QAAQ,kBAAkB,EAC5B;CACF;CAEA,SAAS,uBAAuB;CAChC,SAAS,SAAS;CAClB,SAAS,cAAc;CAEvB,SAAS,iBAAiB,YAAoB;EAC5C,MAAM,IAAI,iBAAiB;GACzB;GACA,WAAW;GACX,SAAS;EACX,CAAC;CACH;CAEA,SAAS,kBAAkB,YAAoB;EAC7C,MAAM,IAAI,iBAAiB;GACzB;GACA,WAAW;GACX,SAAS;EACX,CAAC;CACH;CAEA,SAAS,cAAc,YAAoB;EACzC,MAAM,IAAI,iBAAiB;GACzB;GACA,WAAW;GACX,SAAS;EACX,CAAC;CACH;CAEA,OAAO;AACT;;;;AAKA,MAAa,OAAO,WAAW"}
package/docs/150-hume.mdx CHANGED
@@ -1,17 +1,59 @@
1
1
  ---
2
2
  title: Hume
3
- description: Learn how to use the Hume provider for the AI SDK.
3
+ description: Learn how to set up the Hume provider and check AI Gateway availability.
4
4
  ---
5
5
 
6
6
  # Hume Provider
7
7
 
8
8
  The [Hume](https://hume.ai/) provider contains support for the Hume text-to-speech (TTS) API.
9
+ Hume models are not currently available through [AI Gateway](https://vercel.com/ai-gateway/models), so the opening example uses `@ai-sdk/hume` directly. See [Using AI Gateway](#using-ai-gateway) below for supported alternatives.
9
10
 
10
- ## Setup
11
+ ```ts
12
+ import { generateSpeech } from 'ai';
13
+ import { hume } from '@ai-sdk/hume';
14
+ import { writeFile } from 'node:fs/promises';
15
+
16
+ const { audio } = await generateSpeech({
17
+ model: hume.speech(),
18
+ text: 'Hello, world!',
19
+ outputFormat: 'mp3',
20
+ });
21
+
22
+ await writeFile('speech.mp3', audio.uint8Array);
23
+ ```
24
+
25
+ ## Using AI Gateway
26
+
27
+ The current [AI Gateway model catalog](https://vercel.com/ai-gateway/models) 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:
11
28
 
12
- The Hume provider is available in the `@ai-sdk/hume` module. You can install it with
29
+ <InstallPackages packages="ai" />
13
30
 
14
- <InstallPackages packages="@ai-sdk/hume" />
31
+ Set an [AI Gateway API key](https://vercel.com/docs/ai-gateway/getting-started) in your environment:
32
+
33
+ ```bash
34
+ export AI_GATEWAY_API_KEY=your_api_key_here
35
+ ```
36
+
37
+ Vercel deployments can also use [OIDC authentication](/providers/ai-sdk-providers/ai-gateway#oidc-authentication-vercel-deployments).
38
+ See the [Gateway documentation](/providers/ai-sdk-providers/ai-gateway) for supported models and APIs.
39
+
40
+ ## Using `@ai-sdk/hume`
41
+
42
+ For direct access to Hume, install `ai` and `@ai-sdk/hume`:
43
+
44
+ <InstallPackages packages="ai @ai-sdk/hume" />
45
+
46
+ Set your Hume API credential in the `HUME_API_KEY` environment variable:
47
+
48
+ ```bash
49
+ export HUME_API_KEY=your_api_key_here
50
+ ```
51
+
52
+ <Note>
53
+ The following sections document the direct `@ai-sdk/hume` provider, including
54
+ its model factories and settings. Gateway model and feature availability can
55
+ differ.
56
+ </Note>
15
57
 
16
58
  ## Provider Instance
17
59
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/hume",
3
- "version": "3.0.64",
3
+ "version": "3.0.66",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -29,8 +29,8 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/provider": "4.0.31",
33
- "@ai-sdk/provider-utils": "5.0.64"
32
+ "@ai-sdk/provider": "4.0.32",
33
+ "@ai-sdk/provider-utils": "5.0.66"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@ai-sdk/test-server": "2.0.4",
package/src/hume-error.ts CHANGED
@@ -1,14 +1,23 @@
1
1
  import { z } from 'zod/v4';
2
- import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';
2
+ import {
3
+ lazySchema,
4
+ zodSchema,
5
+ type InferSchema,
6
+ createJsonErrorResponseHandler,
7
+ } from '@ai-sdk/provider-utils';
3
8
 
4
- export const humeErrorDataSchema = z.object({
5
- error: z.object({
6
- message: z.string(),
7
- code: z.number(),
8
- }),
9
- });
9
+ export const humeErrorDataSchema = lazySchema(() =>
10
+ zodSchema(
11
+ z.object({
12
+ error: z.object({
13
+ message: z.string(),
14
+ code: z.number(),
15
+ }),
16
+ }),
17
+ ),
18
+ );
10
19
 
11
- export type HumeErrorData = z.infer<typeof humeErrorDataSchema>;
20
+ export type HumeErrorData = InferSchema<typeof humeErrorDataSchema>;
12
21
 
13
22
  export const humeFailedResponseHandler = createJsonErrorResponseHandler({
14
23
  errorSchema: humeErrorDataSchema,
@@ -1,77 +1,86 @@
1
+ import {
2
+ lazySchema,
3
+ zodSchema,
4
+ type InferSchema,
5
+ } from '@ai-sdk/provider-utils';
1
6
  import { z } from 'zod/v4';
2
7
 
3
8
  // https://dev.hume.ai/reference/text-to-speech-tts/synthesize-file
4
- export const humeSpeechModelOptionsSchema = z.object({
5
- /**
6
- * Context for the speech synthesis request.
7
- * Can be either a generationId for retrieving a previous generation,
8
- * or a list of utterances to synthesize.
9
- */
10
- context: z
11
- .object({
9
+ export const humeSpeechModelOptionsSchema = lazySchema(() =>
10
+ zodSchema(
11
+ z.object({
12
12
  /**
13
- * ID of a previously generated speech synthesis to retrieve.
13
+ * Context for the speech synthesis request.
14
+ * Can be either a generationId for retrieving a previous generation,
15
+ * or a list of utterances to synthesize.
14
16
  */
15
- generationId: z.string(),
16
- })
17
- .or(
18
- z.object({
19
- /**
20
- * List of utterances to synthesize into speech.
21
- */
22
- utterances: z.array(
17
+ context: z
18
+ .object({
19
+ /**
20
+ * ID of a previously generated speech synthesis to retrieve.
21
+ */
22
+ generationId: z.string(),
23
+ })
24
+ .or(
23
25
  z.object({
24
26
  /**
25
- * The text content to convert to speech.
27
+ * List of utterances to synthesize into speech.
26
28
  */
27
- text: z.string(),
28
- /**
29
- * Optional description or instructions for how the text should be spoken.
30
- */
31
- description: z.string().optional(),
32
- /**
33
- * Optional speech rate multiplier.
34
- */
35
- speed: z.number().optional(),
36
- /**
37
- * Optional duration of silence to add after the utterance in seconds.
38
- */
39
- trailingSilence: z.number().optional(),
40
- /**
41
- * Voice configuration for the utterance.
42
- * Can be specified by ID or name.
43
- */
44
- voice: z
45
- .object({
29
+ utterances: z.array(
30
+ z.object({
31
+ /**
32
+ * The text content to convert to speech.
33
+ */
34
+ text: z.string(),
35
+ /**
36
+ * Optional description or instructions for how the text should be spoken.
37
+ */
38
+ description: z.string().optional(),
39
+ /**
40
+ * Optional speech rate multiplier.
41
+ */
42
+ speed: z.number().optional(),
46
43
  /**
47
- * ID of the voice to use.
44
+ * Optional duration of silence to add after the utterance in seconds.
48
45
  */
49
- id: z.string(),
46
+ trailingSilence: z.number().optional(),
50
47
  /**
51
- * Provider of the voice, either Hume's built-in voices or a custom voice.
48
+ * Voice configuration for the utterance.
49
+ * Can be specified by ID or name.
52
50
  */
53
- provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),
54
- })
55
- .or(
56
- z.object({
57
- /**
58
- * Name of the voice to use.
59
- */
60
- name: z.string(),
61
- /**
62
- * Provider of the voice, either Hume's built-in voices or a custom voice.
63
- */
64
- provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),
65
- }),
66
- )
67
- .optional(),
51
+ voice: z
52
+ .object({
53
+ /**
54
+ * ID of the voice to use.
55
+ */
56
+ id: z.string(),
57
+ /**
58
+ * Provider of the voice, either Hume's built-in voices or a custom voice.
59
+ */
60
+ provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),
61
+ })
62
+ .or(
63
+ z.object({
64
+ /**
65
+ * Name of the voice to use.
66
+ */
67
+ name: z.string(),
68
+ /**
69
+ * Provider of the voice, either Hume's built-in voices or a custom voice.
70
+ */
71
+ provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),
72
+ }),
73
+ )
74
+ .optional(),
75
+ }),
76
+ ),
68
77
  }),
69
- ),
70
- }),
71
- )
72
- .nullish(),
73
- });
78
+ )
79
+ .nullish(),
80
+ }),
81
+ ),
82
+ );
74
83
 
75
- export type HumeSpeechModelOptions = z.infer<
84
+ export type HumeSpeechModelOptions = InferSchema<
76
85
  typeof humeSpeechModelOptionsSchema
77
86
  >;