@ai-sdk/gmicloud 3.0.30 → 3.0.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,15 @@
1
1
  # @ai-sdk/gmicloud
2
2
 
3
+ ## 3.0.31
4
+
5
+ ### Patch Changes
6
+
7
+ - ede5b89: chore: migrate package builds from tsup to tsdown
8
+ - Updated dependencies [ede5b89]
9
+ - @ai-sdk/openai-compatible@3.0.60
10
+ - @ai-sdk/provider@4.0.20
11
+ - @ai-sdk/provider-utils@5.0.52
12
+
3
13
  ## 3.0.30
4
14
 
5
15
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,62 +1,67 @@
1
- import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
2
- import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { z } from 'zod/v4';
4
-
1
+ import { LanguageModelV4, ProviderV4 } from "@ai-sdk/provider";
2
+ import { FetchFunction } from "@ai-sdk/provider-utils";
3
+ import "@ai-sdk/openai-compatible";
4
+ import { z } from "zod/v4";
5
+ //#region src/gmicloud-chat-options.d.ts
5
6
  type GmicloudChatModelId = 'deepseek-ai/DeepSeek-V4-Flash-0731' | 'Qwen/Qwen3.8-Max' | 'moonshotai/kimi-k3' | 'zai-org/GLM-5.2-FP8' | 'MiniMaxAI/MiniMax-M3' | (string & {});
6
-
7
+ //#endregion
8
+ //#region src/gmicloud-provider.d.ts
7
9
  interface GmicloudProviderSettings {
8
- /**
9
- * GMI Cloud API key. Defaults to the `GMI_CLOUD_APIKEY` environment
10
- * variable (matching GMI's own SDK package).
11
- */
12
- apiKey?: string;
13
- /**
14
- * Base URL for the API calls. Defaults to
15
- * `https://api.gmi-serving.com/v1`.
16
- */
17
- baseURL?: string;
18
- /**
19
- * Custom headers to include in the requests.
20
- */
21
- headers?: Record<string, string>;
22
- /**
23
- * Custom fetch implementation. You can use it as a middleware to intercept
24
- * requests, or to provide a custom fetch implementation for e.g. testing.
25
- */
26
- fetch?: FetchFunction;
10
+ /**
11
+ * GMI Cloud API key. Defaults to the `GMI_CLOUD_APIKEY` environment
12
+ * variable (matching GMI's own SDK package).
13
+ */
14
+ apiKey?: string;
15
+ /**
16
+ * Base URL for the API calls. Defaults to
17
+ * `https://api.gmi-serving.com/v1`.
18
+ */
19
+ baseURL?: string;
20
+ /**
21
+ * Custom headers to include in the requests.
22
+ */
23
+ headers?: Record<string, string>;
24
+ /**
25
+ * Custom fetch implementation. You can use it as a middleware to intercept
26
+ * requests, or to provide a custom fetch implementation for e.g. testing.
27
+ */
28
+ fetch?: FetchFunction;
27
29
  }
28
30
  interface GmicloudProvider extends ProviderV4 {
29
- /**
30
- * Creates a GMI Cloud model for text generation.
31
- */
32
- (modelId: GmicloudChatModelId): LanguageModelV4;
33
- /**
34
- * Creates a GMI Cloud model for text generation.
35
- */
36
- languageModel(modelId: GmicloudChatModelId): LanguageModelV4;
37
- /**
38
- * Creates a GMI Cloud chat model for text generation.
39
- */
40
- chat(modelId: GmicloudChatModelId): LanguageModelV4;
41
- /**
42
- * @deprecated Use `embeddingModel` instead.
43
- */
44
- textEmbeddingModel(modelId: string): never;
31
+ /**
32
+ * Creates a GMI Cloud model for text generation.
33
+ */
34
+ (modelId: GmicloudChatModelId): LanguageModelV4;
35
+ /**
36
+ * Creates a GMI Cloud model for text generation.
37
+ */
38
+ languageModel(modelId: GmicloudChatModelId): LanguageModelV4;
39
+ /**
40
+ * Creates a GMI Cloud chat model for text generation.
41
+ */
42
+ chat(modelId: GmicloudChatModelId): LanguageModelV4;
43
+ /**
44
+ * @deprecated Use `embeddingModel` instead.
45
+ */
46
+ textEmbeddingModel(modelId: string): never;
45
47
  }
