@ai-sdk/cerebras 3.0.92 → 3.0.94
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 +17 -0
- package/dist/index.d.ts +50 -40
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/cerebras-chat-options.ts +3 -3
- package/src/cerebras-model-catalog.ts +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @ai-sdk/cerebras
|
|
2
2
|
|
|
3
|
+
## 3.0.94
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [10ff0b1]
|
|
8
|
+
- Updated dependencies [e878ab3]
|
|
9
|
+
- Updated dependencies [d99098a]
|
|
10
|
+
- @ai-sdk/provider@4.0.39
|
|
11
|
+
- @ai-sdk/provider-utils@5.0.82
|
|
12
|
+
- @ai-sdk/openai-compatible@3.0.93
|
|
13
|
+
|
|
14
|
+
## 3.0.93
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- f5fc6ba: Derive known model ID suggestions from each provider's model catalog declarations so catalog updates automatically update autocomplete, while preserving existing suggestions, endpoint-specific model lists, and support for custom model IDs.
|
|
19
|
+
|
|
3
20
|
## 3.0.92
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,57 @@
|
|
|
1
1
|
import { LanguageModelV4, ProviderV4 } from "@ai-sdk/provider";
|
|
2
2
|
import { FetchFunction, Resolvable } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
|
+
//#region src/cerebras-chat-language-model-options.d.ts
|
|
5
|
+
declare const cerebrasLanguageModelChatOptions: z.ZodObject<{
|
|
6
|
+
user: z.ZodOptional<z.ZodString>;
|
|
7
|
+
strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
logprobs: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
topLogprobs: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
logitBias: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
12
|
+
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
13
|
+
default: "default";
|
|
14
|
+
auto: "auto";
|
|
15
|
+
flex: "flex";
|
|
16
|
+
priority: "priority";
|
|
17
|
+
}>>;
|
|
18
|
+
queueThreshold: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
20
|
+
none: "none";
|
|
21
|
+
low: "low";
|
|
22
|
+
medium: "medium";
|
|
23
|
+
high: "high";
|
|
24
|
+
}>>;
|
|
25
|
+
reasoningFormat: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
none: "none";
|
|
27
|
+
parsed: "parsed";
|
|
28
|
+
text_parsed: "text_parsed";
|
|
29
|
+
raw: "raw";
|
|
30
|
+
hidden: "hidden";
|
|
31
|
+
}>>;
|
|
32
|
+
prediction: z.ZodOptional<z.ZodObject<{
|
|
33
|
+
type: z.ZodLiteral<"content">;
|
|
34
|
+
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
35
|
+
type: z.ZodLiteral<"text">;
|
|
36
|
+
text: z.ZodString;
|
|
37
|
+
}, z.core.$strip>>]>;
|
|
38
|
+
}, z.core.$strip>>;
|
|
39
|
+
promptCacheKey: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
type CerebrasLanguageModelChatOptions = z.infer<typeof cerebrasLanguageModelChatOptions>;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/cerebras-model-catalog.d.ts
|
|
44
|
+
declare const languageDefinitions: {
|
|
45
|
+
'gpt-oss-120b': false;
|
|
46
|
+
'gemma-4-31b': true;
|
|
47
|
+
};
|
|
48
|
+
/** Known model IDs, derived from the declarations used to build the catalog. */
|
|
49
|
+
type CerebrasModelIds = {
|
|
50
|
+
language: keyof typeof languageDefinitions;
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
4
53
|
//#region src/cerebras-chat-options.d.ts
|
|
5
|
-
type CerebrasChatModelId = '
|
|
54
|
+
type CerebrasChatModelId = CerebrasModelIds['language'] | (string & {});
|
|
6
55
|
//#endregion
|
|
7
56
|
//#region src/cerebras-provider.d.ts
|
|
8
57
|
declare const cerebrasErrorSchema: z.ZodObject<{
|
|
@@ -53,45 +102,6 @@ interface CerebrasProvider extends ProviderV4 {
|
|
|
53
102
|
export declare function createCerebras(options?: CerebrasProviderSettings): CerebrasProvider;
|
|
54
103
|
export declare const cerebras: CerebrasProvider;
|
|
55
104
|
//#endregion
|
|
56
|
-
//#region src/cerebras-chat-language-model-options.d.ts
|
|
57
|
-
declare const cerebrasLanguageModelChatOptions: z.ZodObject<{
|
|
58
|
-
user: z.ZodOptional<z.ZodString>;
|
|
59
|
-
strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
|
|
60
|
-
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
-
logprobs: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
-
topLogprobs: z.ZodOptional<z.ZodNumber>;
|
|
63
|
-
logitBias: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
64
|
-
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
65
|
-
default: "default";
|
|
66
|
-
auto: "auto";
|
|
67
|
-
flex: "flex";
|
|
68
|
-
priority: "priority";
|
|
69
|
-
}>>;
|
|
70
|
-
queueThreshold: z.ZodOptional<z.ZodNumber>;
|
|
71
|
-
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
72
|
-
none: "none";
|
|
73
|
-
low: "low";
|
|
74
|
-
medium: "medium";
|
|
75
|
-
high: "high";
|
|
76
|
-
}>>;
|
|
77
|
-
reasoningFormat: z.ZodOptional<z.ZodEnum<{
|
|
78
|
-
none: "none";
|
|
79
|
-
parsed: "parsed";
|
|
80
|
-
text_parsed: "text_parsed";
|
|
81
|
-
raw: "raw";
|
|
82
|
-
hidden: "hidden";
|
|
83
|
-
}>>;
|
|
84
|
-
prediction: z.ZodOptional<z.ZodObject<{
|
|
85
|
-
type: z.ZodLiteral<"content">;
|
|
86
|
-
content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodObject<{
|
|
87
|
-
type: z.ZodLiteral<"text">;
|
|
88
|
-
text: z.ZodString;
|
|
89
|
-
}, z.core.$strip>>]>;
|
|
90
|
-
}, z.core.$strip>>;
|
|
91
|
-
promptCacheKey: z.ZodOptional<z.ZodString>;
|
|
92
|
-
}, z.core.$strip>;
|
|
93
|
-
type CerebrasLanguageModelChatOptions = z.infer<typeof cerebrasLanguageModelChatOptions>;
|
|
94
|
-
//#endregion
|
|
95
105
|
//#region src/version.d.ts
|
|
96
106
|
export declare const VERSION: string;
|
|
97
107
|
//#endregion
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/cerebras-chat-options.ts","../src/cerebras-
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/cerebras-chat-language-model-options.ts","../src/cerebras-model-catalog.ts","../src/cerebras-chat-options.ts","../src/cerebras-provider.ts","../src/version.ts"],"mappings":";;;;cAIa,kCAAgC,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwB3C,EAAA,KAAA;KAEU,mCAAmC,EAAE,aACxC;;;cCcH;EAAA;EAAA;;;KAgFM;EACV,uBAAuB;;;;KC3Hb,sBAAsB;;;cCmB5B,qBAAmB,EAAA;;;;;GAKvB,EAAA,KAAA;KAEU,oBAAoB,EAAE,aAAa;UAmE9B;;;;;EAKf,SAAS;;;;EAIT;;;;EAIA,UAAU;;;;;EAKV,QAAQ;;UAGO,yBAAyB;;;;GAIvC,SAAS,sBAAsB;;;;EAKhC,cAAc,SAAS,sBAAsB;;;;EAK7C,KAAK,SAAS,sBAAsB;;;;EAKpC,mBAAmB;;wBAGL,eACd,UAAS,2BACR;qBAoDU,UAAQ;;;qBC/LR"}
|
package/dist/index.js
CHANGED
|
@@ -115,7 +115,7 @@ var CerebrasChatLanguageModel = class CerebrasChatLanguageModel extends OpenAICo
|
|
|
115
115
|
};
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region src/version.ts
|
|
118
|
-
const VERSION = "3.0.
|
|
118
|
+
const VERSION = "3.0.94";
|
|
119
119
|
//#endregion
|
|
120
120
|
//#region src/cerebras-metadata-extractor.ts
|
|
121
121
|
const cerebrasMetadataExtractor = {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/cerebras-chat-language-model-options.ts","../src/cerebras-chat-language-model.ts","../src/version.ts","../src/cerebras-metadata-extractor.ts","../src/cerebras-model-catalog.ts","../src/cerebras-provider.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\nexport type { CerebrasChatModelId } from './cerebras-chat-options';\n\nexport const cerebrasLanguageModelChatOptions = z.object({\n user: z.string().optional(),\n strictJsonSchema: z.boolean().optional(),\n parallelToolCalls: z.boolean().optional(),\n logprobs: z.boolean().optional(),\n topLogprobs: z.number().int().min(0).max(20).optional(),\n logitBias: z.record(z.string(), z.number().min(-100).max(100)).optional(),\n serviceTier: z.enum(['auto', 'default', 'flex', 'priority']).optional(),\n /** Maximum queue time in milliseconds for flex/auto requests. */\n queueThreshold: z.number().int().min(50).max(20000).optional(),\n reasoningEffort: z.enum(['none', 'low', 'medium', 'high']).optional(),\n reasoningFormat: z\n .enum(['none', 'parsed', 'text_parsed', 'raw', 'hidden'])\n .optional(),\n prediction: z\n .object({\n type: z.literal('content'),\n content: z.union([\n z.string(),\n z.array(z.object({ type: z.literal('text'), text: z.string() })),\n ]),\n })\n .optional(),\n promptCacheKey: z.string().max(1024).optional(),\n});\n\nexport type CerebrasLanguageModelChatOptions = z.infer<\n typeof cerebrasLanguageModelChatOptions\n>;\n","import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport type {\n LanguageModelV4,\n LanguageModelV4CallOptions,\n LanguageModelV4GenerateResult,\n LanguageModelV4StreamPart,\n LanguageModelV4StreamResult,\n} from '@ai-sdk/provider';\nimport {\n normalizeHeaders,\n parseProviderOptions,\n serializeModelOptions,\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE,\n} from '@ai-sdk/provider-utils';\nimport {\n cerebrasLanguageModelChatOptions,\n type CerebrasChatModelId,\n} from './cerebras-chat-language-model-options';\n\ntype CerebrasChatConfig = ConstructorParameters<\n typeof OpenAICompatibleChatLanguageModel\n>[1];\n\nfunction isStructuredOutputWithToolCallsFinishReason({\n rawFinishReason,\n hasText,\n responseFormatType,\n}: {\n rawFinishReason: string | undefined;\n hasText: boolean;\n responseFormatType:\n | NonNullable<LanguageModelV4CallOptions['responseFormat']>['type']\n | undefined;\n}) {\n return (\n responseFormatType === 'json' && rawFinishReason === 'tool_calls' && hasText\n );\n}\n\nexport class CerebrasChatLanguageModel\n extends OpenAICompatibleChatLanguageModel\n implements LanguageModelV4\n{\n static [WORKFLOW_SERIALIZE](model: CerebrasChatLanguageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: CerebrasChatModelId;\n config: CerebrasChatConfig;\n }) {\n return new CerebrasChatLanguageModel(options.modelId, options.config);\n }\n\n async doGenerate(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4GenerateResult> {\n const result = await super.doGenerate(\n await this.applyQueueThresholdHeader(options),\n );\n\n if (\n !isStructuredOutputWithToolCallsFinishReason({\n rawFinishReason: result.finishReason.raw,\n hasText: result.content.some(\n part => part.type === 'text' && part.text.length > 0,\n ),\n responseFormatType: options.responseFormat?.type,\n })\n ) {\n return result;\n }\n\n return {\n ...result,\n // Cerebras GLM can return valid structured output text while also\n // repeating a tool call. Treat that mixed response as the final answer.\n content: result.content.filter(part => part.type !== 'tool-call'),\n finishReason: {\n ...result.finishReason,\n unified: 'stop',\n },\n };\n }\n\n async doStream(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4StreamResult> {\n const result = await super.doStream(\n await this.applyQueueThresholdHeader(options),\n );\n let hasText = false;\n\n return {\n ...result,\n stream: result.stream.pipeThrough(\n new TransformStream<\n LanguageModelV4StreamPart,\n LanguageModelV4StreamPart\n >({\n transform(part, controller) {\n if (part.type === 'text-delta' && part.delta.length > 0) {\n hasText = true;\n }\n\n if (\n part.type === 'finish' &&\n isStructuredOutputWithToolCallsFinishReason({\n rawFinishReason: part.finishReason.raw,\n hasText,\n responseFormatType: options.responseFormat?.type,\n })\n ) {\n controller.enqueue({\n ...part,\n finishReason: {\n ...part.finishReason,\n unified: 'stop',\n },\n });\n return;\n }\n\n if (\n options.responseFormat?.type === 'json' &&\n hasText &&\n (part.type === 'tool-input-start' ||\n part.type === 'tool-input-delta' ||\n part.type === 'tool-input-end' ||\n part.type === 'tool-call')\n ) {\n return;\n }\n\n controller.enqueue(part);\n },\n }),\n ),\n };\n }\n\n private async applyQueueThresholdHeader(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4CallOptions> {\n const cerebrasOptions = await parseProviderOptions({\n provider: 'cerebras',\n providerOptions: options.providerOptions,\n schema: cerebrasLanguageModelChatOptions.pick({ queueThreshold: true }),\n });\n\n if (cerebrasOptions?.queueThreshold == null) {\n return options;\n }\n\n return {\n ...options,\n headers: {\n ...normalizeHeaders(options.headers),\n queue_threshold: String(cerebrasOptions.queueThreshold),\n },\n };\n }\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 type { MetadataExtractor } from '@ai-sdk/openai-compatible';\nimport { safeValidateTypes } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const cerebrasMetadataExtractor: MetadataExtractor = {\n extractMetadata: async ({ parsedBody }) => {\n const parsed = await safeValidateTypes({\n value: parsedBody,\n schema: cerebrasServiceTierSchema,\n });\n\n if (!parsed.success) {\n return undefined;\n }\n\n const serviceTier = parsed.value.service_tier ?? undefined;\n\n return serviceTier != null ? { cerebras: { serviceTier } } : undefined;\n },\n\n createStreamExtractor: () => {\n let serviceTier: string | undefined;\n\n return {\n processChunk(parsedChunk) {\n serviceTier = getServiceTier(parsedChunk) ?? serviceTier;\n },\n\n buildMetadata() {\n return serviceTier != null ? { cerebras: { serviceTier } } : undefined;\n },\n };\n },\n};\n\nfunction getServiceTier(value: unknown): string | undefined {\n const parsed = cerebrasServiceTierSchema.safeParse(value);\n if (!parsed.success) {\n return undefined;\n }\n return parsed.data.service_tier ?? undefined;\n}\n\nconst cerebrasServiceTierSchema = z.looseObject({\n // The response tier may be absent or null when service-tier handling is not applied.\n service_tier: z.string().nullish(),\n});\n","import type {\n ModelCapabilities,\n ModelCapability,\n ModelEntry,\n ProviderOptionDefinition,\n ProviderOptionDefinitions,\n} from '@ai-sdk/provider';\nimport type { CerebrasLanguageModelChatOptions } from './cerebras-chat-language-model-options';\n\nexport const cerebrasProviderOptions = {\n language: {\n user: { description: 'End-user identifier for abuse monitoring.' },\n strictJsonSchema: { description: 'Use strict JSON schema validation.' },\n parallelToolCalls: { description: 'Allow parallel function calls.' },\n logprobs: { description: 'Return token log probabilities.' },\n topLogprobs: {\n description: 'Number of token log probabilities to return.',\n },\n logitBias: { description: 'Bias token selection by token ID.' },\n serviceTier: { description: 'Request processing tier.' },\n queueThreshold: { description: 'Maximum acceptable flex queue time.' },\n reasoningEffort: {\n description: 'Reasoning effort for configurable models.',\n },\n reasoningFormat: { description: 'Format of the returned reasoning.' },\n prediction: { description: 'Predicted output content.' },\n promptCacheKey: { description: 'Cache affinity key for shared prompts.' },\n } satisfies Record<\n keyof CerebrasLanguageModelChatOptions,\n ProviderOptionDefinition\n >,\n} as const satisfies ProviderOptionDefinitions;\n\ntype LanguageCapabilities = NonNullable<ModelCapabilities['language']> & {\n structuredOutput: { jsonSchema: boolean };\n};\n\ntype CerebrasLanguageModelEntry = ModelEntry & {\n capabilities: { language: LanguageCapabilities };\n providerOptions: {\n language: Record<keyof CerebrasLanguageModelChatOptions, ModelCapability>;\n };\n};\n\n// Preserve the provider page's model set and image-input exception.\nconst languageDefinitions: Record<string, boolean> = {\n 'gpt-oss-120b': false,\n 'gemma-4-31b': true,\n};\n\nfunction createLanguageModelEntry(image?: boolean): CerebrasLanguageModelEntry {\n const support = image != null ? true : 'unknown';\n const language: LanguageCapabilities = {\n inputs: { image: image ?? 'unknown', audio: false },\n objectGeneration: support,\n tools: { usage: support, streaming: support },\n reasoning: { support },\n sampling: { temperature: 'unknown', topP: 'unknown', logprobs: support },\n // Keep forwarding JSON schemas for custom IDs as the existing provider does.\n structuredOutput: { jsonSchema: true },\n };\n return {\n capabilities: { language },\n providerOptions: {\n language: declareProviderOptions(\n cerebrasProviderOptions.language,\n support,\n {\n strictJsonSchema: {\n condition: 'Requires a JSON schema response format.',\n },\n serviceTier: {\n condition: 'Requires a preview-enabled dedicated endpoint.',\n },\n queueThreshold: {\n condition:\n 'Requires flex/auto on a preview-enabled dedicated endpoint.',\n },\n reasoningEffort:\n image != null\n ? { condition: 'Supported values depend on the reasoning model.' }\n : 'unknown',\n reasoningFormat:\n image != null\n ? {\n condition: 'Available formats depend on the reasoning model.',\n }\n : 'unknown',\n },\n ),\n },\n };\n}\n\nexport const cerebrasModelCatalog: Readonly<\n Record<string, CerebrasLanguageModelEntry>\n> = Object.fromEntries(\n Object.entries(languageDefinitions).map(([modelId, image]) => [\n modelId,\n createLanguageModelEntry(image),\n ]),\n);\n\nexport function getCerebrasLanguageModelEntry(\n modelId: string,\n): CerebrasLanguageModelEntry {\n return Object.prototype.hasOwnProperty.call(cerebrasModelCatalog, modelId)\n ? cerebrasModelCatalog[modelId]\n : createLanguageModelEntry();\n}\n\nfunction declareProviderOptions<Option extends string>(\n definitions: Readonly<Record<Option, ProviderOptionDefinition>>,\n support: ModelCapability,\n exceptions: Partial<Record<Option, ModelCapability>>,\n): Record<Option, ModelCapability> {\n return Object.fromEntries(\n (Object.keys(definitions) as Option[]).map(option => [\n option,\n exceptions[option] ?? support,\n ]),\n ) as Record<Option, ModelCapability>;\n}\n","import type { ProviderErrorStructure } from '@ai-sdk/openai-compatible';\nimport {\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n type Resolvable,\n resolveWith,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { CerebrasChatLanguageModel } from './cerebras-chat-language-model';\nimport type { CerebrasChatModelId } from './cerebras-chat-options';\nimport { z } from 'zod/v4';\nimport { VERSION } from './version';\nimport { cerebrasMetadataExtractor } from './cerebras-metadata-extractor';\nimport { getCerebrasLanguageModelEntry } from './cerebras-model-catalog';\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\n/**\n * Cerebras expects assistant reasoning history in the `reasoning` field, while\n * the shared OpenAI-compatible converter serializes it as `reasoning_content`.\n */\nfunction transformCerebrasRequestBody(\n args: Record<string, any>,\n): Record<string, any> {\n const {\n max_tokens: maxTokens,\n parallelToolCalls,\n topLogprobs,\n logitBias,\n serviceTier,\n queueThreshold: _queueThreshold,\n reasoningFormat,\n promptCacheKey,\n ...restArgs\n } = args;\n\n return {\n ...restArgs,\n ...(maxTokens !== undefined && {\n max_completion_tokens: maxTokens,\n }),\n ...(parallelToolCalls !== undefined && {\n parallel_tool_calls: parallelToolCalls,\n }),\n ...(topLogprobs !== undefined && { top_logprobs: topLogprobs }),\n ...(logitBias !== undefined && { logit_bias: logitBias }),\n ...(serviceTier !== undefined && { service_tier: serviceTier }),\n ...(reasoningFormat !== undefined && {\n reasoning_format: reasoningFormat,\n }),\n ...(promptCacheKey !== undefined && {\n prompt_cache_key: promptCacheKey,\n }),\n messages: Array.isArray(args.messages)\n ? args.messages.map(message => {\n if (\n message == null ||\n typeof message !== 'object' ||\n message.role !== 'assistant' ||\n !('reasoning_content' in message)\n ) {\n return message;\n }\n\n const { reasoning_content, ...rest } = message;\n\n return {\n ...rest,\n ...(!('reasoning' in rest) && reasoning_content !== undefined\n ? { reasoning: reasoning_content }\n : {}),\n };\n })\n : args.messages,\n };\n}\n\nexport interface CerebrasProviderSettings {\n /**\n * Cerebras API key.\n * A function is called before each request and may return a promise.\n */\n apiKey?: Resolvable<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 resolveWith(options.apiKey, apiKey =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey,\n environmentVariableName: 'CEREBRAS_API_KEY',\n description: 'Cerebras API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk-cerebras/${VERSION}`,\n ),\n );\n\n const createLanguageModel = (modelId: CerebrasChatModelId) => {\n return new CerebrasChatLanguageModel(modelId, {\n provider: `cerebras.chat`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n errorStructure: cerebrasErrorStructure,\n supportsStructuredOutputs:\n getCerebrasLanguageModelEntry(modelId).capabilities.language\n .structuredOutput.jsonSchema,\n transformRequestBody: transformCerebrasRequestBody,\n metadataExtractor: cerebrasMetadataExtractor,\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"],"mappings":";;;;;AAIA,MAAa,mCAAmC,EAAE,OAAO;CACvD,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,kBAAkB,EAAE,QAAQ,CAAC,CAAC,SAAS;CACvC,mBAAmB,EAAE,QAAQ,CAAC,CAAC,SAAS;CACxC,UAAU,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC/B,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS;CACtD,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI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EACrB,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"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/cerebras-chat-language-model-options.ts","../src/cerebras-chat-language-model.ts","../src/version.ts","../src/cerebras-metadata-extractor.ts","../src/cerebras-model-catalog.ts","../src/cerebras-provider.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\nexport type { CerebrasChatModelId } from './cerebras-chat-options';\n\nexport const cerebrasLanguageModelChatOptions = z.object({\n user: z.string().optional(),\n strictJsonSchema: z.boolean().optional(),\n parallelToolCalls: z.boolean().optional(),\n logprobs: z.boolean().optional(),\n topLogprobs: z.number().int().min(0).max(20).optional(),\n logitBias: z.record(z.string(), z.number().min(-100).max(100)).optional(),\n serviceTier: z.enum(['auto', 'default', 'flex', 'priority']).optional(),\n /** Maximum queue time in milliseconds for flex/auto requests. */\n queueThreshold: z.number().int().min(50).max(20000).optional(),\n reasoningEffort: z.enum(['none', 'low', 'medium', 'high']).optional(),\n reasoningFormat: z\n .enum(['none', 'parsed', 'text_parsed', 'raw', 'hidden'])\n .optional(),\n prediction: z\n .object({\n type: z.literal('content'),\n content: z.union([\n z.string(),\n z.array(z.object({ type: z.literal('text'), text: z.string() })),\n ]),\n })\n .optional(),\n promptCacheKey: z.string().max(1024).optional(),\n});\n\nexport type CerebrasLanguageModelChatOptions = z.infer<\n typeof cerebrasLanguageModelChatOptions\n>;\n","import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';\nimport type {\n LanguageModelV4,\n LanguageModelV4CallOptions,\n LanguageModelV4GenerateResult,\n LanguageModelV4StreamPart,\n LanguageModelV4StreamResult,\n} from '@ai-sdk/provider';\nimport {\n normalizeHeaders,\n parseProviderOptions,\n serializeModelOptions,\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE,\n} from '@ai-sdk/provider-utils';\nimport {\n cerebrasLanguageModelChatOptions,\n type CerebrasChatModelId,\n} from './cerebras-chat-language-model-options';\n\ntype CerebrasChatConfig = ConstructorParameters<\n typeof OpenAICompatibleChatLanguageModel\n>[1];\n\nfunction isStructuredOutputWithToolCallsFinishReason({\n rawFinishReason,\n hasText,\n responseFormatType,\n}: {\n rawFinishReason: string | undefined;\n hasText: boolean;\n responseFormatType:\n | NonNullable<LanguageModelV4CallOptions['responseFormat']>['type']\n | undefined;\n}) {\n return (\n responseFormatType === 'json' && rawFinishReason === 'tool_calls' && hasText\n );\n}\n\nexport class CerebrasChatLanguageModel\n extends OpenAICompatibleChatLanguageModel\n implements LanguageModelV4\n{\n static [WORKFLOW_SERIALIZE](model: CerebrasChatLanguageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: CerebrasChatModelId;\n config: CerebrasChatConfig;\n }) {\n return new CerebrasChatLanguageModel(options.modelId, options.config);\n }\n\n async doGenerate(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4GenerateResult> {\n const result = await super.doGenerate(\n await this.applyQueueThresholdHeader(options),\n );\n\n if (\n !isStructuredOutputWithToolCallsFinishReason({\n rawFinishReason: result.finishReason.raw,\n hasText: result.content.some(\n part => part.type === 'text' && part.text.length > 0,\n ),\n responseFormatType: options.responseFormat?.type,\n })\n ) {\n return result;\n }\n\n return {\n ...result,\n // Cerebras GLM can return valid structured output text while also\n // repeating a tool call. Treat that mixed response as the final answer.\n content: result.content.filter(part => part.type !== 'tool-call'),\n finishReason: {\n ...result.finishReason,\n unified: 'stop',\n },\n };\n }\n\n async doStream(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4StreamResult> {\n const result = await super.doStream(\n await this.applyQueueThresholdHeader(options),\n );\n let hasText = false;\n\n return {\n ...result,\n stream: result.stream.pipeThrough(\n new TransformStream<\n LanguageModelV4StreamPart,\n LanguageModelV4StreamPart\n >({\n transform(part, controller) {\n if (part.type === 'text-delta' && part.delta.length > 0) {\n hasText = true;\n }\n\n if (\n part.type === 'finish' &&\n isStructuredOutputWithToolCallsFinishReason({\n rawFinishReason: part.finishReason.raw,\n hasText,\n responseFormatType: options.responseFormat?.type,\n })\n ) {\n controller.enqueue({\n ...part,\n finishReason: {\n ...part.finishReason,\n unified: 'stop',\n },\n });\n return;\n }\n\n if (\n options.responseFormat?.type === 'json' &&\n hasText &&\n (part.type === 'tool-input-start' ||\n part.type === 'tool-input-delta' ||\n part.type === 'tool-input-end' ||\n part.type === 'tool-call')\n ) {\n return;\n }\n\n controller.enqueue(part);\n },\n }),\n ),\n };\n }\n\n private async applyQueueThresholdHeader(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4CallOptions> {\n const cerebrasOptions = await parseProviderOptions({\n provider: 'cerebras',\n providerOptions: options.providerOptions,\n schema: cerebrasLanguageModelChatOptions.pick({ queueThreshold: true }),\n });\n\n if (cerebrasOptions?.queueThreshold == null) {\n return options;\n }\n\n return {\n ...options,\n headers: {\n ...normalizeHeaders(options.headers),\n queue_threshold: String(cerebrasOptions.queueThreshold),\n },\n };\n }\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 type { MetadataExtractor } from '@ai-sdk/openai-compatible';\nimport { safeValidateTypes } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const cerebrasMetadataExtractor: MetadataExtractor = {\n extractMetadata: async ({ parsedBody }) => {\n const parsed = await safeValidateTypes({\n value: parsedBody,\n schema: cerebrasServiceTierSchema,\n });\n\n if (!parsed.success) {\n return undefined;\n }\n\n const serviceTier = parsed.value.service_tier ?? undefined;\n\n return serviceTier != null ? { cerebras: { serviceTier } } : undefined;\n },\n\n createStreamExtractor: () => {\n let serviceTier: string | undefined;\n\n return {\n processChunk(parsedChunk) {\n serviceTier = getServiceTier(parsedChunk) ?? serviceTier;\n },\n\n buildMetadata() {\n return serviceTier != null ? { cerebras: { serviceTier } } : undefined;\n },\n };\n },\n};\n\nfunction getServiceTier(value: unknown): string | undefined {\n const parsed = cerebrasServiceTierSchema.safeParse(value);\n if (!parsed.success) {\n return undefined;\n }\n return parsed.data.service_tier ?? undefined;\n}\n\nconst cerebrasServiceTierSchema = z.looseObject({\n // The response tier may be absent or null when service-tier handling is not applied.\n service_tier: z.string().nullish(),\n});\n","import type {\n ModelCapabilities,\n ModelCapability,\n ModelEntry,\n ProviderOptionDefinition,\n ProviderOptionDefinitions,\n} from '@ai-sdk/provider';\nimport type { CerebrasLanguageModelChatOptions } from './cerebras-chat-language-model-options';\n\nexport const cerebrasProviderOptions = {\n language: {\n user: { description: 'End-user identifier for abuse monitoring.' },\n strictJsonSchema: { description: 'Use strict JSON schema validation.' },\n parallelToolCalls: { description: 'Allow parallel function calls.' },\n logprobs: { description: 'Return token log probabilities.' },\n topLogprobs: {\n description: 'Number of token log probabilities to return.',\n },\n logitBias: { description: 'Bias token selection by token ID.' },\n serviceTier: { description: 'Request processing tier.' },\n queueThreshold: { description: 'Maximum acceptable flex queue time.' },\n reasoningEffort: {\n description: 'Reasoning effort for configurable models.',\n },\n reasoningFormat: { description: 'Format of the returned reasoning.' },\n prediction: { description: 'Predicted output content.' },\n promptCacheKey: { description: 'Cache affinity key for shared prompts.' },\n } satisfies Record<\n keyof CerebrasLanguageModelChatOptions,\n ProviderOptionDefinition\n >,\n} as const satisfies ProviderOptionDefinitions;\n\ntype LanguageCapabilities = NonNullable<ModelCapabilities['language']> & {\n structuredOutput: { jsonSchema: boolean };\n};\n\ntype CerebrasLanguageModelEntry = ModelEntry & {\n capabilities: { language: LanguageCapabilities };\n providerOptions: {\n language: Record<keyof CerebrasLanguageModelChatOptions, ModelCapability>;\n };\n};\n\n// Preserve the provider page's model set and image-input exception.\nconst languageDefinitions = {\n 'gpt-oss-120b': false,\n 'gemma-4-31b': true,\n} satisfies Record<string, boolean>;\n\nfunction createLanguageModelEntry(image?: boolean): CerebrasLanguageModelEntry {\n const support = image != null ? true : 'unknown';\n const language: LanguageCapabilities = {\n inputs: { image: image ?? 'unknown', audio: false },\n objectGeneration: support,\n tools: { usage: support, streaming: support },\n reasoning: { support },\n sampling: { temperature: 'unknown', topP: 'unknown', logprobs: support },\n // Keep forwarding JSON schemas for custom IDs as the existing provider does.\n structuredOutput: { jsonSchema: true },\n };\n return {\n capabilities: { language },\n providerOptions: {\n language: declareProviderOptions(\n cerebrasProviderOptions.language,\n support,\n {\n strictJsonSchema: {\n condition: 'Requires a JSON schema response format.',\n },\n serviceTier: {\n condition: 'Requires a preview-enabled dedicated endpoint.',\n },\n queueThreshold: {\n condition:\n 'Requires flex/auto on a preview-enabled dedicated endpoint.',\n },\n reasoningEffort:\n image != null\n ? { condition: 'Supported values depend on the reasoning model.' }\n : 'unknown',\n reasoningFormat:\n image != null\n ? {\n condition: 'Available formats depend on the reasoning model.',\n }\n : 'unknown',\n },\n ),\n },\n };\n}\n\nexport const cerebrasModelCatalog: Readonly<\n Record<string, CerebrasLanguageModelEntry>\n> = Object.fromEntries(\n Object.entries(languageDefinitions).map(([modelId, image]) => [\n modelId,\n createLanguageModelEntry(image),\n ]),\n);\n\nexport function getCerebrasLanguageModelEntry(\n modelId: string,\n): CerebrasLanguageModelEntry {\n return Object.prototype.hasOwnProperty.call(cerebrasModelCatalog, modelId)\n ? cerebrasModelCatalog[modelId]\n : createLanguageModelEntry();\n}\n\nfunction declareProviderOptions<Option extends string>(\n definitions: Readonly<Record<Option, ProviderOptionDefinition>>,\n support: ModelCapability,\n exceptions: Partial<Record<Option, ModelCapability>>,\n): Record<Option, ModelCapability> {\n return Object.fromEntries(\n (Object.keys(definitions) as Option[]).map(option => [\n option,\n exceptions[option] ?? support,\n ]),\n ) as Record<Option, ModelCapability>;\n}\n\n/** Known model IDs, derived from the declarations used to build the catalog. */\nexport type CerebrasModelIds = {\n language: keyof typeof languageDefinitions;\n};\n","import type { ProviderErrorStructure } from '@ai-sdk/openai-compatible';\nimport {\n NoSuchModelError,\n type LanguageModelV4,\n type ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n type Resolvable,\n resolveWith,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { CerebrasChatLanguageModel } from './cerebras-chat-language-model';\nimport type { CerebrasChatModelId } from './cerebras-chat-options';\nimport { z } from 'zod/v4';\nimport { VERSION } from './version';\nimport { cerebrasMetadataExtractor } from './cerebras-metadata-extractor';\nimport { getCerebrasLanguageModelEntry } from './cerebras-model-catalog';\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\n/**\n * Cerebras expects assistant reasoning history in the `reasoning` field, while\n * the shared OpenAI-compatible converter serializes it as `reasoning_content`.\n */\nfunction transformCerebrasRequestBody(\n args: Record<string, any>,\n): Record<string, any> {\n const {\n max_tokens: maxTokens,\n parallelToolCalls,\n topLogprobs,\n logitBias,\n serviceTier,\n queueThreshold: _queueThreshold,\n reasoningFormat,\n promptCacheKey,\n ...restArgs\n } = args;\n\n return {\n ...restArgs,\n ...(maxTokens !== undefined && {\n max_completion_tokens: maxTokens,\n }),\n ...(parallelToolCalls !== undefined && {\n parallel_tool_calls: parallelToolCalls,\n }),\n ...(topLogprobs !== undefined && { top_logprobs: topLogprobs }),\n ...(logitBias !== undefined && { logit_bias: logitBias }),\n ...(serviceTier !== undefined && { service_tier: serviceTier }),\n ...(reasoningFormat !== undefined && {\n reasoning_format: reasoningFormat,\n }),\n ...(promptCacheKey !== undefined && {\n prompt_cache_key: promptCacheKey,\n }),\n messages: Array.isArray(args.messages)\n ? args.messages.map(message => {\n if (\n message == null ||\n typeof message !== 'object' ||\n message.role !== 'assistant' ||\n !('reasoning_content' in message)\n ) {\n return message;\n }\n\n const { reasoning_content, ...rest } = message;\n\n return {\n ...rest,\n ...(!('reasoning' in rest) && reasoning_content !== undefined\n ? { reasoning: reasoning_content }\n : {}),\n };\n })\n : args.messages,\n };\n}\n\nexport interface CerebrasProviderSettings {\n /**\n * Cerebras API key.\n * A function is called before each request and may return a promise.\n */\n apiKey?: Resolvable<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 resolveWith(options.apiKey, apiKey =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey,\n environmentVariableName: 'CEREBRAS_API_KEY',\n description: 'Cerebras API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk-cerebras/${VERSION}`,\n ),\n );\n\n const createLanguageModel = (modelId: CerebrasChatModelId) => {\n return new CerebrasChatLanguageModel(modelId, {\n provider: `cerebras.chat`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n errorStructure: cerebrasErrorStructure,\n supportsStructuredOutputs:\n getCerebrasLanguageModelEntry(modelId).capabilities.language\n .structuredOutput.jsonSchema,\n transformRequestBody: transformCerebrasRequestBody,\n metadataExtractor: cerebrasMetadataExtractor,\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"],"mappings":";;;;;AAIA,MAAa,mCAAmC,EAAE,OAAO;CACvD,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS;CAC1B,kBAAkB,EAAE,QAAQ,CAAC,CAAC,SAAS;CACvC,mBAAmB,EAAE,QAAQ,CAAC,CAAC,SAAS;CACxC,UAAU,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC/B,aAAa,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS;CACtD,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,SAAS;CACxE,aAAa,EAAE,KAAK;EAAC;EAAQ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BAAgB;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/cerebras",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.94",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/openai-compatible": "3.0.
|
|
33
|
-
"@ai-sdk/provider": "4.0.
|
|
34
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
32
|
+
"@ai-sdk/openai-compatible": "3.0.93",
|
|
33
|
+
"@ai-sdk/provider": "4.0.39",
|
|
34
|
+
"@ai-sdk/provider-utils": "5.0.82"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "22.19.19",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import type { CerebrasModelIds } from './cerebras-model-catalog';
|
|
2
|
+
|
|
1
3
|
// https://inference-docs.cerebras.ai/models/overview
|
|
2
|
-
export type CerebrasChatModelId =
|
|
3
|
-
// production
|
|
4
|
-
'gpt-oss-120b' | 'gemma-4-31b' | (string & {});
|
|
4
|
+
export type CerebrasChatModelId = CerebrasModelIds['language'] | (string & {});
|
|
@@ -43,10 +43,10 @@ type CerebrasLanguageModelEntry = ModelEntry & {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
// Preserve the provider page's model set and image-input exception.
|
|
46
|
-
const languageDefinitions
|
|
46
|
+
const languageDefinitions = {
|
|
47
47
|
'gpt-oss-120b': false,
|
|
48
48
|
'gemma-4-31b': true,
|
|
49
|
-
}
|
|
49
|
+
} satisfies Record<string, boolean>;
|
|
50
50
|
|
|
51
51
|
function createLanguageModelEntry(image?: boolean): CerebrasLanguageModelEntry {
|
|
52
52
|
const support = image != null ? true : 'unknown';
|
|
@@ -121,3 +121,8 @@ function declareProviderOptions<Option extends string>(
|
|
|
121
121
|
]),
|
|
122
122
|
) as Record<Option, ModelCapability>;
|
|
123
123
|
}
|
|
124
|
+
|
|
125
|
+
/** Known model IDs, derived from the declarations used to build the catalog. */
|
|
126
|
+
export type CerebrasModelIds = {
|
|
127
|
+
language: keyof typeof languageDefinitions;
|
|
128
|
+
};
|