@ai-sdk/huggingface 2.0.0-beta.22 → 2.0.0-beta.24

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/dist/index.js CHANGED
@@ -1,50 +1,38 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- createHuggingFace: () => createHuggingFace,
24
- huggingface: () => huggingface
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
-
28
1
  // src/huggingface-provider.ts
29
- var import_provider3 = require("@ai-sdk/provider");
30
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
2
+ import {
3
+ NoSuchModelError
4
+ } from "@ai-sdk/provider";
5
+ import {
6
+ generateId as generateId2,
7
+ loadApiKey,
8
+ withoutTrailingSlash
9
+ } from "@ai-sdk/provider-utils";
31
10
 
32
11
  // src/responses/huggingface-responses-language-model.ts
33
- var import_provider2 = require("@ai-sdk/provider");
34
- var import_provider_utils3 = require("@ai-sdk/provider-utils");
35
- var import_v42 = require("zod/v4");
12
+ import {
13
+ APICallError
14
+ } from "@ai-sdk/provider";
15
+ import {
16
+ combineHeaders,
17
+ createEventSourceResponseHandler,
18
+ createJsonResponseHandler,
19
+ generateId,
20
+ parseProviderOptions,
21
+ postJsonToApi
22
+ } from "@ai-sdk/provider-utils";
23
+ import { z as z2 } from "zod/v4";
36
24
 
37
25
  // src/huggingface-error.ts