46
- declare function createGmicloud(options?: GmicloudProviderSettings): GmicloudProvider;
47
- declare const gmicloud: GmicloudProvider;
48
-
48
+ export declare function createGmicloud(options?: GmicloudProviderSettings): GmicloudProvider;
49
+ export declare const gmicloud: GmicloudProvider;
50
+ //#endregion
51
+ //#region src/gmicloud-error.d.ts
49
52
  declare const gmicloudErrorDataSchema: z.ZodObject<{
50
- error: z.ZodObject<{
51
- message: z.ZodString;
52
- type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
- param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
54
- code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
55
- details: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
- }, z.core.$strip>;
53
+ error: z.ZodObject<{
54
+ message: z.ZodString;
55
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
+ param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
57
+ code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
58
+ details: z.ZodOptional<z.ZodNullable<z.ZodString>>;
59
+ }, z.core.$strip>;
57
60
  }, z.core.$strip>;
58
61
  type GmicloudErrorData = z.infer<typeof gmicloudErrorDataSchema>;
59
-
60
- declare const VERSION: string;
61
-
62
- export { type GmicloudErrorData, type GmicloudProvider, type GmicloudProviderSettings, VERSION, createGmicloud, gmicloud };
62
+ //#endregion
63
+ //#region src/version.d.ts
64
+ export declare const VERSION: string;
65
+ //#endregion
66
+ export type { GmicloudErrorData, GmicloudProvider, GmicloudProviderSettings };
67
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/gmicloud-chat-options.ts","../src/gmicloud-provider.ts","../src/gmicloud-error.ts","../src/version.ts"],"mappings":";;;;;KACY;;;UCeK;;;;;EAKf;;;;;EAKA;;;;EAIA,UAAU;;;;;EAKV,QAAQ;;UAGO,yBAAyB;;;;GAIvC,SAAS,sBAAsB;;;;EAKhC,cAAc,SAAS,sBAAsB;;;;EAK7C,KAAK,SAAS,sBAAsB;;;;EAKpC,mBAAmB;;wBAGL,eACd,UAAS,2BACR;qBA8CU,UAAQ;;;cCxGR,yBAAuB,EAAA;;;;;;;;GAQlC,EAAA,KAAA;KAEU,oBAAoB,EAAE,aAAa;;;qBCZlC"}
package/dist/index.js CHANGED
@@ -1,108 +1,95 @@
1
- // src/gmicloud-provider.ts
2
- import {
3
- NoSuchModelError
4
- } from "@ai-sdk/provider";
5
- import {
6
- loadApiKey,
7
- withoutTrailingSlash,
8
- withUserAgentSuffix
9
- } from "@ai-sdk/provider-utils";
10
-
11
- // src/gmicloud-chat-language-model.ts
1
+ import { NoSuchModelError } from "@ai-sdk/provider";
2
+ import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, loadApiKey, secureJsonParse, serializeModelOptions, withUserAgentSuffix, withoutTrailingSlash } from "@ai-sdk/provider-utils";
12
3
  import { OpenAICompatibleChatLanguageModel } from "@ai-sdk/openai-compatible";
