@aihubmix/ai-sdk-provider 0.0.1

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 ADDED
@@ -0,0 +1,17 @@
1
+ # @ai-sdk/aihubmix
2
+
3
+ ## 0.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Initial release of Aihubmix provider
8
+ - Support for multiple AI providers through Aihubmix API
9
+ - Support for OpenAI-compatible models (GPT models)
10
+ - Support for Anthropic Claude models
11
+ - Support for Google Gemini models
12
+ - Support for image generation models
13
+ - Support for embedding models
14
+ - Support for transcription models
15
+ - Support for speech synthesis models
16
+ - Support for web search preview tool
17
+ - Strict compatibility mode with OpenAI API
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,163 @@
1
+ # AI SDK - Aihubmix Provider
2
+
3
+ > **🎉 10% discount!**
4
+ Added app-code; this way, requesting all models through ai-sdk offers a 10% discount.
5
+
6
+ **[Aihubmix Official Website](https://aihubmix.com/)** | **[Model Square](https://aihubmix.com/models)**
7
+
8
+ The **[Aihubmix provider](https://ai-sdk.dev/providers/ai-sdk-providers/aihubmix)** for the [AI SDK](https://ai-sdk.dev/docs)
9
+ One Gateway, Infinite Models;one-stop request: OpenAI, Claude, Gemini, DeepSeek, Qwen, and over 500 AI models.
10
+
11
+ ## Setup
12
+
13
+ The Aihubmix provider is available in the `@aihubmix/ai-sdk-provider` module. You can install it with
14
+
15
+ ```bash
16
+ npm i @aihubmix/ai-sdk-provider
17
+ ```
18
+
19
+ ## Provider Instance
20
+
21
+ You can import the default provider instance `aihubmix` from `@aihubmix/ai-sdk-provider`:
22
+
23
+ ```ts
24
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
25
+ ```
26
+
27
+ ## Configuration
28
+
29
+ Set your Aihubmix API key as an environment variable:
30
+
31
+ ```bash
32
+ export AIHUBMIX_API_KEY="your-api-key-here"
33
+ ```
34
+
35
+ Or pass it directly to the provider:
36
+
37
+ ```ts
38
+ import { createAihubmix } from '@aihubmix/ai-sdk-provider';
39
+
40
+ const aihubmix = createAihubmix({
41
+ apiKey: 'your-api-key-here',
42
+ });
43
+ ```
44
+
45
+ ## Supported Models
46
+
47
+ ### OpenAI-Compatible Models
48
+
49
+ - GPT-4, GPT-3.5, and other OpenAI models
50
+ - Image generation models
51
+ - Embedding models
52
+ - Transcription models
53
+ - Speech synthesis models
54
+
55
+ ### Anthropic Claude Models
56
+
57
+ - Claude-3 models (claude-3-opus, claude-3-sonnet, claude-3-haiku)
58
+ - Claude-2 models
59
+
60
+ ### Google Gemini Models
61
+
62
+ - Gemini Pro models
63
+ - Gemini Flash models
64
+ - Imagen models
65
+
66
+ ### Other Models => [Model Square](https://aihubmix.com/models)
67
+
68
+ ## Examples
69
+
70
+ ### Chat Completion
71
+
72
+ ```ts
73
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
74
+ import { generateText } from 'ai';
75
+
76
+ const { text } = await generateText({
77
+ model: aihubmix('o4-mini'),
78
+ prompt: 'Write a vegetarian lasagna recipe for 4 people.',
79
+ });
80
+ ```
81
+
82
+ ### Claude Model
83
+
84
+ ```ts
85
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
86
+ import { generateText } from 'ai';
87
+
88
+ const { text } = await generateText({
89
+ model: aihubmix('claude-3-7-sonnet-20250219'),
90
+ prompt: 'Explain quantum computing in simple terms.',
91
+ });
92
+ ```
93
+
94
+ ### Gemini Model
95
+
96
+ ```ts
97
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
98
+ import { generateText } from 'ai';
99
+
100
+ const { text } = await generateText({
101
+ model: aihubmix('gemini-2.5-flash'),
102
+ prompt: 'Create a Python script to sort a list of numbers.',
103
+ });
104
+ ```
105
+
106
+ ### Image Generation
107
+
108
+ ```ts
109
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
110
+ import { generateImage } from 'ai';
111
+
112
+ const { image } = await generateImage({
113
+ model: aihubmix.image('gpt-image-1'),
114
+ prompt: 'A beautiful sunset over mountains',
115
+ });
116
+ ```
117
+
118
+ ### Embeddings
119
+
120
+ ```ts
121
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
122
+ import { embed } from 'ai';
123
+
124
+ const { embedding } = await embed({
125
+ model: aihubmix.embedding('text-embedding-ada-002'),
126
+ value: 'Hello, world!',
127
+ });
128
+ ```
129
+
130
+ ### Transcription
131
+
132
+ ```ts
133
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
134
+ import { transcribe } from 'ai';
135
+
136
+ const { text } = await transcribe({
137
+ model: aihubmix.transcription('whisper-1'),
138
+ audio: audioFile,
139
+ });
140
+ ```
141
+
142
+ ## Tools
143
+
144
+ The Aihubmix provider supports various tools including web search:
145
+
146
+ ```ts
147
+ import { aihubmix } from '@aihubmix/ai-sdk-provider';
148
+ import { generateText } from 'ai';
149
+
150
+ const { text } = await generateText({
151
+ model: aihubmix('gpt-4'),
152
+ prompt: 'What are the latest developments in AI?',
153
+ tools: {
154
+ webSearchPreview: aihubmix.tools.webSearchPreview({
155
+ searchContextSize: 'high',
156
+ }),
157
+ },
158
+ });
159
+ ```
160
+
161
+ ## Documentation
162
+
163
+ Please check out the **[Aihubmix provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/aihubmix)** for more information.
@@ -0,0 +1,50 @@
1
+ import { OpenAIChatSettings, OpenAICompletionSettings, OpenAIEmbeddingSettings, OpenAIImageSettings } from '@ai-sdk/openai/internal';
2
+ import { ProviderV1, LanguageModelV1, EmbeddingModelV1, ImageModelV1, TranscriptionModelV1, SpeechModelV1 } from '@ai-sdk/provider';
3
+ import { FetchFunction } from '@ai-sdk/provider-utils';
4
+ import { z } from 'zod';
5
+
6
+ declare const WebSearchPreviewParameters: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
7
+ declare function webSearchPreviewTool({ searchContextSize, userLocation, }?: {
8
+ searchContextSize?: 'low' | 'medium' | 'high';
9
+ userLocation?: {
10
+ type?: 'approximate';
11
+ city?: string;
12
+ region?: string;
13
+ country?: string;
14
+ timezone?: string;
15
+ };
16
+ }): {
17
+ type: 'provider-defined';
18
+ id: 'openai.web_search_preview';
19
+ args: {};
20
+ parameters: typeof WebSearchPreviewParameters;
21
+ };
22
+ declare const openaiTools: {
23
+ webSearchPreview: typeof webSearchPreviewTool;
24
+ };
25
+
26
+ interface AihubmixProvider extends ProviderV1 {
27
+ (deploymentId: string, settings?: OpenAIChatSettings): LanguageModelV1;
28
+ languageModel(deploymentId: string, settings?: OpenAIChatSettings): LanguageModelV1;
29
+ chat(deploymentId: string, settings?: OpenAIChatSettings): LanguageModelV1;
30
+ responses(deploymentId: string): LanguageModelV1;
31
+ completion(deploymentId: string, settings?: OpenAICompletionSettings): LanguageModelV1;
32
+ embedding(deploymentId: string, settings?: OpenAIEmbeddingSettings): EmbeddingModelV1<string>;
33
+ image(deploymentId: string, settings?: OpenAIImageSettings): ImageModelV1;
34
+ imageModel(deploymentId: string, settings?: OpenAIImageSettings): ImageModelV1;
35
+ textEmbedding(deploymentId: string, settings?: OpenAIEmbeddingSettings): EmbeddingModelV1<string>;
36
+ textEmbeddingModel(deploymentId: string, settings?: OpenAIEmbeddingSettings): EmbeddingModelV1<string>;
37
+ transcription(deploymentId: string): TranscriptionModelV1;
38
+ speech(deploymentId: string): SpeechModelV1;
39
+ speechModel(deploymentId: string): SpeechModelV1;
40
+ tools: typeof openaiTools;
41
+ }
42
+ interface AihubmixProviderSettings {
43
+ apiKey?: string;
44
+ fetch?: FetchFunction;
45
+ compatibility?: 'strict' | 'compatible';
46
+ }
47
+ declare function createAihubmix(options?: AihubmixProviderSettings): AihubmixProvider;
48
+ declare const aihubmix: AihubmixProvider;
49
+
50
+ export { type AihubmixProvider, type AihubmixProviderSettings, aihubmix, createAihubmix };
@@ -0,0 +1,50 @@
1
+ import { OpenAIChatSettings, OpenAICompletionSettings, OpenAIEmbeddingSettings, OpenAIImageSettings } from '@ai-sdk/openai/internal';
2
+ import { ProviderV1, LanguageModelV1, EmbeddingModelV1, ImageModelV1, TranscriptionModelV1, SpeechModelV1 } from '@ai-sdk/provider';
3
+ import { FetchFunction } from '@ai-sdk/provider-utils';
4
+ import { z } from 'zod';
5
+
6
+ declare const WebSearchPreviewParameters: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
7
+ declare function webSearchPreviewTool({ searchContextSize, userLocation, }?: {
8
+ searchContextSize?: 'low' | 'medium' | 'high';
9
+ userLocation?: {
10
+ type?: 'approximate';
11
+ city?: string;
12
+ region?: string;
13
+ country?: string;
14
+ timezone?: string;
15
+ };
16
+ }): {
17
+ type: 'provider-defined';
18
+ id: 'openai.web_search_preview';
19
+ args: {};
20
+ parameters: typeof WebSearchPreviewParameters;
21
+ };
22
+ declare const openaiTools: {
23
+ webSearchPreview: typeof webSearchPreviewTool;
24
+ };
25
+
26
+ interface AihubmixProvider extends ProviderV1 {
27
+ (deploymentId: string, settings?: OpenAIChatSettings): LanguageModelV1;
28
+ languageModel(deploymentId: string, settings?: OpenAIChatSettings): LanguageModelV1;
29
+ chat(deploymentId: string, settings?: OpenAIChatSettings): LanguageModelV1;
30
+ responses(deploymentId: string): LanguageModelV1;
31
+ completion(deploymentId: string, settings?: OpenAICompletionSettings): LanguageModelV1;
32
+ embedding(deploymentId: string, settings?: OpenAIEmbeddingSettings): EmbeddingModelV1<string>;
33
+ image(deploymentId: string, settings?: OpenAIImageSettings): ImageModelV1;
34
+ imageModel(deploymentId: string, settings?: OpenAIImageSettings): ImageModelV1;
35
+ textEmbedding(deploymentId: string, settings?: OpenAIEmbeddingSettings): EmbeddingModelV1<string>;
36
+ textEmbeddingModel(deploymentId: string, settings?: OpenAIEmbeddingSettings): EmbeddingModelV1<string>;
37
+ transcription(deploymentId: string): TranscriptionModelV1;
38
+ speech(deploymentId: string): SpeechModelV1;
39
+ speechModel(deploymentId: string): SpeechModelV1;
40
+ tools: typeof openaiTools;
41
+ }
42
+ interface AihubmixProviderSettings {
43
+ apiKey?: string;
44
+ fetch?: FetchFunction;
45
+ compatibility?: 'strict' | 'compatible';
46
+ }
47
+ declare function createAihubmix(options?: AihubmixProviderSettings): AihubmixProvider;
48
+ declare const aihubmix: AihubmixProvider;
49
+
50
+ export { type AihubmixProvider, type AihubmixProviderSettings, aihubmix, createAihubmix };
package/dist/index.js ADDED
@@ -0,0 +1,237 @@
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
+ aihubmix: () => aihubmix,
24
+ createAihubmix: () => createAihubmix
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/aihubmix-provider.ts
29
+ var import_internal = require("@ai-sdk/openai/internal");
30
+ var import_internal2 = require("@ai-sdk/anthropic/internal");
31
+ var import_internal3 = require("@ai-sdk/google/internal");
32
+ var import_provider_utils = require("@ai-sdk/provider-utils");
33
+
34
+ // src/aihubmix-tools.ts
35
+ var import_zod = require("zod");
36
+ var WebSearchPreviewParameters = import_zod.z.object({});
37
+ function webSearchPreviewTool({
38
+ searchContextSize,
39
+ userLocation
40
+ } = {}) {
41
+ return {
42
+ type: "provider-defined",
43
+ id: "openai.web_search_preview",
44
+ args: {
45
+ searchContextSize,
46
+ userLocation
47
+ },
48
+ parameters: WebSearchPreviewParameters
49
+ };
50
+ }
51
+ var openaiTools = {
52
+ webSearchPreview: webSearchPreviewTool
53
+ };
54
+
55
+ // src/aihubmix-provider.ts
56
+ var AihubmixTranscriptionModel = class extends import_internal.OpenAITranscriptionModel {
57
+ async doGenerate(options) {
58
+ if (options.mediaType) {
59
+ const mimeTypeMap = {
60
+ "audio/mpeg": "mp3",
61
+ "audio/mp3": "mp3",
62
+ "audio/wav": "wav",
63
+ "audio/flac": "flac",
64
+ "audio/m4a": "m4a",
65
+ "audio/mp4": "mp4",
66
+ "audio/ogg": "ogg",
67
+ "audio/webm": "webm",
68
+ "audio/oga": "oga",
69
+ "audio/mpga": "mpga"
70
+ };
71
+ const extension = mimeTypeMap[options.mediaType];
72
+ if (extension) {
73
+ const modifiedOptions = {
74
+ ...options,
75
+ mediaType: options.mediaType
76
+ };
77
+ const originalGetArgs = this.getArgs;
78
+ this.getArgs = function(args) {
79
+ const result = originalGetArgs.call(this, args);
80
+ if (result.formData) {
81
+ const fileEntry = result.formData.get("file");
82
+ if (fileEntry && typeof fileEntry === "object" && "name" in fileEntry) {
83
+ try {
84
+ const newFile = new globalThis.File([fileEntry], `audio.${extension}`, {
85
+ type: options.mediaType
86
+ });
87
+ result.formData.set("file", newFile);
88
+ } catch (error) {
89
+ if (fileEntry && typeof fileEntry === "object") {
90
+ fileEntry.name = `audio.${extension}`;
91
+ }
92
+ }
93
+ }
94
+ }
95
+ return result;
96
+ };
97
+ return super.doGenerate(modifiedOptions);
98
+ }
99
+ }
100
+ return super.doGenerate(options);
101
+ }
102
+ };
103
+ function createAihubmix(options = {}) {
104
+ const compatibility = options.compatibility ?? "compatible";
105
+ const getHeaders = () => ({
106
+ Authorization: `Bearer ${(0, import_provider_utils.loadApiKey)({
107
+ apiKey: options.apiKey,
108
+ environmentVariableName: "AIHUBMIX_API_KEY",
109
+ description: "Aihubmix"
110
+ })}`,
111
+ "APP-Code": "WHVL9885",
112
+ "Content-Type": "application/json"
113
+ });
114
+ const getTranscriptionHeaders = () => ({
115
+ Authorization: `Bearer ${(0, import_provider_utils.loadApiKey)({
116
+ apiKey: options.apiKey,
117
+ environmentVariableName: "AIHUBMIX_API_KEY",
118
+ description: "Aihubmix"
119
+ })}`,
120
+ "APP-Code": "WHVL9885"
121
+ });
122
+ const url = ({ path, modelId }) => {
123
+ const baseURL = "https://aihubmix.com/v1";
124
+ return `${baseURL}${path}`;
125
+ };
126
+ const createChatModel = (deploymentName, settings = {}) => {
127
+ const headers = getHeaders();
128
+ if (deploymentName.startsWith("claude-")) {
129
+ return new import_internal2.AnthropicMessagesLanguageModel(
130
+ deploymentName,
131
+ settings,
132
+ {
133
+ provider: "aihubmix.chat",
134
+ baseURL: url({ path: "", modelId: deploymentName }),
135
+ headers: {
136
+ ...headers,
137
+ "x-api-key": headers["Authorization"].split(" ")[1]
138
+ },
139
+ supportsImageUrls: true
140
+ }
141
+ );
142
+ }
143
+ if ((deploymentName.startsWith("gemini") || deploymentName.startsWith("imagen")) && !deploymentName.endsWith("-nothink") && !deploymentName.endsWith("-search")) {
144
+ return new import_internal3.GoogleGenerativeAILanguageModel(
145
+ deploymentName,
146
+ settings,
147
+ {
148
+ provider: "aihubmix.chat",
149
+ baseURL: "https://aihubmix.com/gemini/v1beta",
150
+ headers: {
151
+ ...headers,
152
+ "x-goog-api-key": headers["Authorization"].split(" ")[1]
153
+ },
154
+ generateId: () => `aihubmix-${Date.now()}`,
155
+ isSupportedUrl: () => true
156
+ }
157
+ );
158
+ }
159
+ return new import_internal.OpenAIChatLanguageModel(deploymentName, settings, {
160
+ provider: "aihubmix.chat",
161
+ url,
162
+ headers: getHeaders,
163
+ compatibility,
164
+ fetch: options.fetch
165
+ });
166
+ };
167
+ const createCompletionModel = (modelId, settings = {}) => new import_internal.OpenAICompletionLanguageModel(modelId, settings, {
168
+ provider: "aihubmix.completion",
169
+ url,
170
+ compatibility,
171
+ headers: getHeaders,
172
+ fetch: options.fetch
173
+ });
174
+ const createEmbeddingModel = (modelId, settings = {}) => {
175
+ return new import_internal.OpenAIEmbeddingModel(modelId, settings, {
176
+ provider: "aihubmix.embeddings",
177
+ headers: getHeaders,
178
+ url,
179
+ fetch: options.fetch
180
+ });
181
+ };
182
+ const createResponsesModel = (modelId) => new import_internal.OpenAIResponsesLanguageModel(modelId, {
183
+ provider: "aihubmix.responses",
184
+ url,
185
+ headers: getHeaders
186
+ });
187
+ const createImageModel = (modelId, settings = {}) => {
188
+ return new import_internal.OpenAIImageModel(modelId, settings, {
189
+ provider: "aihubmix.image",
190
+ url,
191
+ headers: getHeaders,
192
+ fetch: options.fetch
193
+ });
194
+ };
195
+ const createTranscriptionModel = (modelId) => new AihubmixTranscriptionModel(modelId, {
196
+ provider: "aihubmix.transcription",
197
+ url,
198
+ headers: getTranscriptionHeaders,
199
+ fetch: options.fetch
200
+ });
201
+ const createSpeechModel = (modelId) => new import_internal.OpenAISpeechModel(modelId, {
202
+ provider: "aihubmix.speech",
203
+ url,
204
+ headers: getHeaders,
205
+ fetch: options.fetch
206
+ });
207
+ const provider = function(deploymentId, settings) {
208
+ if (new.target) {
209
+ throw new Error(
210
+ "The Aihubmix model function cannot be called with the new keyword."
211
+ );
212
+ }
213
+ return createChatModel(deploymentId, settings);
214
+ };
215
+ provider.languageModel = createChatModel;
216
+ provider.chat = createChatModel;
217
+ provider.completion = createCompletionModel;
218
+ provider.responses = createResponsesModel;
219
+ provider.embedding = createEmbeddingModel;
220
+ provider.textEmbedding = createEmbeddingModel;
221
+ provider.textEmbeddingModel = createEmbeddingModel;
222
+ provider.image = createImageModel;
223
+ provider.imageModel = createImageModel;
224
+ provider.transcription = createTranscriptionModel;
225
+ provider.transcriptionModel = createTranscriptionModel;
226
+ provider.speech = createSpeechModel;
227
+ provider.speechModel = createSpeechModel;
228
+ provider.tools = openaiTools;
229
+ return provider;
230
+ }
231
+ var aihubmix = createAihubmix();
232
+ // Annotate the CommonJS export names for ESM import in node:
233
+ 0 && (module.exports = {
234
+ aihubmix,
235
+ createAihubmix
236
+ });
237
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/aihubmix-provider.ts","../src/aihubmix-tools.ts"],"sourcesContent":["export { aihubmix, createAihubmix } from './aihubmix-provider';\nexport type {\n AihubmixProvider,\n AihubmixProviderSettings,\n} from './aihubmix-provider';\n","import {\n OpenAIChatLanguageModel,\n OpenAIChatSettings,\n OpenAICompletionLanguageModel,\n OpenAICompletionSettings,\n OpenAIEmbeddingModel,\n OpenAIEmbeddingSettings,\n OpenAIImageModel,\n OpenAIImageSettings,\n OpenAIResponsesLanguageModel,\n OpenAITranscriptionModel,\n OpenAISpeechModel,\n} from '@ai-sdk/openai/internal';\nimport {\n AnthropicMessagesLanguageModel,\n AnthropicMessagesSettings,\n} from '@ai-sdk/anthropic/internal';\nimport {\n InternalGoogleGenerativeAISettings,\n GoogleGenerativeAILanguageModel,\n} from '@ai-sdk/google/internal';\nimport {\n EmbeddingModelV1,\n LanguageModelV1,\n ProviderV1,\n ImageModelV1,\n TranscriptionModelV1,\n SpeechModelV1,\n TranscriptionModelV1CallOptions,\n} from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { openaiTools } from './aihubmix-tools';\n\nexport interface AihubmixProvider extends ProviderV1 {\n (deploymentId: string, settings?: OpenAIChatSettings): LanguageModelV1;\n\n languageModel(\n deploymentId: string,\n settings?: OpenAIChatSettings,\n ): LanguageModelV1;\n\n chat(deploymentId: string, settings?: OpenAIChatSettings): LanguageModelV1;\n\n responses(deploymentId: string): LanguageModelV1;\n\n completion(\n deploymentId: string,\n settings?: OpenAICompletionSettings,\n ): LanguageModelV1;\n\n embedding(\n deploymentId: string,\n settings?: OpenAIEmbeddingSettings,\n ): EmbeddingModelV1<string>;\n\n image(deploymentId: string, settings?: OpenAIImageSettings): ImageModelV1;\n\n imageModel(\n deploymentId: string,\n settings?: OpenAIImageSettings,\n ): ImageModelV1;\n\n textEmbedding(\n deploymentId: string,\n settings?: OpenAIEmbeddingSettings,\n ): EmbeddingModelV1<string>;\n\n textEmbeddingModel(\n deploymentId: string,\n settings?: OpenAIEmbeddingSettings,\n ): EmbeddingModelV1<string>;\n\n transcription(deploymentId: string): TranscriptionModelV1;\n\n speech(deploymentId: string): SpeechModelV1;\n\n speechModel(deploymentId: string): SpeechModelV1;\n\n tools: typeof openaiTools;\n}\n\nclass AihubmixTranscriptionModel extends OpenAITranscriptionModel {\n async doGenerate(options: TranscriptionModelV1CallOptions) {\n // 根据MIME类型设置正确的文件扩展名\n if (options.mediaType) {\n const mimeTypeMap: Record<string, string> = {\n 'audio/mpeg': 'mp3',\n 'audio/mp3': 'mp3',\n 'audio/wav': 'wav',\n 'audio/flac': 'flac',\n 'audio/m4a': 'm4a',\n 'audio/mp4': 'mp4',\n 'audio/ogg': 'ogg',\n 'audio/webm': 'webm',\n 'audio/oga': 'oga',\n 'audio/mpga': 'mpga',\n };\n \n const extension = mimeTypeMap[options.mediaType];\n if (extension) {\n // 修改options,确保文件名有正确的扩展名\n const modifiedOptions = {\n ...options,\n mediaType: options.mediaType,\n };\n \n // 重写getArgs方法来设置正确的文件名\n const originalGetArgs = (this as any).getArgs;\n (this as any).getArgs = function(args: any) {\n const result = originalGetArgs.call(this, args);\n if (result.formData) {\n // 找到file字段并修改文件名\n const fileEntry = result.formData.get('file');\n if (fileEntry && typeof fileEntry === 'object' && 'name' in fileEntry) {\n // 在 Node.js 环境中,我们可能需要创建一个新的文件对象\n // 或者直接修改现有的对象\n try {\n const newFile = new (globalThis as any).File([fileEntry], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n } catch (error) {\n // 如果 File 构造函数不可用,尝试修改现有对象的名称\n if (fileEntry && typeof fileEntry === 'object') {\n (fileEntry as any).name = `audio.${extension}`;\n }\n }\n }\n }\n return result;\n };\n \n return super.doGenerate(modifiedOptions);\n }\n }\n \n return super.doGenerate(options);\n }\n}\n\nexport interface AihubmixProviderSettings {\n apiKey?: string;\n fetch?: FetchFunction;\n compatibility?: 'strict' | 'compatible';\n}\n\nexport function createAihubmix(\n options: AihubmixProviderSettings = {},\n): AihubmixProvider {\n const compatibility = options.compatibility ?? 'compatible';\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n 'Content-Type': 'application/json',\n });\n\n const getTranscriptionHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n });\n\n const url = ({ path, modelId }: { path: string; modelId: string }) => {\n const baseURL = 'https://aihubmix.com/v1';\n return `${baseURL}${path}`;\n };\n\n const createChatModel = (\n deploymentName: string,\n settings: OpenAIChatSettings = {},\n ) => {\n const headers = getHeaders();\n if (deploymentName.startsWith('claude-')) {\n return new AnthropicMessagesLanguageModel(\n deploymentName,\n settings as AnthropicMessagesSettings,\n {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...headers,\n 'x-api-key': headers['Authorization'].split(' ')[1],\n },\n supportsImageUrls: true,\n },\n );\n }\n if (\n (deploymentName.startsWith('gemini') ||\n deploymentName.startsWith('imagen')) &&\n !deploymentName.endsWith('-nothink') &&\n !deploymentName.endsWith('-search')\n ) {\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n settings as InternalGoogleGenerativeAISettings,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...headers,\n 'x-goog-api-key': headers['Authorization'].split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n isSupportedUrl: () => true,\n },\n );\n }\n\n return new OpenAIChatLanguageModel(deploymentName, settings, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n compatibility,\n fetch: options.fetch,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: OpenAICompletionSettings = {},\n ) =>\n new OpenAICompletionLanguageModel(modelId, settings, {\n provider: 'aihubmix.completion',\n url,\n compatibility,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: OpenAIEmbeddingSettings = {},\n ) => {\n return new OpenAIEmbeddingModel(modelId, settings, {\n provider: 'aihubmix.embeddings',\n headers: getHeaders,\n url,\n fetch: options.fetch,\n });\n };\n\n const createResponsesModel = (modelId: string) =>\n new OpenAIResponsesLanguageModel(modelId, {\n provider: 'aihubmix.responses',\n url,\n headers: getHeaders,\n });\n\n const createImageModel = (\n modelId: string,\n settings: OpenAIImageSettings = {},\n ) => {\n return new OpenAIImageModel(modelId, settings, {\n provider: 'aihubmix.image',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createTranscriptionModel = (modelId: string) =>\n new AihubmixTranscriptionModel(modelId, {\n provider: 'aihubmix.transcription',\n url,\n headers: getTranscriptionHeaders,\n fetch: options.fetch,\n });\n const createSpeechModel = (modelId: string) =>\n new OpenAISpeechModel(modelId, {\n provider: 'aihubmix.speech',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n const provider = function (\n deploymentId: string,\n settings?: OpenAIChatSettings | OpenAICompletionSettings,\n ) {\n if (new.target) {\n throw new Error(\n 'The Aihubmix model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(deploymentId, settings as OpenAIChatSettings);\n };\n\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.completion = createCompletionModel;\n provider.responses = createResponsesModel;\n provider.embedding = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n provider.tools = openaiTools;\n\n return provider as AihubmixProvider;\n}\n\nexport const aihubmix = createAihubmix();\n","import { z } from 'zod';\n\nconst WebSearchPreviewParameters = z.object({});\n\nfunction webSearchPreviewTool({\n searchContextSize,\n userLocation,\n}: {\n searchContextSize?: 'low' | 'medium' | 'high';\n userLocation?: {\n type?: 'approximate';\n city?: string;\n region?: string;\n country?: string;\n timezone?: string;\n };\n} = {}): {\n type: 'provider-defined';\n id: 'openai.web_search_preview';\n args: {};\n parameters: typeof WebSearchPreviewParameters;\n} {\n return {\n type: 'provider-defined',\n id: 'openai.web_search_preview',\n args: {\n searchContextSize,\n userLocation,\n },\n parameters: WebSearchPreviewParameters,\n };\n}\n\nexport const openaiTools = {\n webSearchPreview: webSearchPreviewTool,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAYO;AACP,IAAAA,mBAGO;AACP,IAAAA,mBAGO;AAUP,4BAA0C;;;AC9B1C,iBAAkB;AAElB,IAAM,6BAA6B,aAAE,OAAO,CAAC,CAAC;AAE9C,SAAS,qBAAqB;AAAA,EAC5B;AAAA,EACA;AACF,IASI,CAAC,GAKH;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,IAAI;AAAA,IACJ,MAAM;AAAA,MACJ;AAAA,MACA;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AACF;AAEO,IAAM,cAAc;AAAA,EACzB,kBAAkB;AACpB;;;AD8CA,IAAM,6BAAN,cAAyC,yCAAyB;AAAA,EAChE,MAAM,WAAW,SAA0C;AAEzD,QAAI,QAAQ,WAAW;AACrB,YAAM,cAAsC;AAAA,QAC1C,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QACb,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;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gB;AACzB,WAAS,qBAAqB;AAE9B,WAAS,SAAS;AAClB,WAAS,cAAc;AAEvB,WAAS,QAAQ;AAEjB,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":["import_internal"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,221 @@
1
+ // src/aihubmix-provider.ts
2
+ import {
3
+ OpenAIChatLanguageModel,
4
+ OpenAICompletionLanguageModel,
5
+ OpenAIEmbeddingModel,
6
+ OpenAIImageModel,
7
+ OpenAIResponsesLanguageModel,
8
+ OpenAITranscriptionModel,
9
+ OpenAISpeechModel
10
+ } from "@ai-sdk/openai/internal";
11
+ import {
12
+ AnthropicMessagesLanguageModel
13
+ } from "@ai-sdk/anthropic/internal";
14
+ import {
15
+ GoogleGenerativeAILanguageModel
16
+ } from "@ai-sdk/google/internal";
17
+ import { loadApiKey } from "@ai-sdk/provider-utils";
18
+
19
+ // src/aihubmix-tools.ts
20
+ import { z } from "zod";
21
+ var WebSearchPreviewParameters = z.object({});
22
+ function webSearchPreviewTool({
23
+ searchContextSize,
24
+ userLocation
25
+ } = {}) {
26
+ return {
27
+ type: "provider-defined",
28
+ id: "openai.web_search_preview",
29
+ args: {
30
+ searchContextSize,
31
+ userLocation
32
+ },
33
+ parameters: WebSearchPreviewParameters
34
+ };
35
+ }
36
+ var openaiTools = {
37
+ webSearchPreview: webSearchPreviewTool
38
+ };
39
+
40
+ // src/aihubmix-provider.ts
41
+ var AihubmixTranscriptionModel = class extends OpenAITranscriptionModel {
42
+ async doGenerate(options) {
43
+ if (options.mediaType) {
44
+ const mimeTypeMap = {
45
+ "audio/mpeg": "mp3",
46
+ "audio/mp3": "mp3",
47
+ "audio/wav": "wav",
48
+ "audio/flac": "flac",
49
+ "audio/m4a": "m4a",
50
+ "audio/mp4": "mp4",
51
+ "audio/ogg": "ogg",
52
+ "audio/webm": "webm",
53
+ "audio/oga": "oga",
54
+ "audio/mpga": "mpga"
55
+ };
56
+ const extension = mimeTypeMap[options.mediaType];
57
+ if (extension) {
58
+ const modifiedOptions = {
59
+ ...options,
60
+ mediaType: options.mediaType
61
+ };
62
+ const originalGetArgs = this.getArgs;
63
+ this.getArgs = function(args) {
64
+ const result = originalGetArgs.call(this, args);
65
+ if (result.formData) {
66
+ const fileEntry = result.formData.get("file");
67
+ if (fileEntry && typeof fileEntry === "object" && "name" in fileEntry) {
68
+ try {
69
+ const newFile = new globalThis.File([fileEntry], `audio.${extension}`, {
70
+ type: options.mediaType
71
+ });
72
+ result.formData.set("file", newFile);
73
+ } catch (error) {
74
+ if (fileEntry && typeof fileEntry === "object") {
75
+ fileEntry.name = `audio.${extension}`;
76
+ }
77
+ }
78
+ }
79
+ }
80
+ return result;
81
+ };
82
+ return super.doGenerate(modifiedOptions);
83
+ }
84
+ }
85
+ return super.doGenerate(options);
86
+ }
87
+ };
88
+ function createAihubmix(options = {}) {
89
+ const compatibility = options.compatibility ?? "compatible";
90
+ const getHeaders = () => ({
91
+ Authorization: `Bearer ${loadApiKey({
92
+ apiKey: options.apiKey,
93
+ environmentVariableName: "AIHUBMIX_API_KEY",
94
+ description: "Aihubmix"
95
+ })}`,
96
+ "APP-Code": "WHVL9885",
97
+ "Content-Type": "application/json"
98
+ });
99
+ const getTranscriptionHeaders = () => ({
100
+ Authorization: `Bearer ${loadApiKey({
101
+ apiKey: options.apiKey,
102
+ environmentVariableName: "AIHUBMIX_API_KEY",
103
+ description: "Aihubmix"
104
+ })}`,
105
+ "APP-Code": "WHVL9885"
106
+ });
107
+ const url = ({ path, modelId }) => {
108
+ const baseURL = "https://aihubmix.com/v1";
109
+ return `${baseURL}${path}`;
110
+ };
111
+ const createChatModel = (deploymentName, settings = {}) => {
112
+ const headers = getHeaders();
113
+ if (deploymentName.startsWith("claude-")) {
114
+ return new AnthropicMessagesLanguageModel(
115
+ deploymentName,
116
+ settings,
117
+ {
118
+ provider: "aihubmix.chat",
119
+ baseURL: url({ path: "", modelId: deploymentName }),
120
+ headers: {
121
+ ...headers,
122
+ "x-api-key": headers["Authorization"].split(" ")[1]
123
+ },
124
+ supportsImageUrls: true
125
+ }
126
+ );
127
+ }
128
+ if ((deploymentName.startsWith("gemini") || deploymentName.startsWith("imagen")) && !deploymentName.endsWith("-nothink") && !deploymentName.endsWith("-search")) {
129
+ return new GoogleGenerativeAILanguageModel(
130
+ deploymentName,
131
+ settings,
132
+ {
133
+ provider: "aihubmix.chat",
134
+ baseURL: "https://aihubmix.com/gemini/v1beta",
135
+ headers: {
136
+ ...headers,
137
+ "x-goog-api-key": headers["Authorization"].split(" ")[1]
138
+ },
139
+ generateId: () => `aihubmix-${Date.now()}`,
140
+ isSupportedUrl: () => true
141
+ }
142
+ );
143
+ }
144
+ return new OpenAIChatLanguageModel(deploymentName, settings, {
145
+ provider: "aihubmix.chat",
146
+ url,
147
+ headers: getHeaders,
148
+ compatibility,
149
+ fetch: options.fetch
150
+ });
151
+ };
152
+ const createCompletionModel = (modelId, settings = {}) => new OpenAICompletionLanguageModel(modelId, settings, {
153
+ provider: "aihubmix.completion",
154
+ url,
155
+ compatibility,
156
+ headers: getHeaders,
157
+ fetch: options.fetch
158
+ });
159
+ const createEmbeddingModel = (modelId, settings = {}) => {
160
+ return new OpenAIEmbeddingModel(modelId, settings, {
161
+ provider: "aihubmix.embeddings",
162
+ headers: getHeaders,
163
+ url,
164
+ fetch: options.fetch
165
+ });
166
+ };
167
+ const createResponsesModel = (modelId) => new OpenAIResponsesLanguageModel(modelId, {
168
+ provider: "aihubmix.responses",
169
+ url,
170
+ headers: getHeaders
171
+ });
172
+ const createImageModel = (modelId, settings = {}) => {
173
+ return new OpenAIImageModel(modelId, settings, {
174
+ provider: "aihubmix.image",
175
+ url,
176
+ headers: getHeaders,
177
+ fetch: options.fetch
178
+ });
179
+ };
180
+ const createTranscriptionModel = (modelId) => new AihubmixTranscriptionModel(modelId, {
181
+ provider: "aihubmix.transcription",
182
+ url,
183
+ headers: getTranscriptionHeaders,
184
+ fetch: options.fetch
185
+ });
186
+ const createSpeechModel = (modelId) => new OpenAISpeechModel(modelId, {
187
+ provider: "aihubmix.speech",
188
+ url,
189
+ headers: getHeaders,
190
+ fetch: options.fetch
191
+ });
192
+ const provider = function(deploymentId, settings) {
193
+ if (new.target) {
194
+ throw new Error(
195
+ "The Aihubmix model function cannot be called with the new keyword."
196
+ );
197
+ }
198
+ return createChatModel(deploymentId, settings);
199
+ };
200
+ provider.languageModel = createChatModel;
201
+ provider.chat = createChatModel;
202
+ provider.completion = createCompletionModel;
203
+ provider.responses = createResponsesModel;
204
+ provider.embedding = createEmbeddingModel;
205
+ provider.textEmbedding = createEmbeddingModel;
206
+ provider.textEmbeddingModel = createEmbeddingModel;
207
+ provider.image = createImageModel;
208
+ provider.imageModel = createImageModel;
209
+ provider.transcription = createTranscriptionModel;
210
+ provider.transcriptionModel = createTranscriptionModel;
211
+ provider.speech = createSpeechModel;
212
+ provider.speechModel = createSpeechModel;
213
+ provider.tools = openaiTools;
214
+ return provider;
215
+ }
216
+ var aihubmix = createAihubmix();
217
+ export {
218
+ aihubmix,
219
+ createAihubmix
220
+ };
221
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/aihubmix-provider.ts","../src/aihubmix-tools.ts"],"sourcesContent":["import {\n OpenAIChatLanguageModel,\n OpenAIChatSettings,\n OpenAICompletionLanguageModel,\n OpenAICompletionSettings,\n OpenAIEmbeddingModel,\n OpenAIEmbeddingSettings,\n OpenAIImageModel,\n OpenAIImageSettings,\n OpenAIResponsesLanguageModel,\n OpenAITranscriptionModel,\n OpenAISpeechModel,\n} from '@ai-sdk/openai/internal';\nimport {\n AnthropicMessagesLanguageModel,\n AnthropicMessagesSettings,\n} from '@ai-sdk/anthropic/internal';\nimport {\n InternalGoogleGenerativeAISettings,\n GoogleGenerativeAILanguageModel,\n} from '@ai-sdk/google/internal';\nimport {\n EmbeddingModelV1,\n LanguageModelV1,\n ProviderV1,\n ImageModelV1,\n TranscriptionModelV1,\n SpeechModelV1,\n TranscriptionModelV1CallOptions,\n} from '@ai-sdk/provider';\nimport { FetchFunction, loadApiKey } from '@ai-sdk/provider-utils';\nimport { openaiTools } from './aihubmix-tools';\n\nexport interface AihubmixProvider extends ProviderV1 {\n (deploymentId: string, settings?: OpenAIChatSettings): LanguageModelV1;\n\n languageModel(\n deploymentId: string,\n settings?: OpenAIChatSettings,\n ): LanguageModelV1;\n\n chat(deploymentId: string, settings?: OpenAIChatSettings): LanguageModelV1;\n\n responses(deploymentId: string): LanguageModelV1;\n\n completion(\n deploymentId: string,\n settings?: OpenAICompletionSettings,\n ): LanguageModelV1;\n\n embedding(\n deploymentId: string,\n settings?: OpenAIEmbeddingSettings,\n ): EmbeddingModelV1<string>;\n\n image(deploymentId: string, settings?: OpenAIImageSettings): ImageModelV1;\n\n imageModel(\n deploymentId: string,\n settings?: OpenAIImageSettings,\n ): ImageModelV1;\n\n textEmbedding(\n deploymentId: string,\n settings?: OpenAIEmbeddingSettings,\n ): EmbeddingModelV1<string>;\n\n textEmbeddingModel(\n deploymentId: string,\n settings?: OpenAIEmbeddingSettings,\n ): EmbeddingModelV1<string>;\n\n transcription(deploymentId: string): TranscriptionModelV1;\n\n speech(deploymentId: string): SpeechModelV1;\n\n speechModel(deploymentId: string): SpeechModelV1;\n\n tools: typeof openaiTools;\n}\n\nclass AihubmixTranscriptionModel extends OpenAITranscriptionModel {\n async doGenerate(options: TranscriptionModelV1CallOptions) {\n // 根据MIME类型设置正确的文件扩展名\n if (options.mediaType) {\n const mimeTypeMap: Record<string, string> = {\n 'audio/mpeg': 'mp3',\n 'audio/mp3': 'mp3',\n 'audio/wav': 'wav',\n 'audio/flac': 'flac',\n 'audio/m4a': 'm4a',\n 'audio/mp4': 'mp4',\n 'audio/ogg': 'ogg',\n 'audio/webm': 'webm',\n 'audio/oga': 'oga',\n 'audio/mpga': 'mpga',\n };\n \n const extension = mimeTypeMap[options.mediaType];\n if (extension) {\n // 修改options,确保文件名有正确的扩展名\n const modifiedOptions = {\n ...options,\n mediaType: options.mediaType,\n };\n \n // 重写getArgs方法来设置正确的文件名\n const originalGetArgs = (this as any).getArgs;\n (this as any).getArgs = function(args: any) {\n const result = originalGetArgs.call(this, args);\n if (result.formData) {\n // 找到file字段并修改文件名\n const fileEntry = result.formData.get('file');\n if (fileEntry && typeof fileEntry === 'object' && 'name' in fileEntry) {\n // 在 Node.js 环境中,我们可能需要创建一个新的文件对象\n // 或者直接修改现有的对象\n try {\n const newFile = new (globalThis as any).File([fileEntry], `audio.${extension}`, { \n type: options.mediaType \n });\n result.formData.set('file', newFile);\n } catch (error) {\n // 如果 File 构造函数不可用,尝试修改现有对象的名称\n if (fileEntry && typeof fileEntry === 'object') {\n (fileEntry as any).name = `audio.${extension}`;\n }\n }\n }\n }\n return result;\n };\n \n return super.doGenerate(modifiedOptions);\n }\n }\n \n return super.doGenerate(options);\n }\n}\n\nexport interface AihubmixProviderSettings {\n apiKey?: string;\n fetch?: FetchFunction;\n compatibility?: 'strict' | 'compatible';\n}\n\nexport function createAihubmix(\n options: AihubmixProviderSettings = {},\n): AihubmixProvider {\n const compatibility = options.compatibility ?? 'compatible';\n const getHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n 'Content-Type': 'application/json',\n });\n\n const getTranscriptionHeaders = () => ({\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'AIHUBMIX_API_KEY',\n description: 'Aihubmix',\n })}`,\n 'APP-Code': 'WHVL9885',\n });\n\n const url = ({ path, modelId }: { path: string; modelId: string }) => {\n const baseURL = 'https://aihubmix.com/v1';\n return `${baseURL}${path}`;\n };\n\n const createChatModel = (\n deploymentName: string,\n settings: OpenAIChatSettings = {},\n ) => {\n const headers = getHeaders();\n if (deploymentName.startsWith('claude-')) {\n return new AnthropicMessagesLanguageModel(\n deploymentName,\n settings as AnthropicMessagesSettings,\n {\n provider: 'aihubmix.chat',\n baseURL: url({ path: '', modelId: deploymentName }),\n headers: {\n ...headers,\n 'x-api-key': headers['Authorization'].split(' ')[1],\n },\n supportsImageUrls: true,\n },\n );\n }\n if (\n (deploymentName.startsWith('gemini') ||\n deploymentName.startsWith('imagen')) &&\n !deploymentName.endsWith('-nothink') &&\n !deploymentName.endsWith('-search')\n ) {\n return new GoogleGenerativeAILanguageModel(\n deploymentName,\n settings as InternalGoogleGenerativeAISettings,\n {\n provider: 'aihubmix.chat',\n baseURL: 'https://aihubmix.com/gemini/v1beta',\n headers: {\n ...headers,\n 'x-goog-api-key': headers['Authorization'].split(' ')[1],\n },\n generateId: () => `aihubmix-${Date.now()}`,\n isSupportedUrl: () => true,\n },\n );\n }\n\n return new OpenAIChatLanguageModel(deploymentName, settings, {\n provider: 'aihubmix.chat',\n url,\n headers: getHeaders,\n compatibility,\n fetch: options.fetch,\n });\n };\n\n const createCompletionModel = (\n modelId: string,\n settings: OpenAICompletionSettings = {},\n ) =>\n new OpenAICompletionLanguageModel(modelId, settings, {\n provider: 'aihubmix.completion',\n url,\n compatibility,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createEmbeddingModel = (\n modelId: string,\n settings: OpenAIEmbeddingSettings = {},\n ) => {\n return new OpenAIEmbeddingModel(modelId, settings, {\n provider: 'aihubmix.embeddings',\n headers: getHeaders,\n url,\n fetch: options.fetch,\n });\n };\n\n const createResponsesModel = (modelId: string) =>\n new OpenAIResponsesLanguageModel(modelId, {\n provider: 'aihubmix.responses',\n url,\n headers: getHeaders,\n });\n\n const createImageModel = (\n modelId: string,\n settings: OpenAIImageSettings = {},\n ) => {\n return new OpenAIImageModel(modelId, settings, {\n provider: 'aihubmix.image',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n };\n\n const createTranscriptionModel = (modelId: string) =>\n new AihubmixTranscriptionModel(modelId, {\n provider: 'aihubmix.transcription',\n url,\n headers: getTranscriptionHeaders,\n fetch: options.fetch,\n });\n const createSpeechModel = (modelId: string) =>\n new OpenAISpeechModel(modelId, {\n provider: 'aihubmix.speech',\n url,\n headers: getHeaders,\n fetch: options.fetch,\n });\n const provider = function (\n deploymentId: string,\n settings?: OpenAIChatSettings | OpenAICompletionSettings,\n ) {\n if (new.target) {\n throw new Error(\n 'The Aihubmix model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(deploymentId, settings as OpenAIChatSettings);\n };\n\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.completion = createCompletionModel;\n provider.responses = createResponsesModel;\n provider.embedding = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n\n provider.tools = openaiTools;\n\n return provider as AihubmixProvider;\n}\n\nexport const aihubmix = createAihubmix();\n","import { z } from 'zod';\n\nconst WebSearchPreviewParameters = z.object({});\n\nfunction webSearchPreviewTool({\n searchContextSize,\n userLocation,\n}: {\n searchContextSize?: 'low' | 'medium' | 'high';\n userLocation?: {\n type?: 'approximate';\n city?: string;\n region?: string;\n country?: string;\n timezone?: string;\n };\n} = {}): {\n type: 'provider-defined';\n id: 'openai.web_search_preview';\n args: {};\n parameters: typeof WebSearchPreviewParameters;\n} {\n return {\n type: 'provider-defined',\n id: 'openai.web_search_preview',\n args: {\n searchContextSize,\n userLocation,\n },\n parameters: WebSearchPreviewParameters,\n };\n}\n\nexport const openaiTools = {\n webSearchPreview: webSearchPreviewTool,\n};\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,OACK;AAUP,SAAwB,kBAAkB;;;AC9B1C,SAAS,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T,OAAO,QAAQ;AAAA,EACjB,CAAC;AACH,QAAM,oBAAoB,CAAC,YACzB,IAAI,kBAAkB,SAAS;AAAA,IAC7B,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB,CAAC;AACH,QAAM,WAAW,SACf,cACA,UACA;AACA,QAAI,YAAY;AACd,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,WAAO,gBAAgB,cAAc,QAA8B;AAAA,EACrE;AAEA,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAChB,WAAS,aAAa;AACtB,WAAS,YAAY;AACrB,WAAS,YAAY;AACrB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,WAAS,QAAQ;AACjB,WAAS,aAAa;AAEtB,WAAS,gBAAgB;AACzB,WAAS,qBAAqB;AAE9B,WAAS,SAAS;AAClB,WAAS,cAAc;AAEvB,WAAS,QAAQ;AAEjB,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":[]}
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@aihubmix/ai-sdk-provider",
3
+ "version": "0.0.1",
4
+ "license": "Apache-2.0",
5
+ "sideEffects": false,
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist/**/*",
11
+ "CHANGELOG.md"
12
+ ],
13
+ "exports": {
14
+ "./package.json": "./package.json",
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.mjs",
18
+ "require": "./dist/index.js"
19
+ }
20
+ },
21
+ "dependencies": {
22
+ "@ai-sdk/anthropic": "1.2.12",
23
+ "@ai-sdk/google": "1.2.19",
24
+ "@ai-sdk/openai": "1.3.22",
25
+ "@ai-sdk/provider": "1.1.3",
26
+ "@ai-sdk/provider-utils": "2.2.8"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "20.17.24",
30
+ "tsup": "^8",
31
+ "typescript": "5.6.3",
32
+ "zod": "3.23.8",
33
+ "vitest": "^2.0.0",
34
+ "jsdom": "^24.0.0",
35
+ "@edge-runtime/vm": "^2.0.0"
36
+ },
37
+ "peerDependencies": {
38
+ "zod": "^3.0.0"
39
+ },
40
+ "engines": {
41
+ "node": ">=18"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "homepage": "https://aihubmix.com",
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/inferera/aihubmix.git"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/inferera/aihubmix/issues"
53
+ },
54
+ "keywords": [
55
+ "ai",
56
+ "aihubmix",
57
+ "ai-sdk-provider",
58
+ "ai-sdk"
59
+ ],
60
+ "scripts": {
61
+ "build": "tsup",
62
+ "build:watch": "tsup --watch",
63
+ "clean": "rm -rf dist",
64
+ "lint": "eslint \"./**/*.ts*\"",
65
+ "type-check": "tsc --noEmit",
66
+ "prettier-check": "prettier --check \"./**/*.ts*\" --write",
67
+ "test": "pnpm test:node && pnpm test:edge",
68
+ "test:edge": "vitest --config vitest.edge.config.js --run",
69
+ "test:node": "vitest --config vitest.node.config.js --run",
70
+ "test:node:watch": "vitest --config vitest.node.config.js"
71
+ }
72
+ }