@ai-sdk/hume 3.0.0-beta.30 → 3.0.0-beta.31

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,18 @@
1
1
  # @ai-sdk/hume
2
2
 
3
+ ## 3.0.0-beta.31
4
+
5
+ ### Major Changes
6
+
7
+ - 04e9009: chore: make provider implementations code patterns more consistent, including renaming certain exported symbols
8
+
9
+ For all externally exported symbols that were renamed, the old names continue to work via deprecated aliases.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [08d2129]
14
+ - @ai-sdk/provider-utils@5.0.0-beta.30
15
+
3
16
  ## 3.0.0-beta.30
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -14,32 +14,6 @@ type HumeConfig = {
14
14
  generateId?: () => string;
15
15
  };
16
16
 
17
- declare const humeSpeechModelOptionsSchema: z.ZodObject<{
18
- context: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
19
- generationId: z.ZodString;
20
- }, z.core.$strip>, z.ZodObject<{
21
- utterances: z.ZodArray<z.ZodObject<{
22
- text: z.ZodString;
23
- description: z.ZodOptional<z.ZodString>;
24
- speed: z.ZodOptional<z.ZodNumber>;
25
- trailingSilence: z.ZodOptional<z.ZodNumber>;
26
- voice: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
27
- id: z.ZodString;
28
- provider: z.ZodOptional<z.ZodEnum<{
29
- HUME_AI: "HUME_AI";
30
- CUSTOM_VOICE: "CUSTOM_VOICE";
31
- }>>;
32
- }, z.core.$strip>, z.ZodObject<{
33
- name: z.ZodString;
34
- provider: z.ZodOptional<z.ZodEnum<{
35
- HUME_AI: "HUME_AI";
36
- CUSTOM_VOICE: "CUSTOM_VOICE";
37
- }>>;
38
- }, z.core.$strip>]>>;
39
- }, z.core.$strip>>;
40
- }, z.core.$strip>]>>>;
41
- }, z.core.$strip>;
42
- type HumeSpeechModelOptions = z.infer<typeof humeSpeechModelOptionsSchema>;
43
17
  interface HumeSpeechModelConfig extends HumeConfig {
44
18
  _internal?: {
45
19
  currentDate?: () => Date;
@@ -63,7 +37,7 @@ declare class HumeSpeechModel implements SpeechModelV4 {
63
37
  doGenerate(options: Parameters<SpeechModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>>;
64
38
  }
65
39
 
66
- interface HumeProvider extends Pick<ProviderV4, 'speechModel'> {
40
+ interface HumeProvider extends ProviderV4 {
67
41
  (settings?: {}): {
68
42
  speech: HumeSpeechModel;
69
43
  };
@@ -96,6 +70,33 @@ declare function createHume(options?: HumeProviderSettings): HumeProvider;
96
70
  */
97
71
  declare const hume: HumeProvider;
98
72
 
73
+ declare const humeSpeechModelOptionsSchema: z.ZodObject<{
74
+ context: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
75
+ generationId: z.ZodString;
76
+ }, z.core.$strip>, z.ZodObject<{
77
+ utterances: z.ZodArray<z.ZodObject<{
78
+ text: z.ZodString;
79
+ description: z.ZodOptional<z.ZodString>;
80
+ speed: z.ZodOptional<z.ZodNumber>;
81
+ trailingSilence: z.ZodOptional<z.ZodNumber>;
82
+ voice: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
83
+ id: z.ZodString;
84
+ provider: z.ZodOptional<z.ZodEnum<{
85
+ HUME_AI: "HUME_AI";
86
+ CUSTOM_VOICE: "CUSTOM_VOICE";
87
+ }>>;
88
+ }, z.core.$strip>, z.ZodObject<{
89
+ name: z.ZodString;
90
+ provider: z.ZodOptional<z.ZodEnum<{
91
+ HUME_AI: "HUME_AI";
92
+ CUSTOM_VOICE: "CUSTOM_VOICE";
93
+ }>>;
94
+ }, z.core.$strip>]>>;
95
+ }, z.core.$strip>>;
96
+ }, z.core.$strip>]>>>;
97
+ }, z.core.$strip>;
98
+ type HumeSpeechModelOptions = z.infer<typeof humeSpeechModelOptionsSchema>;
99
+
99
100
  declare const VERSION: string;
100
101
 
101
102
  export { type HumeProvider, type HumeProviderSettings, type HumeSpeechModelOptions, VERSION, createHume, hume };
package/dist/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  // src/hume-provider.ts
2
+ import {
3
+ NoSuchModelError
4
+ } from "@ai-sdk/provider";
2
5
  import {
3
6
  loadApiKey,
4
7
  withUserAgentSuffix
@@ -14,7 +17,6 @@ import {
14
17
  WORKFLOW_SERIALIZE,
15
18
  WORKFLOW_DESERIALIZE
16
19
  } from "@ai-sdk/provider-utils";
17
- import { z as z2 } from "zod/v4";
18
20
 
19
21
  // src/hume-error.ts
20
22
  import { z } from "zod/v4";
@@ -30,7 +32,8 @@ var humeFailedResponseHandler = createJsonErrorResponseHandler({
30
32
  errorToMessage: (data) => data.error.message
31
33
  });
32
34
 
33
- // src/hume-speech-model.ts
35
+ // src/hume-speech-model-options.ts
36
+ import { z as z2 } from "zod/v4";
34
37
  var humeSpeechModelOptionsSchema = z2.object({
35
38
  /**
36
39
  * Context for the speech synthesis request.
@@ -95,6 +98,8 @@ var humeSpeechModelOptionsSchema = z2.object({
95
98
  })
96
99
  ).nullish()
97
100
  });
101
+
102
+ // src/hume-speech-model.ts
98
103
  var HumeSpeechModel = class _HumeSpeechModel {
99
104
  constructor(modelId, config) {
100
105
  this.modelId = modelId;
@@ -228,7 +233,7 @@ var HumeSpeechModel = class _HumeSpeechModel {
228
233
  };
229
234
 
230
235
  // src/version.ts
231
- var VERSION = true ? "3.0.0-beta.30" : "0.0.0-test";
236
+ var VERSION = true ? "3.0.0-beta.31" : "0.0.0-test";
232
237
 
233
238
  // src/hume-provider.ts
234
239
  function createHume(options = {}) {
@@ -254,8 +259,30 @@ function createHume(options = {}) {
254
259
  speech: createSpeechModel()
255
260
  };
256
261
  };
262
+ provider.specificationVersion = "v4";
257
263
  provider.speech = createSpeechModel;
258
264
  provider.speechModel = createSpeechModel;
265
+ provider.languageModel = (modelId) => {
266
+ throw new NoSuchModelError({
267
+ modelId,
268
+ modelType: "languageModel",
269
+ message: "Hume does not provide language models"
270
+ });
271
+ };
272
+ provider.embeddingModel = (modelId) => {
273
+ throw new NoSuchModelError({
274
+ modelId,
275
+ modelType: "embeddingModel",
276
+ message: "Hume does not provide embedding models"
277
+ });
278
+ };
279
+ provider.imageModel = (modelId) => {
280
+ throw new NoSuchModelError({
281
+ modelId,
282
+ modelType: "imageModel",
283
+ message: "Hume does not provide image models"
284
+ });
285
+ };
259
286
  return provider;
260
287
  }
261
288
  var hume = createHume();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hume-provider.ts","../src/hume-speech-model.ts","../src/hume-error.ts","../src/version.ts"],"sourcesContent":["import type { SpeechModelV4, ProviderV4 } 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 Pick<ProviderV4, 'speechModel'> {\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.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n return provider satisfies HumeProvider;\n}\n\n/**\n * Default Hume provider instance.\n */\nexport const hume = createHume();\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 { z } from 'zod/v4';\nimport type { HumeConfig } from './hume-config';\nimport { humeFailedResponseHandler } from './hume-error';\nimport type { HumeSpeechAPITypes } from './hume-api-types';\n\n// https://dev.hume.ai/reference/text-to-speech-tts/synthesize-file\nconst 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\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","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","// 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"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;;;ACJP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,KAAAA,UAAS;;;ACVlB,SAAS,SAAS;AAClB,SAAS,sCAAsC;AAExC,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,OAAO,EAAE,OAAO;AAAA,IACd,SAAS,EAAE,OAAO;AAAA,IAClB,MAAM,EAAE,OAAO;AAAA,EACjB,CAAC;AACH,CAAC;AAIM,IAAM,4BAA4B,+BAA+B;AAAA,EACtE,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK,MAAM;AACrC,CAAC;;;ADCD,IAAM,+BAA+BC,GAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM5C,SAASA,GACN,OAAO;AAAA;AAAA;AAAA;AAAA,IAIN,cAAcA,GAAE,OAAO;AAAA,EACzB,CAAC,EACA;AAAA,IACCA,GAAE,OAAO;AAAA;AAAA;AAAA;AAAA,MAIP,YAAYA,GAAE;AAAA,QACZA,GAAE,OAAO;AAAA;AAAA;AAAA;AAAA,UAIP,MAAMA,GAAE,OAAO;AAAA;AAAA;AAAA;AAAA,UAIf,aAAaA,GAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,UAIjC,OAAOA,GAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,UAI3B,iBAAiBA,GAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,UAKrC,OAAOA,GACJ,OAAO;AAAA;AAAA;AAAA;AAAA,YAIN,IAAIA,GAAE,OAAO;AAAA;AAAA;AAAA;AAAA,YAIb,UAAUA,GAAE,KAAK,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
+ {"version":3,"sources":["../src/hume-provider.ts","../src/hume-speech-model.ts","../src/hume-error.ts","../src/hume-speech-model-options.ts","../src/version.ts"],"sourcesContent":["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","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","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","// 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"],"mappings":";AAAA;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAEK;;;ACRP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACTP,SAAS,SAAS;AAClB,SAAS,sCAAsC;AAExC,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,OAAO,EAAE,OAAO;AAAA,IACd,SAAS,EAAE,OAAO;AAAA,IAClB,MAAM,EAAE,OAAO;AAAA,EACjB,CAAC;AACH,CAAC;AAIM,IAAM,4BAA4B,+BAA+B;AAAA,EACtE,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK,MAAM;AACrC,CAAC;;;ACfD,SAAS,KAAAA,UAAS;AAGX,IAAM,+BAA+BA,GAAE,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnD,SAASA,GACN,OAAO;AAAA;AAAA;AAAA;AAAA,IAIN,cAAcA,GAAE,OAAO;AAAA,EACzB,CAAC,EACA;AAAA,IACCA,GAAE,OAAO;AAAA;AAAA;AAAA;AAAA,MAIP,YAAYA,GAAE;AAAA,QACZA,GAAE,OAAO;AAAA;AAAA;AAAA;AAAA,UAIP,MAAMA,GAAE,OAAO;AAAA;AAAA;AAAA;AAAA,UAIf,aAAaA,GAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,UAIjC,OAAOA,GAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,UAI3B,iBAAiBA,GAAE,OAAO,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA,UAKrC,OAAOA,GACJ,OAAO;AAAA;AAAA;AAAA;AAAA,YAIN,IAAIA,GA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AS,SAAS;AAClB,WAAS,cAAc;AAEvB,WAAS,gBAAgB,CAAC,YAAoB;AAC5C,UAAM,IAAI,iBAAiB;AAAA,MACzB;AAAA,MACA,WAAW;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,WAAS,iBAAiB,CAAC,YAAoB;AAC7C,UAAM,IAAI,iBAAiB;AAAA,MACzB;AAAA,MACA,WAAW;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iBAAiB;AAAA,MACzB;AAAA,MACA,WAAW;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAKO,IAAM,OAAO,WAAW;","names":["z"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/hume",
3
- "version": "3.0.0-beta.30",
3
+ "version": "3.0.0-beta.31",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@ai-sdk/provider": "4.0.0-beta.14",
33
- "@ai-sdk/provider-utils": "5.0.0-beta.29"
33
+ "@ai-sdk/provider-utils": "5.0.0-beta.30"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "20.17.24",
@@ -1,4 +1,8 @@
1
- import type { SpeechModelV4, ProviderV4 } from '@ai-sdk/provider';
1
+ import {
2
+ NoSuchModelError,
3
+ type SpeechModelV4,
4
+ type ProviderV4,
5
+ } from '@ai-sdk/provider';
2
6
  import {
3
7
  loadApiKey,
4
8
  withUserAgentSuffix,
@@ -7,7 +11,7 @@ import {
7
11
  import { HumeSpeechModel } from './hume-speech-model';
8
12
  import { VERSION } from './version';
9
13
 
10
- export interface HumeProvider extends Pick<ProviderV4, 'speechModel'> {
14
+ export interface HumeProvider extends ProviderV4 {
11
15
  (settings?: {}): {
12
16
  speech: HumeSpeechModel;
13
17
  };
@@ -67,10 +71,35 @@ export function createHume(options: HumeProviderSettings = {}): HumeProvider {
67
71
  };
68
72
  };
69
73
 
74
+ provider.specificationVersion = 'v4' as const;
70
75
  provider.speech = createSpeechModel;
71
76
  provider.speechModel = createSpeechModel;
72
77
 
73
- return provider satisfies HumeProvider;
78
+ provider.languageModel = (modelId: string) => {
79
+ throw new NoSuchModelError({
80
+ modelId,
81
+ modelType: 'languageModel',
82
+ message: 'Hume does not provide language models',
83
+ });
84
+ };
85
+
86
+ provider.embeddingModel = (modelId: string) => {
87
+ throw new NoSuchModelError({
88
+ modelId,
89
+ modelType: 'embeddingModel',
90
+ message: 'Hume does not provide embedding models',
91
+ });
92
+ };
93
+
94
+ provider.imageModel = (modelId: string) => {
95
+ throw new NoSuchModelError({
96
+ modelId,
97
+ modelType: 'imageModel',
98
+ message: 'Hume does not provide image models',
99
+ });
100
+ };
101
+
102
+ return provider as HumeProvider;
74
103
  }
75
104
 
76
105
  /**
@@ -0,0 +1,77 @@
1
+ import { z } from 'zod/v4';
2
+
3
+ // 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({
12
+ /**
13
+ * ID of a previously generated speech synthesis to retrieve.
14
+ */
15
+ generationId: z.string(),
16
+ })
17
+ .or(
18
+ z.object({
19
+ /**
20
+ * List of utterances to synthesize into speech.
21
+ */
22
+ utterances: z.array(
23
+ z.object({
24
+ /**
25
+ * The text content to convert to speech.
26
+ */
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({
46
+ /**
47
+ * ID of the voice to use.
48
+ */
49
+ id: z.string(),
50
+ /**
51
+ * Provider of the voice, either Hume's built-in voices or a custom voice.
52
+ */
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(),
68
+ }),
69
+ ),
70
+ }),
71
+ )
72
+ .nullish(),
73
+ });
74
+
75
+ export type HumeSpeechModelOptions = z.infer<
76
+ typeof humeSpeechModelOptionsSchema
77
+ >;
@@ -8,87 +8,11 @@ import {
8
8
  WORKFLOW_SERIALIZE,
9
9
  WORKFLOW_DESERIALIZE,
10
10
  } from '@ai-sdk/provider-utils';
11
- import { z } from 'zod/v4';
12
11
  import type { HumeConfig } from './hume-config';
13
12
  import { humeFailedResponseHandler } from './hume-error';
13
+ import { humeSpeechModelOptionsSchema } from './hume-speech-model-options';
14
14
  import type { HumeSpeechAPITypes } from './hume-api-types';
15
15
 
16
- // https://dev.hume.ai/reference/text-to-speech-tts/synthesize-file
17
- const humeSpeechModelOptionsSchema = z.object({
18
- /**
19
- * Context for the speech synthesis request.
20
- * Can be either a generationId for retrieving a previous generation,
21
- * or a list of utterances to synthesize.
22
- */
23
- context: z
24
- .object({
25
- /**
26
- * ID of a previously generated speech synthesis to retrieve.
27
- */
28
- generationId: z.string(),
29
- })
30
- .or(
31
- z.object({
32
- /**
33
- * List of utterances to synthesize into speech.
34
- */
35
- utterances: z.array(
36
- z.object({
37
- /**
38
- * The text content to convert to speech.
39
- */
40
- text: z.string(),
41
- /**
42
- * Optional description or instructions for how the text should be spoken.
43
- */
44
- description: z.string().optional(),
45
- /**
46
- * Optional speech rate multiplier.
47
- */
48
- speed: z.number().optional(),
49
- /**
50
- * Optional duration of silence to add after the utterance in seconds.
51
- */
52
- trailingSilence: z.number().optional(),
53
- /**
54
- * Voice configuration for the utterance.
55
- * Can be specified by ID or name.
56
- */
57
- voice: z
58
- .object({
59
- /**
60
- * ID of the voice to use.
61
- */
62
- id: z.string(),
63
- /**
64
- * Provider of the voice, either Hume's built-in voices or a custom voice.
65
- */
66
- provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),
67
- })
68
- .or(
69
- z.object({
70
- /**
71
- * Name of the voice to use.
72
- */
73
- name: z.string(),
74
- /**
75
- * Provider of the voice, either Hume's built-in voices or a custom voice.
76
- */
77
- provider: z.enum(['HUME_AI', 'CUSTOM_VOICE']).optional(),
78
- }),
79
- )
80
- .optional(),
81
- }),
82
- ),
83
- }),
84
- )
85
- .nullish(),
86
- });
87
-
88
- export type HumeSpeechModelOptions = z.infer<
89
- typeof humeSpeechModelOptionsSchema
90
- >;
91
-
92
16
  interface HumeSpeechModelConfig extends HumeConfig {
93
17
  _internal?: {
94
18
  currentDate?: () => Date;
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { createHume, hume } from './hume-provider';
2
2
  export type { HumeProvider, HumeProviderSettings } from './hume-provider';
3
- export type { HumeSpeechModelOptions } from './hume-speech-model';
3
+ export type { HumeSpeechModelOptions } from './hume-speech-model-options';
4
4
  export { VERSION } from './version';