13
- import {
14
- serializeModelOptions,
15
- WORKFLOW_DESERIALIZE,
16
- WORKFLOW_SERIALIZE
17
- } from "@ai-sdk/provider-utils";
18
- var GmicloudChatLanguageModel = class _GmicloudChatLanguageModel extends OpenAICompatibleChatLanguageModel {
19
- static [WORKFLOW_SERIALIZE](model) {
20
- return serializeModelOptions({
21
- modelId: model.modelId,
22
- config: model.config
23
- });
24
- }
25
- static [WORKFLOW_DESERIALIZE](options) {
26
- return new _GmicloudChatLanguageModel(options.modelId, options.config);
27
- }
28
- };
29
-
30
- // src/gmicloud-error.ts
31
- import { secureJsonParse } from "@ai-sdk/provider-utils";
32
4
  import { z } from "zod/v4";
33
- var gmicloudErrorDataSchema = z.object({
34
- error: z.object({
35
- message: z.string(),
36
- type: z.string().nullish(),
37
- param: z.any().nullish(),
38
- code: z.union([z.string(), z.number()]).nullish(),
39
- details: z.string().nullish()
40
- })
41
- });
5
+ //#region src/gmicloud-chat-language-model.ts
6
+ /**
7
+ * GMI Cloud chat completions over the OpenAI-compatible protocol. The only
8
+ * customization is the error structure (see ./gmicloud-error.ts): GMI's edge
9
+ * nests the backend engine's diagnostic in `error.details`, which the default
10
+ * OpenAI-compatible error handling drops.
11
+ */
12
+ var GmicloudChatLanguageModel = class GmicloudChatLanguageModel extends OpenAICompatibleChatLanguageModel {
13
+ static [WORKFLOW_SERIALIZE](model) {
14
+ return serializeModelOptions({
15
+ modelId: model.modelId,
16
+ config: model.config
17
+ });
18
+ }
19
+ static [WORKFLOW_DESERIALIZE](options) {
20
+ return new GmicloudChatLanguageModel(options.modelId, options.config);
21
+ }
22
+ };
23
+ //#endregion
24
+ //#region src/gmicloud-error.ts
25
+ const gmicloudErrorDataSchema = z.object({ error: z.object({
26
+ message: z.string(),
27
+ type: z.string().nullish(),
28
+ param: z.any().nullish(),
29
+ code: z.union([z.string(), z.number()]).nullish(),
30
+ details: z.string().nullish()
31
+ }) });
42
32
  function unwrapDetailsMessage(details) {
43
- if (details == null || details === "") {
44
- return void 0;
45
- }
46
- let parsed;
47
- try {
48
- parsed = secureJsonParse(details);
49
- } catch {
50
- return void 0;
51
- }
52
- const message = parsed?.error?.message;
53
- return typeof message === "string" && message.trim() !== "" ? message : void 0;
33
+ if (details == null || details === "") return;
34
+ let parsed;
35
+ try {
36
+ parsed = secureJsonParse(details);
37
+ } catch {
38
+ return;
39
+ }
40
+ const message = parsed?.error?.message;
41
+ return typeof message === "string" && message.trim() !== "" ? message : void 0;
54
42
  }