38
- var import_provider_utils = require("@ai-sdk/provider-utils");
39
- var import_v4 = require("zod/v4");
40
- var huggingfaceErrorDataSchema = import_v4.z.object({
41
- error: import_v4.z.object({
42
- message: import_v4.z.string(),
43
- type: import_v4.z.string().optional(),
44
- code: import_v4.z.string().optional()
26
+ import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
27
+ import { z } from "zod/v4";
28
+ var huggingfaceErrorDataSchema = z.object({
29
+ error: z.object({
30
+ message: z.string(),
31
+ type: z.string().optional(),
32
+ code: z.string().optional()
45
33
  })
46
34
  });
47
- var huggingfaceFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
35
+ var huggingfaceFailedResponseHandler = createJsonErrorResponseHandler({
48
36
  errorSchema: huggingfaceErrorDataSchema,
49
37
  errorToMessage: (data) => data.error.message
50
38
  });
@@ -89,8 +77,10 @@ function convertHuggingFaceResponsesUsage(usage) {
89
77
  }
90
78
 
91
79
  // src/responses/convert-to-huggingface-responses-messages.ts
92
- var import_provider = require("@ai-sdk/provider");
93
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
80
+ import {
81
+ UnsupportedFunctionalityError
82
+ } from "@ai-sdk/provider";
83
+ import { isProviderReference } from "@ai-sdk/provider-utils";
94
84
  async function convertToHuggingFaceResponsesMessages({
95
85
  prompt
96
86
  }) {
@@ -111,8 +101,8 @@ async function convertToHuggingFaceResponsesMessages({
111
101
  return { type: "input_text", text: part.text };
112
102
  }
113
103
  case "file": {
114
- if ((0, import_provider_utils2.isProviderReference)(part.data)) {
115
- throw new import_provider.UnsupportedFunctionalityError({
104
+ if (isProviderReference(part.data)) {
105
+ throw new UnsupportedFunctionalityError({
116
106
  functionality: "file parts with provider references"
117
107
  });
118
108
  }
@@ -123,7 +113,7 @@ async function convertToHuggingFaceResponsesMessages({
123
113
  image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`
124
114
  };
125
115
  } else {
126
- throw new import_provider.UnsupportedFunctionalityError({
116
+ throw new UnsupportedFunctionalityError({
127
117
  functionality: `file part media type ${part.mediaType}`
128
118
  });
129
119
  }
@@ -307,7 +297,7 @@ var HuggingFaceResponsesLanguageModel = class {
307
297
  prompt
308
298
  });
309
299
  warnings.push(...messageWarnings);
310
- const huggingfaceOptions = await (0, import_provider_utils3.parseProviderOptions)({
300
+ const huggingfaceOptions = await parseProviderOptions({
311
301
  provider: "huggingface",
312
302
  providerOptions,
313
303
  schema: huggingfaceResponsesProviderOptionsSchema
@@ -368,19 +358,19 @@ var HuggingFaceResponsesLanguageModel = class {
368
358
  value: response,
369
359
  responseHeaders,
370
360
  rawValue: rawResponse
371
- } = await (0, import_provider_utils3.postJsonToApi)({
361
+ } = await postJsonToApi({
372
362
  url,
373
- headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
363
+ headers: combineHeaders(this.config.headers(), options.headers),
374
364
  body,
375
365
  failedResponseHandler: huggingfaceFailedResponseHandler,
376
- successfulResponseHandler: (0, import_provider_utils3.createJsonResponseHandler)(
366
+ successfulResponseHandler: createJsonResponseHandler(
377
367
  huggingfaceResponsesResponseSchema
378
368
  ),
379
369
  abortSignal: options.abortSignal,
380
370
  fetch: this.config.fetch
381
371
  });
382
372
  if (response.error) {
383
- throw new import_provider2.APICallError({
373
+ throw new APICallError({
384
374
  message: response.error.message,
385
375
  url,
386
376
  requestBodyValues: body,
@@ -409,7 +399,7 @@ var HuggingFaceResponsesLanguageModel = class {
409
399
  content.push({
410
400
  type: "source",
411
401
  sourceType: "url",
412
- id: (_c = (_b = (_a = this.config).generateId) == null ? void 0 : _b.call(_a)) != null ? _c : (0, import_provider_utils3.generateId)(),
402
+ id: (_c = (_b = (_a = this.config).generateId) == null ? void 0 : _b.call(_a)) != null ? _c : generateId(),
413
403
  url: annotation.url,
414
404
  title: annotation.title
415
405
  });
@@ -521,15 +511,15 @@ var HuggingFaceResponsesLanguageModel = class {
521
511
  ...args,
522
512
  stream: true
523
513
  };
524
- const { value: response, responseHeaders } = await (0, import_provider_utils3.postJsonToApi)({
514
+ const { value: response, responseHeaders } = await postJsonToApi({
525
515
  url: this.config.url({
526
516
  path: "/responses",
527
517
  modelId: this.modelId
528
518
  }),
529
- headers: (0, import_provider_utils3.combineHeaders)(this.config.headers(), options.headers),
519
+ headers: combineHeaders(this.config.headers(), options.headers),
530
520
  body,
531
521
  failedResponseHandler: huggingfaceFailedResponseHandler,
532
- successfulResponseHandler: (0, import_provider_utils3.createEventSourceResponseHandler)(
522
+ successfulResponseHandler: createEventSourceResponseHandler(
533
523
  huggingfaceResponsesChunkSchema
534
524
  ),
535
525
  abortSignal: options.abortSignal,
@@ -682,231 +672,231 @@ var HuggingFaceResponsesLanguageModel = class {
682
672
  };
683
673
  }
684
674
  };
685
- var huggingfaceResponsesProviderOptionsSchema = import_v42.z.object({
686
- metadata: import_v42.z.record(import_v42.z.string(), import_v42.z.string()).optional(),
687
- instructions: import_v42.z.string().optional(),
688
- strictJsonSchema: import_v42.z.boolean().optional(),
689
- reasoningEffort: import_v42.z.string().optional()
675
+ var huggingfaceResponsesProviderOptionsSchema = z2.object({
676
+ metadata: z2.record(z2.string(), z2.string()).optional(),
677
+ instructions: z2.string().optional(),
678
+ strictJsonSchema: z2.boolean().optional(),
679
+ reasoningEffort: z2.string().optional()
690
680
  });
691
- var huggingfaceResponsesOutputSchema = import_v42.z.discriminatedUnion("type", [
692
- import_v42.z.object({
693
- type: import_v42.z.literal("message"),
694
- id: import_v42.z.string(),
695
- role: import_v42.z.string().optional(),
696
- status: import_v42.z.string().optional(),
697
- content: import_v42.z.array(
698
- import_v42.z.object({
699
- type: import_v42.z.literal("output_text"),
700
- text: import_v42.z.string(),
701
- annotations: import_v42.z.array(import_v42.z.any()).optional()
681
+ var huggingfaceResponsesOutputSchema = z2.discriminatedUnion("type", [
682
+ z2.object({
683
+ type: z2.literal("message"),
684
+ id: z2.string(),
685
+ role: z2.string().optional(),
686
+ status: z2.string().optional(),
687
+ content: z2.array(
688
+ z2.object({
689
+ type: z2.literal("output_text"),
690
+ text: z2.string(),
691
+ annotations: z2.array(z2.any()).optional()
702
692
  })
703
693
  )
704
694
  }),
705
- import_v42.z.object({
706
- type: import_v42.z.literal("reasoning"),
707
- id: import_v42.z.string(),
708
- status: import_v42.z.string().optional(),
709
- content: import_v42.z.array(
710
- import_v42.z.object({
711
- type: import_v42.z.literal("reasoning_text"),
712
- text: import_v42.z.string()
695
+ z2.object({
696
+ type: z2.literal("reasoning"),
697
+ id: z2.string(),
698
+ status: z2.string().optional(),
699
+ content: z2.array(
700
+ z2.object({
701
+ type: z2.literal("reasoning_text"),
702
+ text: z2.string()
713
703
  })
714
704
  ),
715
- summary: import_v42.z.array(
716
- import_v42.z.object({
717
- type: import_v42.z.literal("reasoning_summary"),
718
- text: import_v42.z.string()
705
+ summary: z2.array(
706
+ z2.object({
707
+ type: z2.literal("reasoning_summary"),
708
+ text: z2.string()
719
709
  }).optional()
720
710
  ).optional()
721
711
  }),
722
- import_v42.z.object({
723
- type: import_v42.z.literal("function_call"),
724
- id: import_v42.z.string(),
725
- call_id: import_v42.z.string(),
726
- name: import_v42.z.string(),
727
- arguments: import_v42.z.string(),
728
- output: import_v42.z.string().optional(),
729
- status: import_v42.z.string().optional()
712
+ z2.object({
713
+ type: z2.literal("function_call"),
714
+ id: z2.string(),
715
+ call_id: z2.string(),
716
+ name: z2.string(),
717
+ arguments: z2.string(),
718
+ output: z2.string().optional(),
719
+ status: z2.string().optional()
730
720
  }),
731
- import_v42.z.object({
732
- type: import_v42.z.literal("mcp_call"),
733
- id: import_v42.z.string(),
734
- name: import_v42.z.string(),
735
- arguments: import_v42.z.string(),
736
- output: import_v42.z.string().optional(),
737
- status: import_v42.z.string().optional()
721
+ z2.object({
722
+ type: z2.literal("mcp_call"),
723
+ id: z2.string(),
724
+ name: z2.string(),
725
+ arguments: z2.string(),
726
+ output: z2.string().optional(),
727
+ status: z2.string().optional()
738
728
  }),
739
- import_v42.z.object({
740
- type: import_v42.z.literal("mcp_list_tools"),
741
- id: import_v42.z.string(),
742
- server_label: import_v42.z.string(),
743
- tools: import_v42.z.array(import_v42.z.any()).optional(),
744
- status: import_v42.z.string().optional()
729
+ z2.object({
730
+ type: z2.literal("mcp_list_tools"),
731
+ id: z2.string(),
732
+ server_label: z2.string(),
733
+ tools: z2.array(z2.any()).optional(),
734
+ status: z2.string().optional()
745
735
  })
746
736
  ]);
747
- var huggingfaceResponsesResponseSchema = import_v42.z.object({
748
- id: import_v42.z.string(),
749
- model: import_v42.z.string(),
750
- object: import_v42.z.string(),
751
- created_at: import_v42.z.number(),
752
- status: import_v42.z.string(),
753
- error: import_v42.z.any().nullable(),
754
- instructions: import_v42.z.any().nullable(),
755
- max_output_tokens: import_v42.z.any().nullable(),
756
- metadata: import_v42.z.any().nullable(),
757
- tool_choice: import_v42.z.any(),
758
- tools: import_v42.z.array(import_v42.z.any()),
759
- temperature: import_v42.z.number(),
760
- top_p: import_v42.z.number(),
761
- incomplete_details: import_v42.z.object({
762
- reason: import_v42.z.string()
737
+ var huggingfaceResponsesResponseSchema = z2.object({
738
+ id: z2.string(),
739
+ model: z2.string(),
740
+ object: z2.string(),
741
+ created_at: z2.number(),
742
+ status: z2.string(),
743
+ error: z2.any().nullable(),
744
+ instructions: z2.any().nullable(),
745
+ max_output_tokens: z2.any().nullable(),
746
+ metadata: z2.any().nullable(),
747
+ tool_choice: z2.any(),
748
+ tools: z2.array(z2.any()),
749
+ temperature: z2.number(),
750
+ top_p: z2.number(),
751
+ incomplete_details: z2.object({
752
+ reason: z2.string()
763
753
  }).nullable().optional(),
764
- usage: import_v42.z.object({
765
- input_tokens: import_v42.z.number(),
766
- input_tokens_details: import_v42.z.object({
767
- cached_tokens: import_v42.z.number()
754
+ usage: z2.object({
755
+ input_tokens: z2.number(),
756
+ input_tokens_details: z2.object({
757
+ cached_tokens: z2.number()
768
758
  }).optional(),
769
- output_tokens: import_v42.z.number(),
770
- output_tokens_details: import_v42.z.object({
771
- reasoning_tokens: import_v42.z.number()
759
+ output_tokens: z2.number(),
760
+ output_tokens_details: z2.object({
761
+ reasoning_tokens: z2.number()
772
762
  }).optional(),
773
- total_tokens: import_v42.z.number()
763
+ total_tokens: z2.number()
774
764
  }).nullable().optional(),
775
- output: import_v42.z.array(huggingfaceResponsesOutputSchema),
776
- output_text: import_v42.z.string().nullable().optional()
765
+ output: z2.array(huggingfaceResponsesOutputSchema),
766
+ output_text: z2.string().nullable().optional()
777
767
  });
778
- var responseOutputItemAddedSchema = import_v42.z.object({
779
- type: import_v42.z.literal("response.output_item.added"),
780
- output_index: import_v42.z.number(),
781
- item: import_v42.z.discriminatedUnion("type", [
782
- import_v42.z.object({
783
- type: import_v42.z.literal("message"),
784
- id: import_v42.z.string(),
785
- role: import_v42.z.string().optional(),
786
- status: import_v42.z.string().optional(),
787
- content: import_v42.z.array(import_v42.z.any()).optional()
768
+ var responseOutputItemAddedSchema = z2.object({
769
+ type: z2.literal("response.output_item.added"),
770
+ output_index: z2.number(),
771
+ item: z2.discriminatedUnion("type", [
772
+ z2.object({
773
+ type: z2.literal("message"),
774
+ id: z2.string(),
775
+ role: z2.string().optional(),
776
+ status: z2.string().optional(),
777
+ content: z2.array(z2.any()).optional()
788
778
  }),
789
- import_v42.z.object({
790
- type: import_v42.z.literal("reasoning"),
791
- id: import_v42.z.string(),
792
- status: import_v42.z.string().optional(),
793
- content: import_v42.z.array(import_v42.z.any()).optional(),
794
- summary: import_v42.z.array(import_v42.z.any()).optional()
779
+ z2.object({
780
+ type: z2.literal("reasoning"),
781
+ id: z2.string(),
782
+ status: z2.string().optional(),
783
+ content: z2.array(z2.any()).optional(),
784
+ summary: z2.array(z2.any()).optional()
795
785
  }),
796
- import_v42.z.object({
797
- type: import_v42.z.literal("mcp_list_tools"),
798
- id: import_v42.z.string(),
799
- server_label: import_v42.z.string(),
800
- tools: import_v42.z.array(import_v42.z.any()).optional(),
801
- error: import_v42.z.string().optional()
786
+ z2.object({
787
+ type: z2.literal("mcp_list_tools"),
788
+ id: z2.string(),
789
+ server_label: z2.string(),
790
+ tools: z2.array(z2.any()).optional(),
791
+ error: z2.string().optional()
802
792
  }),
803
- import_v42.z.object({
804
- type: import_v42.z.literal("mcp_call"),
805
- id: import_v42.z.string(),
806
- server_label: import_v42.z.string(),
807
- name: import_v42.z.string(),
808
- arguments: import_v42.z.string(),
809
- output: import_v42.z.string().optional(),
810
- error: import_v42.z.string().optional()
793
+ z2.object({
794
+ type: z2.literal("mcp_call"),
795
+ id: z2.string(),
796
+ server_label: z2.string(),
797
+ name: z2.string(),
798
+ arguments: z2.string(),
799
+ output: z2.string().optional(),
800
+ error: z2.string().optional()
811
801
  }),
812
- import_v42.z.object({
813
- type: import_v42.z.literal("function_call"),
814
- id: import_v42.z.string(),
815
- call_id: import_v42.z.string(),
816
- name: import_v42.z.string(),
817
- arguments: import_v42.z.string(),
818
- output: import_v42.z.string().optional(),
819
- error: import_v42.z.string().optional()
802
+ z2.object({
803
+ type: z2.literal("function_call"),
804
+ id: z2.string(),
805
+ call_id: z2.string(),
806
+ name: z2.string(),
807
+ arguments: z2.string(),
808
+ output: z2.string().optional(),
809
+ error: z2.string().optional()
820
810
  })
821
811
  ]),
822
- sequence_number: import_v42.z.number()
812
+ sequence_number: z2.number()
823
813
  });
824
- var responseOutputItemDoneSchema = import_v42.z.object({
825
- type: import_v42.z.literal("response.output_item.done"),
826
- output_index: import_v42.z.number(),
827
- item: import_v42.z.discriminatedUnion("type", [
828
- import_v42.z.object({
829
- type: import_v42.z.literal("message"),
830
- id: import_v42.z.string(),
831
- role: import_v42.z.string().optional(),
832
- status: import_v42.z.string().optional(),
833
- content: import_v42.z.array(import_v42.z.any()).optional()
814
+ var responseOutputItemDoneSchema = z2.object({
815
+ type: z2.literal("response.output_item.done"),
816
+ output_index: z2.number(),
817
+ item: z2.discriminatedUnion("type", [
818
+ z2.object({
819
+ type: z2.literal("message"),
820
+ id: z2.string(),
821
+ role: z2.string().optional(),
822
+ status: z2.string().optional(),
823
+ content: z2.array(z2.any()).optional()
834
824
  }),
835
- import_v42.z.object({
836
- type: import_v42.z.literal("mcp_list_tools"),
837
- id: import_v42.z.string(),
838
- server_label: import_v42.z.string(),
839
- tools: import_v42.z.array(import_v42.z.any()).optional(),
840
- error: import_v42.z.string().optional()
825
+ z2.object({
826
+ type: z2.literal("mcp_list_tools"),
827
+ id: z2.string(),
828
+ server_label: z2.string(),
829
+ tools: z2.array(z2.any()).optional(),
830
+ error: z2.string().optional()
841
831
  }),
842
- import_v42.z.object({
843
- type: import_v42.z.literal("mcp_call"),
844
- id: import_v42.z.string(),
845
- server_label: import_v42.z.string(),
846
- name: import_v42.z.string(),
847
- arguments: import_v42.z.string(),
848
- output: import_v42.z.string().optional(),
849
- error: import_v42.z.string().optional()
832
+ z2.object({
833
+ type: z2.literal("mcp_call"),
834
+ id: z2.string(),
835
+ server_label: z2.string(),
836
+ name: z2.string(),
837
+ arguments: z2.string(),
838
+ output: z2.string().optional(),
839
+ error: z2.string().optional()
850
840
  }),
851
- import_v42.z.object({
852
- type: import_v42.z.literal("function_call"),
853
- id: import_v42.z.string(),
854
- call_id: import_v42.z.string(),
855
- name: import_v42.z.string(),
856
- arguments: import_v42.z.string(),
857
- output: import_v42.z.string().optional(),
858
- error: import_v42.z.string().optional()
841
+ z2.object({
842
+ type: z2.literal("function_call"),
843
+ id: z2.string(),
844
+ call_id: z2.string(),
845
+ name: z2.string(),
846
+ arguments: z2.string(),
847
+ output: z2.string().optional(),
848
+ error: z2.string().optional()
859
849
  }),
860
- import_v42.z.object({
861
- type: import_v42.z.literal("reasoning"),
862
- id: import_v42.z.string(),
863
- status: import_v42.z.string().optional(),
864
- content: import_v42.z.array(import_v42.z.any()).optional(),
865
- summary: import_v42.z.array(import_v42.z.any()).optional()
850
+ z2.object({
851
+ type: z2.literal("reasoning"),
852
+ id: z2.string(),
853
+ status: z2.string().optional(),
854
+ content: z2.array(z2.any()).optional(),
855
+ summary: z2.array(z2.any()).optional()
866
856
  })
867
857
  ]),
868
- sequence_number: import_v42.z.number()
858
+ sequence_number: z2.number()
869
859
  });
870
- var textDeltaChunkSchema = import_v42.z.object({
871
- type: import_v42.z.literal("response.output_text.delta"),
872
- item_id: import_v42.z.string(),
873
- output_index: import_v42.z.number(),
874
- content_index: import_v42.z.number(),
875
- delta: import_v42.z.string(),
876
- sequence_number: import_v42.z.number()
860
+ var textDeltaChunkSchema = z2.object({
861
+ type: z2.literal("response.output_text.delta"),
862
+ item_id: z2.string(),
863
+ output_index: z2.number(),
864
+ content_index: z2.number(),
865
+ delta: z2.string(),
866
+ sequence_number: z2.number()
877
867
  });
878
- var reasoningTextDeltaChunkSchema = import_v42.z.object({
879
- type: import_v42.z.literal("response.reasoning_text.delta"),
880
- item_id: import_v42.z.string(),
881
- output_index: import_v42.z.number(),
882
- content_index: import_v42.z.number(),
883
- delta: import_v42.z.string(),
884
- sequence_number: import_v42.z.number()
868
+ var reasoningTextDeltaChunkSchema = z2.object({
869
+ type: z2.literal("response.reasoning_text.delta"),
870
+ item_id: z2.string(),
871
+ output_index: z2.number(),
872
+ content_index: z2.number(),
873
+ delta: z2.string(),
874
+ sequence_number: z2.number()
885
875
  });
886
- var reasoningTextEndChunkSchema = import_v42.z.object({
887
- type: import_v42.z.literal("response.reasoning_text.done"),
888
- item_id: import_v42.z.string(),
889
- output_index: import_v42.z.number(),
890
- content_index: import_v42.z.number(),
891
- text: import_v42.z.string(),
892
- sequence_number: import_v42.z.number()
876
+ var reasoningTextEndChunkSchema = z2.object({
877
+ type: z2.literal("response.reasoning_text.done"),
878
+ item_id: z2.string(),
879
+ output_index: z2.number(),
880
+ content_index: z2.number(),
881
+ text: z2.string(),
882
+ sequence_number: z2.number()
893
883
  });
894
- var responseCompletedChunkSchema = import_v42.z.object({
895
- type: import_v42.z.literal("response.completed"),
884
+ var responseCompletedChunkSchema = z2.object({
885
+ type: z2.literal("response.completed"),
896
886
  response: huggingfaceResponsesResponseSchema,
897
- sequence_number: import_v42.z.number()
887
+ sequence_number: z2.number()
898
888
  });
899
- var responseCreatedChunkSchema = import_v42.z.object({
900
- type: import_v42.z.literal("response.created"),
901
- response: import_v42.z.object({
902
- id: import_v42.z.string(),
903
- object: import_v42.z.string(),
904
- created_at: import_v42.z.number(),
905
- status: import_v42.z.string(),
906
- model: import_v42.z.string()
889
+ var responseCreatedChunkSchema = z2.object({
890
+ type: z2.literal("response.created"),
891
+ response: z2.object({
892
+ id: z2.string(),
893
+ object: z2.string(),
894
+ created_at: z2.number(),
895
+ status: z2.string(),
896
+ model: z2.string()
907
897
  })
908
898
  });
909
- var huggingfaceResponsesChunkSchema = import_v42.z.union([
899
+ var huggingfaceResponsesChunkSchema = z2.union([
910
900
  responseOutputItemAddedSchema,
911
901
  responseOutputItemDoneSchema,
912
902
  reasoningTextDeltaChunkSchema,
@@ -914,7 +904,7 @@ var huggingfaceResponsesChunkSchema = import_v42.z.union([
914
904
  textDeltaChunkSchema,
915
905
  responseCompletedChunkSchema,
916
906
  responseCreatedChunkSchema,
917
- import_v42.z.object({ type: import_v42.z.string() }).loose()
907
+ z2.object({ type: z2.string() }).loose()
918
908
  // fallback for unknown chunks
919
909
  ]);
920
910
  function isResponseOutputItemAddedChunk(chunk) {
@@ -942,9 +932,9 @@ function isResponseCreatedChunk(chunk) {
942
932
  // src/huggingface-provider.ts
943
933
  function createHuggingFace(options = {}) {
944
934
  var _a;
945
- const baseURL = (_a = (0, import_provider_utils4.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://router.huggingface.co/v1";
935
+ const baseURL = (_a = withoutTrailingSlash(options.baseURL)) != null ? _a : "https://router.huggingface.co/v1";
946
936
  const getHeaders = () => ({
947
- Authorization: `Bearer ${(0, import_provider_utils4.loadApiKey)({
937
+ Authorization: `Bearer ${loadApiKey({
948
938
  apiKey: options.apiKey,
949
939
  environmentVariableName: "HUGGINGFACE_API_KEY",
950
940
  description: "Hugging Face"
@@ -958,7 +948,7 @@ function createHuggingFace(options = {}) {
958
948
  url: ({ path }) => `${baseURL}${path}`,
959
949
  headers: getHeaders,
960
950
  fetch: options.fetch,
961
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils4.generateId
951
+ generateId: (_a2 = options.generateId) != null ? _a2 : generateId2
962
952
  });
963
953
  };
964
954
  const provider = (modelId) => createResponsesModel(modelId);
@@ -966,7 +956,7 @@ function createHuggingFace(options = {}) {
966
956
  provider.languageModel = createResponsesModel;
967
957
  provider.responses = createResponsesModel;
968
958
  provider.embeddingModel = (modelId) => {
969
- throw new import_provider3.NoSuchModelError({
959
+ throw new NoSuchModelError({
970
960
  modelId,
971
961
  modelType: "embeddingModel",
972
962
  message: "Hugging Face Responses API does not support text embeddings. Use the Hugging Face Inference API directly for embeddings."
@@ -974,7 +964,7 @@ function createHuggingFace(options = {}) {
974
964
  };
975
965
  provider.textEmbeddingModel = provider.embeddingModel;
976
966
  provider.imageModel = (modelId) => {
977
- throw new import_provider3.NoSuchModelError({
967
+ throw new NoSuchModelError({
978
968
  modelId,
979
969
  modelType: "imageModel",
980
970
  message: "Hugging Face Responses API does not support image generation. Use the Hugging Face Inference API directly for image models."
@@ -983,9 +973,8 @@ function createHuggingFace(options = {}) {
983
973
  return provider;
984
974
  }
985
975
  var huggingface = createHuggingFace();
986
- // Annotate the CommonJS export names for ESM import in node:
987
- 0 && (module.exports = {
976
+ export {
988
977
  createHuggingFace,
989
978
  huggingface
990
- });
979
+ };
991
980
  //# sourceMappingURL=index.js.map