@ai-sdk/cerebras 3.0.0-beta.9 → 3.0.0-canary.37

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,261 @@
1
1
  # @ai-sdk/cerebras
2
2
 
3
+ ## 3.0.0-canary.37
4
+
5
+ ### Patch Changes
6
+
7
+ - 0c4c275: trigger initial canary release
8
+ - Updated dependencies [0c4c275]
9
+ - @ai-sdk/openai-compatible@3.0.0-canary.37
10
+ - @ai-sdk/provider-utils@5.0.0-canary.31
11
+ - @ai-sdk/provider@4.0.0-canary.15
12
+
13
+ ## 3.0.0-beta.36
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [e59c955]
18
+ - @ai-sdk/openai-compatible@3.0.0-beta.36
19
+
20
+ ## 3.0.0-beta.35
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [08d2129]
25
+ - Updated dependencies [04e9009]
26
+ - @ai-sdk/provider-utils@5.0.0-beta.30
27
+ - @ai-sdk/openai-compatible@3.0.0-beta.35
28
+
29
+ ## 3.0.0-beta.34
30
+
31
+ ### Patch Changes
32
+
33
+ - 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
34
+ - Updated dependencies [9bd6512]
35
+ - Updated dependencies [258c093]
36
+ - Updated dependencies [b6783da]
37
+ - @ai-sdk/openai-compatible@3.0.0-beta.34
38
+ - @ai-sdk/provider-utils@5.0.0-beta.29
39
+ - @ai-sdk/provider@4.0.0-beta.14
40
+
41
+ ## 3.0.0-beta.33
42
+
43
+ ### Patch Changes
44
+
45
+ - 9f0e36c: trigger release for all packages after provenance setup
46
+ - Updated dependencies [9f0e36c]
47
+ - @ai-sdk/openai-compatible@3.0.0-beta.33
48
+ - @ai-sdk/provider@4.0.0-beta.13
49
+ - @ai-sdk/provider-utils@5.0.0-beta.28
50
+
51
+ ## 3.0.0-beta.32
52
+
53
+ ### Patch Changes
54
+
55
+ - Updated dependencies [ab81968]
56
+ - Updated dependencies [785fe16]
57
+ - Updated dependencies [67df0a0]
58
+ - Updated dependencies [befb78c]
59
+ - Updated dependencies [0458559]
60
+ - Updated dependencies [58a2ad7]
61
+ - Updated dependencies [5852c0a]
62
+ - Updated dependencies [fc92055]
63
+ - @ai-sdk/openai-compatible@3.0.0-beta.32
64
+ - @ai-sdk/provider-utils@5.0.0-beta.27
65
+
66
+ ## 3.0.0-beta.31
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies [2e98477]
71
+ - Updated dependencies [bfb756d]
72
+ - @ai-sdk/provider-utils@5.0.0-beta.26
73
+ - @ai-sdk/openai-compatible@3.0.0-beta.31
74
+
75
+ ## 3.0.0-beta.30
76
+
77
+ ### Patch Changes
78
+
79
+ - Updated dependencies [eea8d98]
80
+ - @ai-sdk/provider-utils@5.0.0-beta.25
81
+ - @ai-sdk/openai-compatible@3.0.0-beta.30
82
+
83
+ ## 3.0.0-beta.29
84
+
85
+ ### Patch Changes
86
+
87
+ - Updated dependencies [f807e45]
88
+ - @ai-sdk/provider-utils@5.0.0-beta.24
89
+ - @ai-sdk/openai-compatible@3.0.0-beta.29
90
+
91
+ ## 3.0.0-beta.28
92
+
93
+ ### Patch Changes
94
+
95
+ - Updated dependencies [350ea38]
96
+ - @ai-sdk/provider-utils@5.0.0-beta.23
97
+ - @ai-sdk/openai-compatible@3.0.0-beta.28
98
+
99
+ ## 3.0.0-beta.27
100
+
101
+ ### Patch Changes
102
+
103
+ - Updated dependencies [083947b]
104
+ - @ai-sdk/provider-utils@5.0.0-beta.22
105
+ - @ai-sdk/openai-compatible@3.0.0-beta.27
106
+
107
+ ## 3.0.0-beta.26
108
+
109
+ ### Patch Changes
110
+
111
+ - Updated dependencies [add1126]
112
+ - @ai-sdk/provider-utils@5.0.0-beta.21
113
+ - @ai-sdk/openai-compatible@3.0.0-beta.26
114
+
115
+ ## 3.0.0-beta.25
116
+
117
+ ### Patch Changes
118
+
119
+ - Updated dependencies [b3976a2]
120
+ - Updated dependencies [ff5eba1]
121
+ - @ai-sdk/provider-utils@5.0.0-beta.20
122
+ - @ai-sdk/openai-compatible@3.0.0-beta.25
123
+ - @ai-sdk/provider@4.0.0-beta.12
124
+
125
+ ## 3.0.0-beta.24
126
+
127
+ ### Major Changes
128
+
129
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
130
+
131
+ ### Patch Changes
132
+
133
+ - Updated dependencies [ef992f8]
134
+ - @ai-sdk/openai-compatible@3.0.0-beta.24
135
+ - @ai-sdk/provider@4.0.0-beta.11
136
+ - @ai-sdk/provider-utils@5.0.0-beta.19
137
+
138
+ ## 3.0.0-beta.23
139
+
140
+ ### Patch Changes
141
+
142
+ - 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
143
+ - Updated dependencies [90e2d8a]
144
+ - @ai-sdk/openai-compatible@3.0.0-beta.23
145
+ - @ai-sdk/provider-utils@5.0.0-beta.18
146
+
147
+ ## 3.0.0-beta.22
148
+
149
+ ### Patch Changes
150
+
151
+ - Updated dependencies [3ae1786]
152
+ - @ai-sdk/provider-utils@5.0.0-beta.17
153
+ - @ai-sdk/openai-compatible@3.0.0-beta.22
154
+
155
+ ## 3.0.0-beta.21
156
+
157
+ ### Patch Changes
158
+
159
+ - Updated dependencies [176466a]
160
+ - @ai-sdk/provider@4.0.0-beta.10
161
+ - @ai-sdk/openai-compatible@3.0.0-beta.21
162
+ - @ai-sdk/provider-utils@5.0.0-beta.16
163
+
164
+ ## 3.0.0-beta.20
165
+
166
+ ### Patch Changes
167
+
168
+ - Updated dependencies [e311194]
169
+ - @ai-sdk/provider@4.0.0-beta.9
170
+ - @ai-sdk/openai-compatible@3.0.0-beta.20
171
+ - @ai-sdk/provider-utils@5.0.0-beta.15
172
+
173
+ ## 3.0.0-beta.19
174
+
175
+ ### Patch Changes
176
+
177
+ - Updated dependencies [34bd95d]
178
+ - Updated dependencies [008271d]
179
+ - @ai-sdk/provider@4.0.0-beta.8
180
+ - @ai-sdk/openai-compatible@3.0.0-beta.19
181
+ - @ai-sdk/provider-utils@5.0.0-beta.14
182
+
183
+ ## 3.0.0-beta.18
184
+
185
+ ### Patch Changes
186
+
187
+ - Updated dependencies [b0c2869]
188
+ - Updated dependencies [7e26e81]
189
+ - @ai-sdk/provider-utils@5.0.0-beta.13
190
+ - @ai-sdk/openai-compatible@3.0.0-beta.18
191
+
192
+ ## 3.0.0-beta.17
193
+
194
+ ### Patch Changes
195
+
196
+ - Updated dependencies [816ff67]
197
+ - @ai-sdk/openai-compatible@3.0.0-beta.17
198
+
199
+ ## 3.0.0-beta.16
200
+
201
+ ### Patch Changes
202
+
203
+ - Updated dependencies [46d1149]
204
+ - @ai-sdk/provider-utils@5.0.0-beta.12
205
+ - @ai-sdk/openai-compatible@3.0.0-beta.16
206
+
207
+ ## 3.0.0-beta.15
208
+
209
+ ### Patch Changes
210
+
211
+ - Updated dependencies [6fd51c0]
212
+ - @ai-sdk/provider-utils@5.0.0-beta.11
213
+ - @ai-sdk/provider@4.0.0-beta.7
214
+ - @ai-sdk/openai-compatible@3.0.0-beta.15
215
+
216
+ ## 3.0.0-beta.14
217
+
218
+ ### Patch Changes
219
+
220
+ - Updated dependencies [c29a26f]
221
+ - @ai-sdk/openai-compatible@3.0.0-beta.14
222
+ - @ai-sdk/provider-utils@5.0.0-beta.10
223
+ - @ai-sdk/provider@4.0.0-beta.6
224
+
225
+ ## 3.0.0-beta.13
226
+
227
+ ### Patch Changes
228
+
229
+ - 38fc777: Add AI Gateway hint to provider READMEs
230
+ - Updated dependencies [38fc777]
231
+ - @ai-sdk/openai-compatible@3.0.0-beta.13
232
+
233
+ ## 3.0.0-beta.12
234
+
235
+ ### Patch Changes
236
+
237
+ - Updated dependencies [2e17091]
238
+ - @ai-sdk/provider-utils@5.0.0-beta.9
239
+ - @ai-sdk/openai-compatible@3.0.0-beta.12
240
+
241
+ ## 3.0.0-beta.11
242
+
243
+ ### Patch Changes
244
+
245
+ - Updated dependencies [986c6fd]
246
+ - Updated dependencies [493295c]
247
+ - @ai-sdk/provider-utils@5.0.0-beta.8
248
+ - @ai-sdk/openai-compatible@3.0.0-beta.11
249
+
250
+ ## 3.0.0-beta.10
251
+
252
+ ### Patch Changes
253
+
254
+ - Updated dependencies [1f509d4]
255
+ - @ai-sdk/provider-utils@5.0.0-beta.7
256
+ - @ai-sdk/provider@4.0.0-beta.5
257
+ - @ai-sdk/openai-compatible@3.0.0-beta.10
258
+
3
259
  ## 3.0.0-beta.9
