@ai-sdk/cerebras 1.1.0-beta.9 → 2.0.0-beta.13
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 +48 -0
- package/README.md +43 -8
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @ai-sdk/cerebras
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 42e9f64: Add support for 5 new Cerebras models:
|
|
8
|
+
|
|
9
|
+
- gpt-oss-120b (120B parameters)
|
|
10
|
+
- qwen-3-235b-a22b-instruct-2507 (235B instruction-tuned)
|
|
11
|
+
- qwen-3-235b-a22b-thinking-2507 (235B enhanced reasoning)
|
|
12
|
+
- qwen-3-32b (32B multilingual)
|
|
13
|
+
- qwen-3-coder-480b (480B code generation)
|
|
14
|
+
|
|
15
|
+
Remove deprecated llama3.1-70b model.
|
|
16
|
+
|
|
17
|
+
## 2.0.0-beta.12
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- Added support for new Cerebras models:
|
|
22
|
+
- `gpt-oss-120b` - 120 billion parameter high-performance model
|
|
23
|
+
- `qwen-3-235b-a22b-instruct-2507` - 235 billion parameter instruction-tuned model
|
|
24
|
+
- `qwen-3-235b-a22b-thinking-2507` - 235 billion parameter model with enhanced reasoning
|
|
25
|
+
- `qwen-3-32b` - 32 billion parameter multilingual model
|
|
26
|
+
- `qwen-3-coder-480b` - 480 billion parameter model specialized for code generation
|
|
27
|
+
- Removed deprecated `llama3.1-70b` model
|
|
28
|
+
- Updated documentation with comprehensive model information
|
|
29
|
+
|
|
30
|
+
## 2.0.0-beta.11
|
|
31
|
+
|
|
32
|
+
### Major Changes
|
|
33
|
+
|
|
34
|
+
- dee8b05: ai SDK 6 beta
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- Updated dependencies [dee8b05]
|
|
39
|
+
- @ai-sdk/openai-compatible@2.0.0-beta.10
|
|
40
|
+
- @ai-sdk/provider@3.0.0-beta.6
|
|
41
|
+
- @ai-sdk/provider-utils@4.0.0-beta.10
|
|
42
|
+
|
|
43
|
+
## 1.1.0-beta.10
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [521c537]
|
|
48
|
+
- @ai-sdk/provider-utils@3.1.0-beta.9
|
|
49
|
+
- @ai-sdk/openai-compatible@1.1.0-beta.9
|
|
50
|
+
|
|
3
51
|
## 1.1.0-beta.9
|
|
4
52
|
|
|
5
53
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -20,7 +20,15 @@ import { cerebras } from '@ai-sdk/cerebras';
|
|
|
20
20
|
|
|
21
21
|
## Available Models
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Cerebras offers a variety of high-performance language models:
|
|
24
|
+
|
|
25
|
+
### Llama 3.3 70B
|
|
26
|
+
|
|
27
|
+
- Model ID: `llama-3.3-70b`
|
|
28
|
+
- 70 billion parameters
|
|
29
|
+
- Knowledge cutoff: December 2023
|
|
30
|
+
- Context Length: 8192
|
|
31
|
+
- Training Tokens: 15 trillion+
|
|
24
32
|
|
|
25
33
|
### Llama 3.1 8B
|
|
26
34
|
|
|
@@ -30,13 +38,40 @@ Currently, Cerebras offers two models:
|
|
|
30
38
|
- Context Length: 8192
|
|
31
39
|
- Training Tokens: 15 trillion+
|
|
32
40
|
|
|
33
|
-
###
|
|
41
|
+
### GPT-OSS 120B
|
|
34
42
|
|
|
35
|
-
- Model ID: `
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
|
|
43
|
+
- Model ID: `gpt-oss-120b`
|
|
44
|
+
- 120 billion parameters
|
|
45
|
+
- High-performance open-source model
|
|
46
|
+
- Optimized for inference speed
|
|
47
|
+
|
|
48
|
+
### Qwen 3 235B A22B Instruct 2507
|
|
49
|
+
|
|
50
|
+
- Model ID: `qwen-3-235b-a22b-instruct-2507`
|
|
51
|
+
- 235 billion parameters
|
|
52
|
+
- Instruction-tuned model
|
|
53
|
+
- Released July 2025
|
|
54
|
+
|
|
55
|
+
### Qwen 3 235B A22B Thinking 2507
|
|
56
|
+
|
|
57
|
+
- Model ID: `qwen-3-235b-a22b-thinking-2507`
|
|
58
|
+
- 235 billion parameters
|
|
59
|
+
- Enhanced reasoning capabilities
|
|
60
|
+
- Released July 2025
|
|
61
|
+
|
|
62
|
+
### Qwen 3 32B
|
|
63
|
+
|
|
64
|
+
- Model ID: `qwen-3-32b`
|
|
65
|
+
- 32 billion parameters
|
|
66
|
+
- Balanced performance and efficiency
|
|
67
|
+
- Multilingual capabilities
|
|
68
|
+
|
|
69
|
+
### Qwen 3 Coder 480B
|
|
70
|
+
|
|
71
|
+
- Model ID: `qwen-3-coder-480b`
|
|
72
|
+
- 480 billion parameters
|
|
73
|
+
- Specialized for code generation and understanding
|
|
74
|
+
- Advanced programming capabilities
|
|
40
75
|
|
|
41
76
|
## Example
|
|
42
77
|
|
|
@@ -45,7 +80,7 @@ import { cerebras } from '@ai-sdk/cerebras';
|
|
|
45
80
|
import { generateText } from 'ai';
|
|
46
81
|
|
|
47
82
|
const { text } = await generateText({
|
|
48
|
-
model: cerebras('
|
|
83
|
+
model: cerebras('llama-3.3-70b'),
|
|
49
84
|
prompt: 'Write a JavaScript function that sorts a list:',
|
|
50
85
|
});
|
|
51
86
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
|
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { z } from 'zod/v4';
|
|
4
4
|
|
|
5
|
-
type CerebrasChatModelId = '
|
|
5
|
+
type CerebrasChatModelId = 'llama-3.3-70b' | 'llama3.1-8b' | 'gpt-oss-120b' | 'qwen-3-235b-a22b-instruct-2507' | 'qwen-3-235b-a22b-thinking-2507' | 'qwen-3-32b' | 'qwen-3-coder-480b' | (string & {});
|
|
6
6
|
|
|
7
7
|
declare const cerebrasErrorSchema: z.ZodObject<{
|
|
8
8
|
message: z.ZodString;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
|
|
|
2
2
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
3
|
import { z } from 'zod/v4';
|
|
4
4
|
|
|
5
|
-
type CerebrasChatModelId = '
|
|
5
|
+
type CerebrasChatModelId = 'llama-3.3-70b' | 'llama3.1-8b' | 'gpt-oss-120b' | 'qwen-3-235b-a22b-instruct-2507' | 'qwen-3-235b-a22b-thinking-2507' | 'qwen-3-32b' | 'qwen-3-coder-480b' | (string & {});
|
|
6
6
|
|
|
7
7
|
declare const cerebrasErrorSchema: z.ZodObject<{
|
|
8
8
|
message: z.ZodString;
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
|
33
33
|
var import_v4 = require("zod/v4");
|
|
34
34
|
|
|
35
35
|
// src/version.ts
|
|
36
|
-
var VERSION = true ? "
|
|
36
|
+
var VERSION = true ? "2.0.0-beta.13" : "0.0.0-test";
|
|
37
37
|
|
|
38
38
|
// src/cerebras-provider.ts
|
|
39
39
|
var cerebrasErrorSchema = import_v4.z.object({
|
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 LanguageModelV3,\n NoSuchModelError,\n ProviderV3,\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 /**\nCerebras API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface CerebrasProvider extends ProviderV3 {\n /**\nCreates a Cerebras model for text generation.\n*/\n (modelId: CerebrasChatModelId): LanguageModelV3;\n\n /**\nCreates a Cerebras model for text generation.\n*/\n languageModel(modelId: CerebrasChatModelId): LanguageModelV3;\n\n /**\nCreates a Cerebras chat model for text generation.\n*/\n chat(modelId: CerebrasChatModelId): LanguageModelV3;\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.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\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,
|
|
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 LanguageModelV3,\n NoSuchModelError,\n ProviderV3,\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 /**\nCerebras API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface CerebrasProvider extends ProviderV3 {\n /**\nCreates a Cerebras model for text generation.\n*/\n (modelId: CerebrasChatModelId): LanguageModelV3;\n\n /**\nCreates a Cerebras model for text generation.\n*/\n languageModel(modelId: CerebrasChatModelId): LanguageModelV3;\n\n /**\nCreates a Cerebras chat model for text generation.\n*/\n chat(modelId: CerebrasChatModelId): LanguageModelV3;\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.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\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,kBACA;;;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;AAuCO,SAAS,eACd,UAAoC,CAAC,GACnB;AAvEpB;AAwEE,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,gBAAgB;AACzB,WAAS,OAAO;AAEhB,WAAS,qBAAqB,CAAC,YAAoB;AACjD,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,qBAAqB,CAAC;AAAA,EACzE;AACA,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iCAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAEO,IAAM,WAAW,eAAe;","names":[]}
|
package/dist/index.mjs
CHANGED
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cerebras-provider.ts","../src/version.ts"],"sourcesContent":["import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n LanguageModelV3,\n NoSuchModelError,\n ProviderV3,\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 /**\nCerebras API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface CerebrasProvider extends ProviderV3 {\n /**\nCreates a Cerebras model for text generation.\n*/\n (modelId: CerebrasChatModelId): LanguageModelV3;\n\n /**\nCreates a Cerebras model for text generation.\n*/\n languageModel(modelId: CerebrasChatModelId): LanguageModelV3;\n\n /**\nCreates a Cerebras chat model for text generation.\n*/\n chat(modelId: CerebrasChatModelId): LanguageModelV3;\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.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\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,
|
|
1
|
+
{"version":3,"sources":["../src/cerebras-provider.ts","../src/version.ts"],"sourcesContent":["import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport {\n LanguageModelV3,\n NoSuchModelError,\n ProviderV3,\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 /**\nCerebras API key.\n*/\n apiKey?: string;\n /**\nBase URL for the API calls.\n*/\n baseURL?: string;\n /**\nCustom headers to include in the requests.\n*/\n headers?: Record<string, string>;\n /**\nCustom fetch implementation. You can use it as a middleware to intercept requests,\nor to provide a custom fetch implementation for e.g. testing.\n*/\n fetch?: FetchFunction;\n}\n\nexport interface CerebrasProvider extends ProviderV3 {\n /**\nCreates a Cerebras model for text generation.\n*/\n (modelId: CerebrasChatModelId): LanguageModelV3;\n\n /**\nCreates a Cerebras model for text generation.\n*/\n languageModel(modelId: CerebrasChatModelId): LanguageModelV3;\n\n /**\nCreates a Cerebras chat model for text generation.\n*/\n chat(modelId: CerebrasChatModelId): LanguageModelV3;\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.languageModel = createLanguageModel;\n provider.chat = createLanguageModel;\n\n provider.textEmbeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'textEmbeddingModel' });\n };\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,kBACA;;;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;AAuCO,SAAS,eACd,UAAoC,CAAC,GACnB;AAvEpB;AAwEE,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,gBAAgB;AACzB,WAAS,OAAO;AAEhB,WAAS,qBAAqB,CAAC,YAAoB;AACjD,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,qBAAqB,CAAC;AAAA,EACzE;AACA,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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/cerebras",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.13",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@ai-sdk/openai-compatible": "
|
|
23
|
-
"@ai-sdk/provider": "
|
|
24
|
-
"@ai-sdk/provider-utils": "
|
|
22
|
+
"@ai-sdk/openai-compatible": "2.0.0-beta.10",
|
|
23
|
+
"@ai-sdk/provider": "3.0.0-beta.6",
|
|
24
|
+
"@ai-sdk/provider-utils": "4.0.0-beta.10"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "20.17.24",
|
|
@@ -50,6 +50,9 @@
|
|
|
50
50
|
"keywords": [
|
|
51
51
|
"ai"
|
|
52
52
|
],
|
|
53
|
+
"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.",
|
|
54
|
+
"author": "",
|
|
55
|
+
"type": "commonjs",
|
|
53
56
|
"scripts": {
|
|
54
57
|
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
|
55
58
|
"build:watch": "pnpm clean && tsup --watch",
|