55
- var gmicloudErrorStructure = {
56
- errorSchema: gmicloudErrorDataSchema,
57
- errorToMessage: (data) => unwrapDetailsMessage(data.error.details) ?? data.error.message
43
+ const gmicloudErrorStructure = {
44
+ errorSchema: gmicloudErrorDataSchema,
45
+ errorToMessage: (data) => unwrapDetailsMessage(data.error.details) ?? data.error.message
58
46
  };
59
-
60
- // src/version.ts
61
- var VERSION = true ? "3.0.30" : "0.0.0-test";
62
-
63
- // src/gmicloud-provider.ts
47
+ //#endregion
48
+ //#region src/version.ts
49
+ const VERSION = "3.0.31";
50
+ //#endregion
51
+ //#region src/gmicloud-provider.ts
64
52
  function createGmicloud(options = {}) {
65
- const baseURL = withoutTrailingSlash(
66
- options.baseURL ?? "https://api.gmi-serving.com/v1"
67
- );
68
- const getHeaders = () => withUserAgentSuffix(
69
- {
70
- Authorization: `Bearer ${loadApiKey({
71
- apiKey: options.apiKey,
72
- environmentVariableName: "GMI_CLOUD_APIKEY",
73
- description: "GMI Cloud API key"
74
- })}`,
75
- ...options.headers
76
- },
77
- `ai-sdk-gmicloud/${VERSION}`
78
- );
79
- const createLanguageModel = (modelId) => {
80
- return new GmicloudChatLanguageModel(modelId, {
81
- provider: `gmicloud.chat`,
82
- url: ({ path }) => `${baseURL}${path}`,
83
- headers: getHeaders,
84
- fetch: options.fetch,
85
- errorStructure: gmicloudErrorStructure,
86
- includeUsage: true
87
- });
88
- };
89
- const provider = (modelId) => createLanguageModel(modelId);
90
- provider.specificationVersion = "v4";
91
- provider.languageModel = createLanguageModel;
92
- provider.chat = createLanguageModel;
93
- provider.embeddingModel = (modelId) => {
94
- throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
95
- };
96
- provider.textEmbeddingModel = provider.embeddingModel;
97
- provider.imageModel = (modelId) => {
98
- throw new NoSuchModelError({ modelId, modelType: "imageModel" });
99
- };
100
- return provider;
53
+ const baseURL = withoutTrailingSlash(options.baseURL ?? "https://api.gmi-serving.com/v1");
54
+ const getHeaders = () => withUserAgentSuffix({
55
+ Authorization: `Bearer ${loadApiKey({
56
+ apiKey: options.apiKey,
57
+ environmentVariableName: "GMI_CLOUD_APIKEY",
58
+ description: "GMI Cloud API key"
59
+ })}`,
60
+ ...options.headers
61
+ }, `ai-sdk-gmicloud/${VERSION}`);
62
+ const createLanguageModel = (modelId) => {
63
+ return new GmicloudChatLanguageModel(modelId, {
64
+ provider: `gmicloud.chat`,
65
+ url: ({ path }) => `${baseURL}${path}`,
66
+ headers: getHeaders,
67
+ fetch: options.fetch,
68
+ errorStructure: gmicloudErrorStructure,
69
+ includeUsage: true
70
+ });
71
+ };
72
+ const provider = (modelId) => createLanguageModel(modelId);
73
+ provider.specificationVersion = "v4";
74
+ provider.languageModel = createLanguageModel;
75
+ provider.chat = createLanguageModel;
76
+ provider.embeddingModel = (modelId) => {
77
+ throw new NoSuchModelError({
78
+ modelId,
79
+ modelType: "embeddingModel"
80
+ });
81
+ };
82
+ provider.textEmbeddingModel = provider.embeddingModel;
83
+ provider.imageModel = (modelId) => {
84
+ throw new NoSuchModelError({
85
+ modelId,
86
+ modelType: "imageModel"
87
+ });
88
+ };
89
+ return provider;
101
90
  }
102
- var gmicloud = createGmicloud();
103
- export {
104
- VERSION,
105
- createGmicloud,
106
- gmicloud
107
- };
91
+ const gmicloud = createGmicloud();
92
+ //#endregion
93
+ export { VERSION, createGmicloud, gmicloud };
94
+
108
95
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/gmicloud-provider.ts","../src/gmicloud-chat-language-model.ts","../src/gmicloud-error.ts","../src/version.ts"],"sourcesContent":["import {\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { GmicloudChatLanguageModel } from './gmicloud-chat-language-model';\nimport type { GmicloudChatModelId } from './gmicloud-chat-options';\nimport { gmicloudErrorStructure } from './gmicloud-error';\nimport { VERSION } from './version';\n\nexport interface GmicloudProviderSettings {\n /**\n * GMI Cloud API key. Defaults to the `GMI_CLOUD_APIKEY` environment\n * variable (matching GMI's own SDK package).\n */\n apiKey?: string;\n /**\n * Base URL for the API calls. Defaults to\n * `https://api.gmi-serving.com/v1`.\n */\n baseURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept\n * requests, or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface GmicloudProvider extends ProviderV4 {\n /**\n * Creates a GMI Cloud model for text generation.\n */\n (modelId: GmicloudChatModelId): LanguageModelV4;\n\n /**\n * Creates a GMI Cloud model for text generation.\n */\n languageModel(modelId: GmicloudChatModelId): LanguageModelV4;\n\n /**\n * Creates a GMI Cloud chat model for text generation.\n */\n chat(modelId: GmicloudChatModelId): LanguageModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport function createGmicloud(\n options: GmicloudProviderSettings = {},\n): GmicloudProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.gmi-serving.com/v1',\n );\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'GMI_CLOUD_APIKEY',\n description: 'GMI Cloud API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk-gmicloud/${VERSION}`,\n );\n\n const createLanguageModel = (modelId: GmicloudChatModelId) => {\n return new GmicloudChatLanguageModel(modelId, {\n provider: `gmicloud.chat`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n errorStructure: gmicloudErrorStructure,\n includeUsage: true,\n });\n };\n\n const provider = (modelId: GmicloudChatModelId) =>\n createLanguageModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const gmicloud = createGmicloud();\n","import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport type { LanguageModelV4 } from '@ai-sdk/provider';\nimport {\n serializeModelOptions,\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE,\n} from '@ai-sdk/provider-utils';\nimport type { GmicloudChatModelId } from './gmicloud-chat-language-model-options';\n\ntype GmicloudChatConfig = ConstructorParameters<\n typeof OpenAICompatibleChatLanguageModel\n>[1];\n\n/**\n * GMI Cloud chat completions over the OpenAI-compatible protocol. The only\n * customization is the error structure (see ./gmicloud-error.ts): GMI's edge\n * nests the backend engine's diagnostic in `error.details`, which the default\n * OpenAI-compatible error handling drops.\n */\nexport class GmicloudChatLanguageModel\n extends OpenAICompatibleChatLanguageModel\n implements LanguageModelV4\n{\n static [WORKFLOW_SERIALIZE](model: GmicloudChatLanguageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: GmicloudChatModelId;\n config: GmicloudChatConfig;\n }) {\n return new GmicloudChatLanguageModel(options.modelId, options.config);\n }\n}\n","import type { ProviderErrorStructure } from '@ai-sdk/openai-compatible';\nimport { secureJsonParse } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const gmicloudErrorDataSchema = z.object({\n error: z.object({\n message: z.string(),\n type: z.string().nullish(),\n param: z.any().nullish(),\n code: z.union([z.string(), z.number()]).nullish(),\n details: z.string().nullish(),\n }),\n});\n\nexport type GmicloudErrorData = z.infer<typeof gmicloudErrorDataSchema>;\n\nfunction unwrapDetailsMessage(details: string | null | undefined) {\n if (details == null || details === '') {\n return undefined;\n }\n let parsed: unknown;\n try {\n parsed = secureJsonParse(details);\n } catch {\n return undefined;\n }\n const message = (parsed as { error?: { message?: unknown } })?.error?.message;\n return typeof message === 'string' && message.trim() !== ''\n ? message\n : undefined;\n}\n\nexport const gmicloudErrorStructure: ProviderErrorStructure<GmicloudErrorData> =\n {\n errorSchema: gmicloudErrorDataSchema,\n errorToMessage: data =>\n unwrapDetailsMessage(data.error.details) ?? 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":";AAAA;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACVP,SAAS,yCAAyC;AAElD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAaA,IAAM,4BAAN,MAAM,mCACH,kCAEV;AAAA,EACE,QAAQ,kBAAkB,EAAE,OAAkC;AAC5D,WAAO,sBAAsB;AAAA,MAC3B,SAAS,MAAM;AAAA,MACf,QAAQ,MAAM;AAAA,IAChB,CAAC;AAAA,EACH;AAAA,EAEA,QAAQ,oBAAoB,EAAE,SAG3B;AACD,WAAO,IAAI,2BAA0B,QAAQ,SAAS,QAAQ,MAAM;AAAA,EACtE;AACF;;;ACnCA,SAAS,uBAAuB;AAChC,SAAS,SAAS;AAEX,IAAM,0BAA0B,EAAE,OAAO;AAAA,EAC9C,OAAO,EAAE,OAAO;AAAA,IACd,SAAS,EAAE,OAAO;AAAA,IAClB,MAAM,EAAE,OAAO,EAAE,QAAQ;AAAA,IACzB,OAAO,EAAE,IAAI,EAAE,QAAQ;AAAA,IACvB,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,EAAE,QAAQ;AAAA,IAChD,SAAS,EAAE,OAAO,EAAE,QAAQ;AAAA,EAC9B,CAAC;AACH,CAAC;AAID,SAAS,qBAAqB,SAAoC;AAChE,MAAI,WAAW,QAAQ,YAAY,IAAI;AACrC,WAAO;AAAA,EACT;AACA,MAAI;AACJ,MAAI;AACF,aAAS,gBAAgB,OAAO;AAAA,EAClC,QAAQ;AACN,WAAO;AAAA,EACT;AACA,QAAM,UAAW,QAA8C,OAAO;AACtE,SAAO,OAAO,YAAY,YAAY,QAAQ,KAAK,MAAM,KACrD,UACA;AACN;AAEO,IAAM,yBACX;AAAA,EACE,aAAa;AAAA,EACb,gBAAgB,UACd,qBAAqB,KAAK,MAAM,OAAO,KAAK,KAAK,MAAM;AAC3D;;;ACnCK,IAAM,UACX,OACI,WACA;;;AHuDC,SAAS,eACd,UAAoC,CAAC,GACnB;AAClB,QAAM,UAAU;AAAA,IACd,QAAQ,WAAW;AAAA,EACrB;AACA,QAAM,aAAa,MACjB;AAAA,IACE;AAAA,MACE,eAAe,UAAU,WAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,mBAAmB,OAAO;AAAA,EAC5B;AAEF,QAAM,sBAAsB,CAAC,YAAiC;AAC5D,WAAO,IAAI,0BAA0B,SAAS;AAAA,MAC5C,UAAU;AAAA,MACV,KAAK,CAAC,EAAE,KAAK,MAAM,GAAG,OAAO,GAAG,IAAI;AAAA,MACpC,SAAS;AAAA,MACT,OAAO,QAAQ;AAAA,MACf,gBAAgB;AAAA,MAChB,cAAc;AAAA,IAChB,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,CAAC,YAChB,oBAAoB,OAAO;AAE7B,WAAS,uBAAuB;AAChC,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAEhB,WAAS,iBAAiB,CAAC,YAAoB;AAC7C,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,iBAAiB,CAAC;AAAA,EACrE;AACA,WAAS,qBAAqB,SAAS;AACvC,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/gmicloud-chat-language-model.ts","../src/gmicloud-error.ts","../src/version.ts","../src/gmicloud-provider.ts"],"sourcesContent":["import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport type { LanguageModelV4 } from '@ai-sdk/provider';\nimport {\n serializeModelOptions,\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE,\n} from '@ai-sdk/provider-utils';\nimport type { GmicloudChatModelId } from './gmicloud-chat-language-model-options';\n\ntype GmicloudChatConfig = ConstructorParameters<\n typeof OpenAICompatibleChatLanguageModel\n>[1];\n\n/**\n * GMI Cloud chat completions over the OpenAI-compatible protocol. The only\n * customization is the error structure (see ./gmicloud-error.ts): GMI's edge\n * nests the backend engine's diagnostic in `error.details`, which the default\n * OpenAI-compatible error handling drops.\n */\nexport class GmicloudChatLanguageModel\n extends OpenAICompatibleChatLanguageModel\n implements LanguageModelV4\n{\n static [WORKFLOW_SERIALIZE](model: GmicloudChatLanguageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: GmicloudChatModelId;\n config: GmicloudChatConfig;\n }) {\n return new GmicloudChatLanguageModel(options.modelId, options.config);\n }\n}\n","import type { ProviderErrorStructure } from '@ai-sdk/openai-compatible';\nimport { secureJsonParse } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const gmicloudErrorDataSchema = z.object({\n error: z.object({\n message: z.string(),\n type: z.string().nullish(),\n param: z.any().nullish(),\n code: z.union([z.string(), z.number()]).nullish(),\n details: z.string().nullish(),\n }),\n});\n\nexport type GmicloudErrorData = z.infer<typeof gmicloudErrorDataSchema>;\n\nfunction unwrapDetailsMessage(details: string | null | undefined) {\n if (details == null || details === '') {\n return undefined;\n }\n let parsed: unknown;\n try {\n parsed = secureJsonParse(details);\n } catch {\n return undefined;\n }\n const message = (parsed as { error?: { message?: unknown } })?.error?.message;\n return typeof message === 'string' && message.trim() !== ''\n ? message\n : undefined;\n}\n\nexport const gmicloudErrorStructure: ProviderErrorStructure<GmicloudErrorData> =\n {\n errorSchema: gmicloudErrorDataSchema,\n errorToMessage: data =>\n unwrapDetailsMessage(data.error.details) ?? 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","import {\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { GmicloudChatLanguageModel } from './gmicloud-chat-language-model';\nimport type { GmicloudChatModelId } from './gmicloud-chat-options';\nimport { gmicloudErrorStructure } from './gmicloud-error';\nimport { VERSION } from './version';\n\nexport interface GmicloudProviderSettings {\n /**\n * GMI Cloud API key. Defaults to the `GMI_CLOUD_APIKEY` environment\n * variable (matching GMI's own SDK package).\n */\n apiKey?: string;\n /**\n * Base URL for the API calls. Defaults to\n * `https://api.gmi-serving.com/v1`.\n */\n baseURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept\n * requests, or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface GmicloudProvider extends ProviderV4 {\n /**\n * Creates a GMI Cloud model for text generation.\n */\n (modelId: GmicloudChatModelId): LanguageModelV4;\n\n /**\n * Creates a GMI Cloud model for text generation.\n */\n languageModel(modelId: GmicloudChatModelId): LanguageModelV4;\n\n /**\n * Creates a GMI Cloud chat model for text generation.\n */\n chat(modelId: GmicloudChatModelId): LanguageModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport function createGmicloud(\n options: GmicloudProviderSettings = {},\n): GmicloudProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.gmi-serving.com/v1',\n );\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'GMI_CLOUD_APIKEY',\n description: 'GMI Cloud API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk-gmicloud/${VERSION}`,\n );\n\n const createLanguageModel = (modelId: GmicloudChatModelId) => {\n return new GmicloudChatLanguageModel(modelId, {\n provider: `gmicloud.chat`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n errorStructure: gmicloudErrorStructure,\n includeUsage: true,\n });\n };\n\n const provider = (modelId: GmicloudChatModelId) =>\n createLanguageModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const gmicloud = createGmicloud();\n"],"mappings":";;;;;;;;;;;AAmBA,IAAa,4BAAb,MAAa,kCACH,kCAEV;CACE,QAAQ,oBAAoB,OAAkC;EAC5D,OAAO,sBAAsB;GAC3B,SAAS,MAAM;GACf,QAAQ,MAAM;EAChB,CAAC;CACH;CAEA,QAAQ,sBAAsB,SAG3B;EACD,OAAO,IAAI,0BAA0B,QAAQ,SAAS,QAAQ,MAAM;CACtE;AACF;;;AChCA,MAAa,0BAA0B,EAAE,OAAO,EAC9C,OAAO,EAAE,OAAO;CACd,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ;CACzB,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ;CACvB,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ;CAChD,SAAS,EAAE,OAAO,CAAC,CAAC,QAAQ;AAC9B,CAAC,EACH,CAAC;AAID,SAAS,qBAAqB,SAAoC;CAChE,IAAI,WAAW,QAAQ,YAAY,IACjC;CAEF,IAAI;CACJ,IAAI;EACF,SAAS,gBAAgB,OAAO;CAClC,QAAQ;EACN;CACF;CACA,MAAM,UAAW,QAA8C,OAAO;CACtE,OAAO,OAAO,YAAY,YAAY,QAAQ,KAAK,MAAM,KACrD,UACA,KAAA;AACN;AAEA,MAAa,yBACX;CACE,aAAa;CACb,iBAAgB,SACd,qBAAqB,KAAK,MAAM,OAAO,KAAK,KAAK,MAAM;AAC3D;;;ACnCF,MAAa,UAAA;;;AC0Db,SAAgB,eACd,UAAoC,CAAC,GACnB;CAClB,MAAM,UAAU,qBACd,QAAQ,WAAW,gCACrB;CACA,MAAM,mBACJ,oBACE;EACE,eAAe,UAAU,WAAW;GAClC,QAAQ,QAAQ;GAChB,yBAAyB;GACzB,aAAa;EACf,CAAC;EACD,GAAG,QAAQ;CACb,GACA,mBAAmB,SACrB;CAEF,MAAM,uBAAuB,YAAiC;EAC5D,OAAO,IAAI,0BAA0B,SAAS;GAC5C,UAAU;GACV,MAAM,EAAE,WAAW,GAAG,UAAU;GAChC,SAAS;GACT,OAAO,QAAQ;GACf,gBAAgB;GAChB,cAAc;EAChB,CAAC;CACH;CAEA,MAAM,YAAY,YAChB,oBAAoB,OAAO;CAE7B,SAAS,uBAAuB;CAChC,SAAS,gBAAgB;CACzB,SAAS,OAAO;CAEhB,SAAS,kBAAkB,YAAoB;EAC7C,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAiB,CAAC;CACrE;CACA,SAAS,qBAAqB,SAAS;CACvC,SAAS,cAAc,YAAoB;EACzC,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAa,CAAC;CACjE;CAEA,OAAO;AACT;AAEA,MAAa,WAAW,eAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/gmicloud",
3
- "version": "3.0.30",
3
+ "version": "3.0.31",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -29,14 +29,14 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/openai-compatible": "3.0.59",
33
- "@ai-sdk/provider": "4.0.19",
34
- "@ai-sdk/provider-utils": "5.0.51"
32
+ "@ai-sdk/openai-compatible": "3.0.60",
33
+ "@ai-sdk/provider": "4.0.20",
34
+ "@ai-sdk/provider-utils": "5.0.52"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "22.19.19",
38
38
  "@vercel/ai-tsconfig": "0.0.0",
39
- "tsup": "^8.5.1",
39
+ "tsdown": "^0.23.0",
40
40
  "typescript": "5.8.3",
41
41
  "zod": "3.25.76"
42
42
  },
@@ -64,9 +64,9 @@
64
64
  ],
65
65
  "description": "The **GMI Cloud provider** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for [GMI Cloud](https://www.gmicloud.ai), offering GPU inference for open-weight models over an OpenAI-compatible API.",
66
66
  "scripts": {
67
- "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
68
- "build:watch": "pnpm clean && tsup --watch",
69
- "clean": "del-cli dist docs *.tsbuildinfo",
67
+ "build": "pnpm clean && tsdown",
68
+ "build:watch": "pnpm clean && tsdown --watch",
69
+ "clean": "del-cli docs *.tsbuildinfo",
70
70
  "type-check": "tsc --build",
71
71
  "test": "pnpm test:node && pnpm test:edge",
72
72
  "test:update": "pnpm test:node -u",