4
260
 
5
261
  ### Patch Changes
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  The **Cerebras provider** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for [Cerebras](https://cerebras.ai), offering high-speed AI model inference powered by Cerebras Wafer-Scale Engines and CS-3 systems.
4
4
 
5
+ > **Deploying to Vercel?** With Vercel's AI Gateway you can access Cerebras (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
6
+
5
7
  ## Setup
6
8
 
7
9
  The Cerebras provider is available in the `@ai-sdk/cerebras` module. You can install it with
package/dist/index.js CHANGED
@@ -1,46 +1,26 @@
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
- VERSION: () => VERSION,
24
- cerebras: () => cerebras,
25
- createCerebras: () => createCerebras
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
-
29
1
  // src/cerebras-provider.ts
30
- var import_openai_compatible = require("@ai-sdk/openai-compatible");
31
- var import_provider = require("@ai-sdk/provider");
32
- var import_provider_utils = require("@ai-sdk/provider-utils");
33
- var import_v4 = require("zod/v4");
2
+ import {
3
+ OpenAICompatibleChatLanguageModel
4
+ } from "@ai-sdk/openai-compatible";
5
+ import {
6
+ NoSuchModelError
7
+ } from "@ai-sdk/provider";
8
+ import {
9
+ loadApiKey,
10
+ withoutTrailingSlash,
11
+ withUserAgentSuffix
12
+ } from "@ai-sdk/provider-utils";
13
+ import { z } from "zod/v4";
34
14
 
35
15
  // src/version.ts
36
- var VERSION = true ? "3.0.0-beta.9" : "0.0.0-test";
16
+ var VERSION = true ? "3.0.0-canary.37" : "0.0.0-test";
37
17
 
38
18
  // src/cerebras-provider.ts
39
- var cerebrasErrorSchema = import_v4.z.object({
40
- message: import_v4.z.string(),
41
- type: import_v4.z.string(),
42
- param: import_v4.z.string(),
43
- code: import_v4.z.string()
19
+ var cerebrasErrorSchema = z.object({
20
+ message: z.string(),
21
+ type: z.string(),
22
+ param: z.string(),
23
+ code: z.string()
44
24
  });
45
25
  var cerebrasErrorStructure = {
46
26
  errorSchema: cerebrasErrorSchema,
@@ -48,12 +28,12 @@ var cerebrasErrorStructure = {
48
28
  };
49
29
  function createCerebras(options = {}) {
50
30
  var _a;
51
- const baseURL = (0, import_provider_utils.withoutTrailingSlash)(
31
+ const baseURL = withoutTrailingSlash(
52
32
  (_a = options.baseURL) != null ? _a : "https://api.cerebras.ai/v1"
53
33
  );
54
- const getHeaders = () => (0, import_provider_utils.withUserAgentSuffix)(
34
+ const getHeaders = () => withUserAgentSuffix(
55
35
  {
56
- Authorization: `Bearer ${(0, import_provider_utils.loadApiKey)({
36
+ Authorization: `Bearer ${loadApiKey({
57
37
  apiKey: options.apiKey,
58
38
  environmentVariableName: "CEREBRAS_API_KEY",
59
39
  description: "Cerebras API key"
@@ -63,7 +43,7 @@ function createCerebras(options = {}) {
63
43
  `ai-sdk/cerebras/${VERSION}`
64
44
  );
65
45
  const createLanguageModel = (modelId) => {
66
- return new import_openai_compatible.OpenAICompatibleChatLanguageModel(modelId, {
46
+ return new OpenAICompatibleChatLanguageModel(modelId, {
67
47
  provider: `cerebras.chat`,
68
48
  url: ({ path }) => `${baseURL}${path}`,
69
49
  headers: getHeaders,
@@ -77,19 +57,18 @@ function createCerebras(options = {}) {
77
57
  provider.languageModel = createLanguageModel;
78
58
  provider.chat = createLanguageModel;
79
59
  provider.embeddingModel = (modelId) => {
80
- throw new import_provider.NoSuchModelError({ modelId, modelType: "embeddingModel" });
60
+ throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
81
61
  };
82
62
  provider.textEmbeddingModel = provider.embeddingModel;
83
63
  provider.imageModel = (modelId) => {
84
- throw new import_provider.NoSuchModelError({ modelId, modelType: "imageModel" });
64
+ throw new NoSuchModelError({ modelId, modelType: "imageModel" });
85
65
  };
86
66
  return provider;
87
67
  }
88
68
  var cerebras = createCerebras();
89
- // Annotate the CommonJS export names for ESM import in node:
90
- 0 && (module.exports = {
69
+ export {
91
70
  VERSION,
92
71
  cerebras,
93
72
  createCerebras
94
- });
73
+ };
95
74
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/cerebras-provider.ts","../src/version.ts"],"sourcesContent":["export { createCerebras, cerebras } from './cerebras-provider';\nexport type {\n CerebrasProvider,\n CerebrasProviderSettings,\n} from './cerebras-provider';\nexport type { CerebrasErrorData } from './cerebras-provider';\nexport { VERSION } from './version';\n","import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n LanguageModelV4,\n NoSuchModelError,\n ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { CerebrasChatModelId } from './cerebras-chat-options';\nimport { z } from 'zod/v4';\nimport { ProviderErrorStructure } from '@ai-sdk/openai-compatible';\nimport { VERSION } from './version';\n\n// Add error schema and structure\nconst cerebrasErrorSchema = z.object({\n message: z.string(),\n type: z.string(),\n param: z.string(),\n code: z.string(),\n});\n\nexport type CerebrasErrorData = z.infer<typeof cerebrasErrorSchema>;\n\nconst cerebrasErrorStructure: ProviderErrorStructure<CerebrasErrorData> = {\n errorSchema: cerebrasErrorSchema,\n errorToMessage: data => data.message,\n};\n\nexport interface CerebrasProviderSettings {\n /**\n * Cerebras API key.\n */\n apiKey?: string;\n /**\n * Base URL for the API calls.\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 requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface CerebrasProvider extends ProviderV4 {\n /**\n * Creates a Cerebras model for text generation.\n */\n (modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * Creates a Cerebras model for text generation.\n */\n languageModel(modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * Creates a Cerebras chat model for text generation.\n */\n chat(modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport function createCerebras(\n options: CerebrasProviderSettings = {},\n): CerebrasProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.cerebras.ai/v1',\n );\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'CEREBRAS_API_KEY',\n description: 'Cerebras API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/cerebras/${VERSION}`,\n );\n\n const createLanguageModel = (modelId: CerebrasChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n provider: `cerebras.chat`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n errorStructure: cerebrasErrorStructure,\n supportsStructuredOutputs: true,\n });\n };\n\n const provider = (modelId: CerebrasChatModelId) =>\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 cerebras = createCerebras();\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;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,+BAAkD;AAClD,sBAIO;AACP,4BAKO;AAEP,gBAAkB;;;ACXX,IAAM,UACX,OACI,iBACA;;;ADaN,IAAM,sBAAsB,YAAE,OAAO;AAAA,EACnC,SAAS,YAAE,OAAO;AAAA,EAClB,MAAM,YAAE,OAAO;AAAA,EACf,OAAO,YAAE,OAAO;AAAA,EAChB,MAAM,YAAE,OAAO;AACjB,CAAC;AAID,IAAM,yBAAoE;AAAA,EACxE,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK;AAC/B;AA4CO,SAAS,eACd,UAAoC,CAAC,GACnB;AA5EpB;AA6EE,QAAM,cAAU;AAAA,KACd,aAAQ,YAAR,YAAmB;AAAA,EACrB;AACA,QAAM,aAAa,UACjB;AAAA,IACE;AAAA,MACE,eAAe,cAAU,kCAAW;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,2DAAkC,SAAS;AAAA,MACpD,UAAU;AAAA,MACV,KAAK,CAAC,EAAE,KAAK,MAAM,GAAG,OAAO,GAAG,IAAI;AAAA,MACpC,SAAS;AAAA,MACT,OAAO,QAAQ;AAAA,MACf,gBAAgB;AAAA,MAChB,2BAA2B;AAAA,IAC7B,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,iCAAiB,EAAE,SAAS,WAAW,iBAAiB,CAAC;AAAA,EACrE;AACA,WAAS,qBAAqB,SAAS;AACvC,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":[]}
1
+ {"version":3,"sources":["../src/cerebras-provider.ts","../src/version.ts"],"sourcesContent":["import {\n OpenAICompatibleChatLanguageModel,\n type ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport {\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 type { CerebrasChatModelId } from './cerebras-chat-options';\nimport { z } from 'zod/v4';\nimport { VERSION } from './version';\n\n// Add error schema and structure\nconst cerebrasErrorSchema = z.object({\n message: z.string(),\n type: z.string(),\n param: z.string(),\n code: z.string(),\n});\n\nexport type CerebrasErrorData = z.infer<typeof cerebrasErrorSchema>;\n\nconst cerebrasErrorStructure: ProviderErrorStructure<CerebrasErrorData> = {\n errorSchema: cerebrasErrorSchema,\n errorToMessage: data => data.message,\n};\n\nexport interface CerebrasProviderSettings {\n /**\n * Cerebras API key.\n */\n apiKey?: string;\n /**\n * Base URL for the API calls.\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 requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface CerebrasProvider extends ProviderV4 {\n /**\n * Creates a Cerebras model for text generation.\n */\n (modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * Creates a Cerebras model for text generation.\n */\n languageModel(modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * Creates a Cerebras chat model for text generation.\n */\n chat(modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport function createCerebras(\n options: CerebrasProviderSettings = {},\n): CerebrasProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.cerebras.ai/v1',\n );\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'CEREBRAS_API_KEY',\n description: 'Cerebras API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/cerebras/${VERSION}`,\n );\n\n const createLanguageModel = (modelId: CerebrasChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n provider: `cerebras.chat`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n errorStructure: cerebrasErrorStructure,\n supportsStructuredOutputs: true,\n });\n };\n\n const provider = (modelId: CerebrasChatModelId) =>\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 cerebras = createCerebras();\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,OAEK;AACP;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,SAAS;;;ACdX,IAAM,UACX,OACI,oBACA;;;ADeN,IAAM,sBAAsB,EAAE,OAAO;AAAA,EACnC,SAAS,EAAE,OAAO;AAAA,EAClB,MAAM,EAAE,OAAO;AAAA,EACf,OAAO,EAAE,OAAO;AAAA,EAChB,MAAM,EAAE,OAAO;AACjB,CAAC;AAID,IAAM,yBAAoE;AAAA,EACxE,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK;AAC/B;AA4CO,SAAS,eACd,UAAoC,CAAC,GACnB;AA9EpB;AA+EE,QAAM,UAAU;AAAA,KACd,aAAQ,YAAR,YAAmB;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,kCAAkC,SAAS;AAAA,MACpD,UAAU;AAAA,MACV,KAAK,CAAC,EAAE,KAAK,MAAM,GAAG,OAAO,GAAG,IAAI;AAAA,MACpC,SAAS;AAAA,MACT,OAAO,QAAQ;AAAA,MACf,gBAAgB;AAAA,MAChB,2BAA2B;AAAA,IAC7B,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":[]}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@ai-sdk/cerebras",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.0-canary.37",
4
+ "type": "module",
4
5
  "license": "Apache-2.0",
5
6
  "sideEffects": false,
6
7
  "main": "./dist/index.js",
7
- "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",
9
9
  "files": [
10
10
  "dist/**/*",
@@ -24,14 +24,14 @@
24
24
  "./package.json": "./package.json",
25
25
  ".": {
26
26
  "types": "./dist/index.d.ts",
27
- "import": "./dist/index.mjs",
28
- "require": "./dist/index.js"
27
+ "import": "./dist/index.js",
28
+ "default": "./dist/index.js"
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/openai-compatible": "3.0.0-beta.9",
33
- "@ai-sdk/provider": "4.0.0-beta.4",
34
- "@ai-sdk/provider-utils": "5.0.0-beta.6"
32
+ "@ai-sdk/openai-compatible": "3.0.0-canary.37",
33
+ "@ai-sdk/provider": "4.0.0-canary.15",
34
+ "@ai-sdk/provider-utils": "5.0.0-canary.31"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "20.17.24",
@@ -47,12 +47,14 @@
47
47
  "node": ">=18"
48
48
  },
49
49
  "publishConfig": {
50
- "access": "public"
50
+ "access": "public",
51
+ "provenance": true
51
52
  },
52
53
  "homepage": "https://ai-sdk.dev/docs",
53
54
  "repository": {
54
55
  "type": "git",
55
- "url": "git+https://github.com/vercel/ai.git"
56
+ "url": "https://github.com/vercel/ai",
57
+ "directory": "packages/cerebras"
56
58
  },
57
59
  "bugs": {
58
60
  "url": "https://github.com/vercel/ai/issues"
@@ -61,8 +63,6 @@
61
63
  "ai"
62
64
  ],
63
65
  "description": "The **Cerebras provider** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for [Cerebras](https://cerebras.ai), offering high-speed AI model inference powered by Cerebras Wafer-Scale Engines and CS-3 systems.",
64
- "author": "",
65
- "type": "commonjs",
66
66
  "scripts": {
67
67
  "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
68
68
  "build:watch": "pnpm clean && tsup --watch",
@@ -1,18 +1,20 @@
1
- import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';
2
1
  import {
3
- LanguageModelV4,
2
+ OpenAICompatibleChatLanguageModel,
3
+ type ProviderErrorStructure,
4
+ } from '@ai-sdk/openai-compatible';
5
+ import {
4
6
  NoSuchModelError,
5
- ProviderV4,
7
+ type LanguageModelV4,
8
+ type ProviderV4,
6
9
  } from '@ai-sdk/provider';
7
10
  import {
8
- FetchFunction,
9
11
  loadApiKey,
10
12
  withoutTrailingSlash,
11
13
  withUserAgentSuffix,
14
+ type FetchFunction,
12
15
  } from '@ai-sdk/provider-utils';
13
- import { CerebrasChatModelId } from './cerebras-chat-options';
16
+ import type { CerebrasChatModelId } from './cerebras-chat-options';
14
17
  import { z } from 'zod/v4';
15
- import { ProviderErrorStructure } from '@ai-sdk/openai-compatible';
16
18
  import { VERSION } from './version';
17
19
 
18
20
  // Add error schema and structure
package/dist/index.d.mts DELETED
@@ -1,56 +0,0 @@
1
- import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
2
- import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { z } from 'zod/v4';
4
-
5
- type CerebrasChatModelId = 'llama3.1-8b' | 'gpt-oss-120b' | 'qwen-3-235b-a22b-instruct-2507' | 'qwen-3-235b-a22b-thinking-2507' | 'zai-glm-4.6' | 'zai-glm-4.7' | (string & {});
6
-
7
- declare const cerebrasErrorSchema: z.ZodObject<{
8
- message: z.ZodString;
9
- type: z.ZodString;
10
- param: z.ZodString;
11
- code: z.ZodString;
12
- }, z.core.$strip>;
13
- type CerebrasErrorData = z.infer<typeof cerebrasErrorSchema>;
14
- interface CerebrasProviderSettings {
15
- /**
16
- * Cerebras API key.
17
- */
18
- apiKey?: string;
19
- /**
20
- * Base URL for the API calls.
21
- */
22
- baseURL?: string;
23
- /**
24
- * Custom headers to include in the requests.
25
- */
26
- headers?: Record<string, string>;
27
- /**
28
- * Custom fetch implementation. You can use it as a middleware to intercept requests,
29
- * or to provide a custom fetch implementation for e.g. testing.
30
- */
31
- fetch?: FetchFunction;
32
- }
33
- interface CerebrasProvider extends ProviderV4 {
34
- /**
35
- * Creates a Cerebras model for text generation.
36
- */
37
- (modelId: CerebrasChatModelId): LanguageModelV4;
38
- /**
39
- * Creates a Cerebras model for text generation.
40
- */
41
- languageModel(modelId: CerebrasChatModelId): LanguageModelV4;
42
- /**
43
- * Creates a Cerebras chat model for text generation.
44
- */
45
- chat(modelId: CerebrasChatModelId): LanguageModelV4;
46
- /**
47
- * @deprecated Use `embeddingModel` instead.
48
- */
49
- textEmbeddingModel(modelId: string): never;
50
- }
51
- declare function createCerebras(options?: CerebrasProviderSettings): CerebrasProvider;
52
- declare const cerebras: CerebrasProvider;
53
-
54
- declare const VERSION: string;
55
-
56
- export { type CerebrasErrorData, type CerebrasProvider, type CerebrasProviderSettings, VERSION, cerebras, createCerebras };
package/dist/index.mjs DELETED
@@ -1,72 +0,0 @@
1
- // src/cerebras-provider.ts
2
- import { OpenAICompatibleChatLanguageModel } from "@ai-sdk/openai-compatible";
3
- import {
4
- NoSuchModelError
5
- } from "@ai-sdk/provider";
6
- import {
7
- loadApiKey,
8
- withoutTrailingSlash,
9
- withUserAgentSuffix
10
- } from "@ai-sdk/provider-utils";
11
- import { z } from "zod/v4";
12
-
13
- // src/version.ts
14
- var VERSION = true ? "3.0.0-beta.9" : "0.0.0-test";
15
-
16
- // src/cerebras-provider.ts
17
- var cerebrasErrorSchema = z.object({
18
- message: z.string(),
19
- type: z.string(),
20
- param: z.string(),
21
- code: z.string()
22
- });
23
- var cerebrasErrorStructure = {
24
- errorSchema: cerebrasErrorSchema,
25
- errorToMessage: (data) => data.message
26
- };
27
- function createCerebras(options = {}) {
28
- var _a;
29
- const baseURL = withoutTrailingSlash(
30
- (_a = options.baseURL) != null ? _a : "https://api.cerebras.ai/v1"
31
- );
32
- const getHeaders = () => withUserAgentSuffix(
33
- {
34
- Authorization: `Bearer ${loadApiKey({
35
- apiKey: options.apiKey,
36
- environmentVariableName: "CEREBRAS_API_KEY",
37
- description: "Cerebras API key"
38
- })}`,
39
- ...options.headers
40
- },
41
- `ai-sdk/cerebras/${VERSION}`
42
- );
43
- const createLanguageModel = (modelId) => {
44
- return new OpenAICompatibleChatLanguageModel(modelId, {
45
- provider: `cerebras.chat`,
46
- url: ({ path }) => `${baseURL}${path}`,
47
- headers: getHeaders,
48
- fetch: options.fetch,
49
- errorStructure: cerebrasErrorStructure,
50
- supportsStructuredOutputs: true
51
- });
52
- };
53
- const provider = (modelId) => createLanguageModel(modelId);
54
- provider.specificationVersion = "v4";
55
- provider.languageModel = createLanguageModel;
56
- provider.chat = createLanguageModel;
57
- provider.embeddingModel = (modelId) => {
58
- throw new NoSuchModelError({ modelId, modelType: "embeddingModel" });
59
- };
60
- provider.textEmbeddingModel = provider.embeddingModel;
61
- provider.imageModel = (modelId) => {
62
- throw new NoSuchModelError({ modelId, modelType: "imageModel" });
63
- };
64
- return provider;
65
- }
66
- var cerebras = createCerebras();
67
- export {
68
- VERSION,
69
- cerebras,
70
- createCerebras
71
- };
72
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cerebras-provider.ts","../src/version.ts"],"sourcesContent":["import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n LanguageModelV4,\n NoSuchModelError,\n ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n FetchFunction,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n} from '@ai-sdk/provider-utils';\nimport { CerebrasChatModelId } from './cerebras-chat-options';\nimport { z } from 'zod/v4';\nimport { ProviderErrorStructure } from '@ai-sdk/openai-compatible';\nimport { VERSION } from './version';\n\n// Add error schema and structure\nconst cerebrasErrorSchema = z.object({\n message: z.string(),\n type: z.string(),\n param: z.string(),\n code: z.string(),\n});\n\nexport type CerebrasErrorData = z.infer<typeof cerebrasErrorSchema>;\n\nconst cerebrasErrorStructure: ProviderErrorStructure<CerebrasErrorData> = {\n errorSchema: cerebrasErrorSchema,\n errorToMessage: data => data.message,\n};\n\nexport interface CerebrasProviderSettings {\n /**\n * Cerebras API key.\n */\n apiKey?: string;\n /**\n * Base URL for the API calls.\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 requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface CerebrasProvider extends ProviderV4 {\n /**\n * Creates a Cerebras model for text generation.\n */\n (modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * Creates a Cerebras model for text generation.\n */\n languageModel(modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * Creates a Cerebras chat model for text generation.\n */\n chat(modelId: CerebrasChatModelId): LanguageModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nexport function createCerebras(\n options: CerebrasProviderSettings = {},\n): CerebrasProvider {\n const baseURL = withoutTrailingSlash(\n options.baseURL ?? 'https://api.cerebras.ai/v1',\n );\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'CEREBRAS_API_KEY',\n description: 'Cerebras API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/cerebras/${VERSION}`,\n );\n\n const createLanguageModel = (modelId: CerebrasChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n provider: `cerebras.chat`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n errorStructure: cerebrasErrorStructure,\n supportsStructuredOutputs: true,\n });\n };\n\n const provider = (modelId: CerebrasChatModelId) =>\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 cerebras = createCerebras();\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,SAAS,yCAAyC;AAClD;AAAA,EAEE;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,SAAS;;;ACXX,IAAM,UACX,OACI,iBACA;;;ADaN,IAAM,sBAAsB,EAAE,OAAO;AAAA,EACnC,SAAS,EAAE,OAAO;AAAA,EAClB,MAAM,EAAE,OAAO;AAAA,EACf,OAAO,EAAE,OAAO;AAAA,EAChB,MAAM,EAAE,OAAO;AACjB,CAAC;AAID,IAAM,yBAAoE;AAAA,EACxE,aAAa;AAAA,EACb,gBAAgB,UAAQ,KAAK;AAC/B;AA4CO,SAAS,eACd,UAAoC,CAAC,GACnB;AA5EpB;AA6EE,QAAM,UAAU;AAAA,KACd,aAAQ,YAAR,YAAmB;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,kCAAkC,SAAS;AAAA,MACpD,UAAU;AAAA,MACV,KAAK,CAAC,EAAE,KAAK,MAAM,GAAG,OAAO,GAAG,IAAI;AAAA,MACpC,SAAS;AAAA,MACT,OAAO,QAAQ;AAAA,MACf,gBAAgB;AAAA,MAChB,2BAA2B;AAAA,IAC7B,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":[]}