@ai-sdk/fireworks 3.0.66 → 3.0.67
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 +22 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/docs/26-fireworks.mdx +7 -0
- package/package.json +6 -6
- package/src/fireworks-provider.ts +18 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @ai-sdk/fireworks
|
|
2
2
|
|
|
3
|
+
## 3.0.67
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 268225c: feat(provider): add a portable `max` reasoning level with native provider mappings, compatibility coercions, and budget-based fallback support.
|
|
8
|
+
|
|
9
|
+
Compatibility notes:
|
|
10
|
+
|
|
11
|
+
- **TypeScript source compatibility:** Adding `max` widens `LanguageModelV4CallOptions['reasoning']` and the derived `ReasoningLevel` type. Third-party providers and consumers with exhaustive switches or `Record<ReasoningLevel, ...>` mappings must handle `max` before upgrading. Ordinary calls using existing reasoning levels remain accepted.
|
|
12
|
+
- **Amazon Bedrock:** Existing Nova 2 calls using portable `reasoning: 'xhigh'` now send `maxReasoningEffort: 'high'` instead of the unsupported `'max'`, and return a compatibility warning. Anthropic and OpenAI Bedrock effort mappings retain their existing `xhigh` behavior. Partial Bedrock reasoning configurations continue to preserve explicit values and derive missing fields; explicit effort/budget overrides and disabled thinking no longer emit warnings for portable mappings that are not sent.
|
|
13
|
+
- **Fireworks:** Existing portable `minimal` and `xhigh` calls keep their request mappings to `low` and `high`, respectively, and now return compatibility warnings in generation and streaming results. Portable `max` maps to `high` with the same warning behavior.
|
|
14
|
+
|
|
15
|
+
**Release classification:** This remains a patch changeset under the repository's explicit release policy, which uses patch releases for both fixes and features. The TypeScript source-compatibility caveat for exhaustive consumers is disclosed above. Maintainers can override this classification with a `major` label if they decide to align the provider-spec addition with a future AI SDK major release.
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [fc1e19e]
|
|
18
|
+
- Updated dependencies [5094ebd]
|
|
19
|
+
- Updated dependencies [268225c]
|
|
20
|
+
- Updated dependencies [0af2f7c]
|
|
21
|
+
- @ai-sdk/provider-utils@5.0.55
|
|
22
|
+
- @ai-sdk/provider@4.0.23
|
|
23
|
+
- @ai-sdk/openai-compatible@3.0.64
|
|
24
|
+
|
|
3
25
|
## 3.0.66
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/fireworks-chat-options.ts","../src/fireworks-embedding-options.ts","../src/fireworks-image-options.ts","../src/fireworks-image-model.ts","../src/fireworks-image-model-options.ts","../src/fireworks-completion-options.ts","../src/fireworks-provider.ts","../src/version.ts"],"mappings":";;;;KAIY;cAsBC,+BAA6B,EAAA;;;;;;;;;;;;;;;;;GAoBxC,EAAA,KAAA;KAEU,gCAAgC,EAAE,aACrC;;;KC9CG;cAIC,gCAA8B,EAAA,cAAA,EAAA,KAAA;KAE/B,iCAAiC,EAAE,aACtC;;;KCTG;;;UC8FF;EACR;EACA;EACA,gBAAgB;EAChB,QAAQ;;;;;EAKR;;;;;EAKA;EACA;IACE,oBAAoB;;;qBAIX,+BAA+B;WAgD/B,SAAS;UACV;WAhDD;WACA;MAEL;MAqBA;MAIA;UAII,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;EAKU,YAAA,SAAS,uBACV,QAAQ;EAGZ,aACJ,QACA,GACA,MACA,aACA,MACA,iBACA,SACA,aACA,OACA,QACC,WAAW,iCAAiC,QAC7C,QAAQ,WAAW;;;;;UA2GP;;;;UAkEA;;;;cCzVH,mEAAgC;;;;;;;;;;;;KAmDjC,6BAA6B,mBAChC;;;KC1DG;;;KCyBA,qBAAqB,EAAE,aAAa;cAE1C,sBAAoB,EAAA;;;;;;;;GAWxB,EAAA,KAAA;UAQe;;;;;EAKf;;;;EAIA;;;;EAIA,UAAU;;;;;EAKV,QAAQ;;UAGO,0BAA0B;;;;GAIxC,SAAS,uBAAuB;;;;EAKjC,UAAU,SAAS,uBAAuB;;;;EAK1C,gBAAgB,SAAS,6BAA6B;;;;EAKtD,cAAc,SAAS,uBAAuB;;;;EAK9C,eAAe,SAAS,4BAA4B;;;;EAKpD,mBAAmB,SAAS,4BAA4B;;;;EAKxD,MAAM,SAAS,wBAAwB;;;;EAKvC,WAAW,SAAS,wBAAwB;;wBAK9B,gBACd,UAAS,4BACR;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/fireworks-chat-options.ts","../src/fireworks-embedding-options.ts","../src/fireworks-image-options.ts","../src/fireworks-image-model.ts","../src/fireworks-image-model-options.ts","../src/fireworks-completion-options.ts","../src/fireworks-provider.ts","../src/version.ts"],"mappings":";;;;KAIY;cAsBC,+BAA6B,EAAA;;;;;;;;;;;;;;;;;GAoBxC,EAAA,KAAA;KAEU,gCAAgC,EAAE,aACrC;;;KC9CG;cAIC,gCAA8B,EAAA,cAAA,EAAA,KAAA;KAE/B,iCAAiC,EAAE,aACtC;;;KCTG;;;UC8FF;EACR;EACA;EACA,gBAAgB;EAChB,QAAQ;;;;;EAKR;;;;;EAKA;EACA;IACE,oBAAoB;;;qBAIX,+BAA+B;WAgD/B,SAAS;UACV;WAhDD;WACA;MAEL;MAqBA;MAIA;UAII,oBAAoB,OAAO;;;;UAO3B,sBAAsB;IAC5B,SAAS;IACT,QAAQ;MACT;EAKU,YAAA,SAAS,uBACV,QAAQ;EAGZ,aACJ,QACA,GACA,MACA,aACA,MACA,iBACA,SACA,aACA,OACA,QACC,WAAW,iCAAiC,QAC7C,QAAQ,WAAW;;;;;UA2GP;;;;UAkEA;;;;cCzVH,mEAAgC;;;;;;;;;;;;KAmDjC,6BAA6B,mBAChC;;;KC1DG;;;KCyBA,qBAAqB,EAAE,aAAa;cAE1C,sBAAoB,EAAA;;;;;;;;GAWxB,EAAA,KAAA;UAQe;;;;;EAKf;;;;EAIA;;;;EAIA,UAAU;;;;;EAKV,QAAQ;;UAGO,0BAA0B;;;;GAIxC,SAAS,uBAAuB;;;;EAKjC,UAAU,SAAS,uBAAuB;;;;EAK1C,gBAAgB,SAAS,6BAA6B;;;;EAKtD,cAAc,SAAS,uBAAuB;;;;EAK9C,eAAe,SAAS,4BAA4B;;;;EAKpD,mBAAmB,SAAS,4BAA4B;;;;EAKxD,MAAM,SAAS,wBAAwB;;;;EAKvC,WAAW,SAAS,wBAAwB;;wBAK9B,gBACd,UAAS,4BACR;qBA+HU,WAAS;;;qBC/OT"}
|
package/dist/index.js
CHANGED
|
@@ -286,7 +286,7 @@ var FireworksImageModel = class FireworksImageModel {
|
|
|
286
286
|
};
|
|
287
287
|
//#endregion
|
|
288
288
|
//#region src/version.ts
|
|
289
|
-
const VERSION = "3.0.
|
|
289
|
+
const VERSION = "3.0.67";
|
|
290
290
|
//#endregion
|
|
291
291
|
//#region src/fireworks-provider.ts
|
|
292
292
|
const fireworksErrorStructure = {
|
|
@@ -322,15 +322,21 @@ function createFireworks(options = {}) {
|
|
|
322
322
|
includeUsage: true,
|
|
323
323
|
errorStructure: fireworksErrorStructure,
|
|
324
324
|
supportsStructuredOutputs: true,
|
|
325
|
-
transformRequestBody: (args) => {
|
|
325
|
+
transformRequestBody: (args, warnings) => {
|
|
326
326
|
const thinking = args.thinking;
|
|
327
327
|
const reasoningHistory = args.reasoningHistory;
|
|
328
328
|
const promptCacheKey = args.promptCacheKey;
|
|
329
329
|
const serviceTier = args.serviceTier;
|
|
330
330
|
const { thinking: _, reasoningHistory: __, promptCacheKey: ___, serviceTier: ____, reasoning_effort, ...rest } = args;
|
|
331
|
+
const mappedReasoningEffort = reasoning_effort === "minimal" ? "low" : reasoning_effort === "xhigh" || reasoning_effort === "max" ? "high" : reasoning_effort;
|
|
332
|
+
if (mappedReasoningEffort !== reasoning_effort) warnings?.push({
|
|
333
|
+
type: "compatibility",
|
|
334
|
+
feature: "reasoning",
|
|
335
|
+
details: `reasoning "${reasoning_effort}" is not directly supported by this model. mapped to effort "${mappedReasoningEffort}".`
|
|
336
|
+
});
|
|
331
337
|
return {
|
|
332
338
|
...rest,
|
|
333
|
-
...reasoning_effort != null && { reasoning_effort:
|
|
339
|
+
...reasoning_effort != null && { reasoning_effort: mappedReasoningEffort },
|
|
334
340
|
...promptCacheKey !== void 0 && { prompt_cache_key: promptCacheKey },
|
|
335
341
|
...serviceTier !== void 0 && { service_tier: serviceTier },
|
|
336
342
|
...thinking && { thinking: {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/fireworks-image-api.ts","../src/fireworks-image-model-options.ts","../src/fireworks-image-model.ts","../src/version.ts","../src/fireworks-provider.ts"],"sourcesContent":["import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// Schema for async submit response\nexport const asyncSubmitResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n request_id: z.string(),\n }),\n ),\n);\n\n// Schema for async poll response\nexport const asyncPollResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string(),\n status: z.string(),\n result: z\n .object({\n sample: z.string().optional(),\n })\n .nullable(),\n }),\n ),\n);\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const fireworksImageModelOptionsSchema = lazySchema(() =>\n zodSchema(\n z.looseObject({\n /**\n * Classifier-free guidance scale for the image diffusion process.\n */\n guidance_scale: z.number().optional(),\n\n /**\n * Number of denoising steps for the image generation process.\n */\n num_inference_steps: z.number().int().optional(),\n\n /**\n * Desired output image format.\n */\n output_format: z.enum(['jpeg', 'png']).optional(),\n\n /**\n * URL to receive webhook notifications for async Kontext requests.\n */\n webhook_url: z.string().optional(),\n\n /**\n * Secret for webhook signature verification.\n */\n webhook_secret: z.string().optional(),\n\n /**\n * Whether Fireworks should automatically modify the prompt for more creative generation.\n */\n prompt_upsampling: z.boolean().optional(),\n\n /**\n * Moderation tolerance level for inputs and outputs.\n */\n safety_tolerance: z.number().int().min(0).max(6).optional(),\n\n /**\n * Guidance scale for legacy image_generation models.\n */\n cfg_scale: z.number().optional(),\n\n /**\n * Number of generation steps for legacy image_generation models.\n */\n steps: z.number().int().optional(),\n }),\n ),\n);\n\nexport type FireworksImageModelOptions = InferSchema<\n typeof fireworksImageModelOptionsSchema\n>;\n","import type { ImageModelV4, SharedV4Warning } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertImageModelFileToDataUri,\n createBinaryResponseHandler,\n createJsonResponseHandler,\n createStatusCodeErrorResponseHandler,\n delay,\n getFromApi,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport {\n asyncPollResponseSchema,\n asyncSubmitResponseSchema,\n} from './fireworks-image-api';\nimport { fireworksImageModelOptionsSchema } from './fireworks-image-model-options';\nimport type { FireworksImageModelId } from './fireworks-image-options';\n\nconst DEFAULT_POLL_INTERVAL_MILLIS = 500;\nconst DEFAULT_POLL_TIMEOUT_MILLIS = 120000; // 2 minutes for image generation\n\ninterface FireworksImageModelBackendConfig {\n urlFormat: 'workflows' | 'workflows_async' | 'image_generation';\n supportsSize?: boolean;\n supportsEditing?: boolean;\n}\n\nconst modelToBackendConfig: Partial<\n Record<FireworksImageModelId, FireworksImageModelBackendConfig>\n> = {\n 'accounts/fireworks/models/flux-1-dev-fp8': {\n urlFormat: 'workflows',\n },\n 'accounts/fireworks/models/flux-1-schnell-fp8': {\n urlFormat: 'workflows',\n },\n 'accounts/fireworks/models/flux-kontext-pro': {\n urlFormat: 'workflows_async',\n supportsEditing: true,\n },\n 'accounts/fireworks/models/flux-kontext-max': {\n urlFormat: 'workflows_async',\n supportsEditing: true,\n },\n 'accounts/fireworks/models/playground-v2-5-1024px-aesthetic': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/japanese-stable-diffusion-xl': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/playground-v2-1024px-aesthetic': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/stable-diffusion-xl-1024-v1-0': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/SSD-1B': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n};\n\nfunction getUrlForModel(\n baseUrl: string,\n modelId: FireworksImageModelId,\n): string {\n const config = modelToBackendConfig[modelId];\n\n switch (config?.urlFormat) {\n case 'image_generation':\n return `${baseUrl}/image_generation/${modelId}`;\n case 'workflows_async':\n return `${baseUrl}/workflows/${modelId}`;\n case 'workflows':\n default:\n return `${baseUrl}/workflows/${modelId}/text_to_image`;\n }\n}\n\nfunction getPollUrlForModel(\n baseUrl: string,\n modelId: FireworksImageModelId,\n): string {\n return `${baseUrl}/workflows/${modelId}/get_result`;\n}\n\ninterface FireworksImageModelConfig {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string>;\n fetch?: FetchFunction;\n /**\n * Poll interval in milliseconds between status checks for async models.\n * Defaults to 500ms.\n */\n pollIntervalMillis?: number;\n /**\n * Overall timeout in milliseconds for polling before giving up.\n * Defaults to 120000ms (2 minutes).\n */\n pollTimeoutMillis?: number;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class FireworksImageModel implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly maxImagesPerCall = 1;\n\n get supportsFileInputs(): boolean | undefined {\n if (\n this.modelId === 'accounts/fireworks/models/flux-kontext-pro' ||\n this.modelId === 'accounts/fireworks/models/flux-kontext-max'\n ) {\n return true;\n }\n\n return [\n 'accounts/fireworks/models/flux-1-dev-fp8',\n 'accounts/fireworks/models/flux-1-schnell-fp8',\n 'accounts/fireworks/models/playground-v2-5-1024px-aesthetic',\n 'accounts/fireworks/models/japanese-stable-diffusion-xl',\n 'accounts/fireworks/models/playground-v2-1024px-aesthetic',\n 'accounts/fireworks/models/SSD-1B',\n 'accounts/fireworks/models/stable-diffusion-xl-1024-v1-0',\n ].includes(this.modelId)\n ? false\n : undefined;\n }\n\n get supportsMaskInputs(): boolean | undefined {\n return this.supportsFileInputs == null ? undefined : false;\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: FireworksImageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: FireworksImageModelId;\n config: FireworksImageModelConfig;\n }) {\n return new FireworksImageModel(options.modelId, options.config);\n }\n\n constructor(\n readonly modelId: FireworksImageModelId,\n private config: FireworksImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n n,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n files,\n mask,\n }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV4['doGenerate']>>\n > {\n const warnings: Array<SharedV4Warning> = [];\n\n const backendConfig = modelToBackendConfig[this.modelId];\n if (!backendConfig?.supportsSize && size != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n // Use supportsSize as a proxy for whether the model does not support\n // aspectRatio. This invariant holds for the current set of models.\n if (backendConfig?.supportsSize && aspectRatio != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details: 'This model does not support the `aspectRatio` option.',\n });\n }\n\n // Handle files for image editing\n const hasInputImage = files != null && files.length > 0;\n let inputImage: string | undefined;\n\n if (hasInputImage) {\n inputImage = convertImageModelFileToDataUri(files[0]);\n\n if (files.length > 1) {\n warnings.push({\n type: 'other',\n message:\n 'Fireworks only supports a single input image. Additional images are ignored.',\n });\n }\n }\n\n // Warn about mask - Fireworks Kontext models don't support explicit masks\n if (mask != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'mask',\n details:\n 'Fireworks Kontext models do not support explicit masks. Use the prompt to describe the areas to edit.',\n });\n }\n\n const splitSize = size?.split('x');\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const combinedHeaders = combineHeaders(this.config.headers?.(), headers);\n const fireworksOptions =\n (await parseProviderOptions({\n provider: 'fireworks',\n providerOptions,\n schema: fireworksImageModelOptionsSchema,\n })) ?? {};\n\n const body = {\n prompt,\n aspect_ratio: aspectRatio,\n seed,\n samples: n,\n ...(inputImage && { input_image: inputImage }),\n ...(splitSize && { width: splitSize[0], height: splitSize[1] }),\n ...fireworksOptions,\n };\n\n // Handle async models that require polling (e.g., flux-kontext-*)\n if (backendConfig?.urlFormat === 'workflows_async') {\n return this.doGenerateAsync({\n body,\n headers: combinedHeaders,\n abortSignal,\n warnings,\n currentDate,\n });\n }\n\n // Handle sync models that return binary directly\n const { value: response, responseHeaders } = await postJsonToApi({\n url: getUrlForModel(this.config.baseURL, this.modelId),\n headers: combinedHeaders,\n body,\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: [response],\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n\n /**\n * Handles async image generation for models like flux-kontext-* that return\n * a request_id and require polling for results.\n */\n private async doGenerateAsync({\n body,\n headers,\n abortSignal,\n warnings,\n currentDate,\n }: {\n body: Record<string, unknown>;\n headers: Record<string, string | undefined>;\n abortSignal: AbortSignal | undefined;\n warnings: Array<SharedV4Warning>;\n currentDate: Date;\n }): Promise<Awaited<ReturnType<ImageModelV4['doGenerate']>>> {\n // Submit the generation request\n const { value: submitResponse } = await postJsonToApi({\n url: getUrlForModel(this.config.baseURL, this.modelId),\n headers,\n body,\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n asyncSubmitResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n const requestId = submitResponse.request_id;\n\n // Poll for the result\n const imageUrl = await this.pollForImageUrl({\n requestId,\n headers,\n abortSignal,\n });\n\n // Download the image from the URL. The URL comes from the provider\n // response and typically points at a CDN, so only send credentials when it\n // stays on the provider's own origin (never leak the API key to a CDN or an\n // attacker-named host).\n const { value: imageBytes, responseHeaders } = await getFromApi({\n url: imageUrl,\n // imageUrl comes from the provider response body.\n validateUrl: true,\n credentialedOrigin: this.config.baseURL,\n trustedOrigin: this.config.baseURL,\n headers,\n abortSignal,\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n fetch: this.config.fetch,\n });\n\n return {\n images: [imageBytes],\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n\n /**\n * Polls the get_result endpoint until the image is ready.\n */\n private async pollForImageUrl({\n requestId,\n headers,\n abortSignal,\n }: {\n requestId: string;\n headers: Record<string, string | undefined>;\n abortSignal: AbortSignal | undefined;\n }): Promise<string> {\n const pollIntervalMillis =\n this.config.pollIntervalMillis ?? DEFAULT_POLL_INTERVAL_MILLIS;\n const pollTimeoutMillis =\n this.config.pollTimeoutMillis ?? DEFAULT_POLL_TIMEOUT_MILLIS;\n\n const pollUrl = getPollUrlForModel(this.config.baseURL, this.modelId);\n\n const timeoutController = new AbortController();\n let didTimeout = false;\n const timeoutId = setTimeout(() => {\n didTimeout = true;\n timeoutController.abort();\n }, pollTimeoutMillis);\n const pollingAbortSignal =\n abortSignal == null\n ? timeoutController.signal\n : AbortSignal.any([abortSignal, timeoutController.signal]);\n\n try {\n while (true) {\n const { value: pollResponse } = await postJsonToApi({\n url: pollUrl,\n headers,\n body: { id: requestId },\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n asyncPollResponseSchema,\n ),\n abortSignal: pollingAbortSignal,\n fetch: this.config.fetch,\n });\n\n const status = pollResponse.status;\n\n if (status === 'Ready') {\n const imageUrl = pollResponse.result?.sample;\n if (typeof imageUrl === 'string') {\n return imageUrl;\n }\n throw new Error(\n 'Fireworks poll response is Ready but missing result.sample',\n );\n }\n\n if (status === 'Error' || status === 'Failed') {\n throw new Error(\n `Fireworks image generation failed with status: ${status}`,\n );\n }\n\n // Wait before next poll attempt\n await delay(pollIntervalMillis, {\n abortSignal: pollingAbortSignal,\n });\n }\n } catch (error) {\n if (didTimeout) {\n throw new Error(\n `Fireworks image generation timed out after ${pollTimeoutMillis}ms`,\n );\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\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 {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n type ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport type {\n EmbeddingModelV4,\n ImageModelV4,\n LanguageModelV4,\n ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { FireworksChatModelId } from './fireworks-chat-options';\nimport type { FireworksCompletionModelId } from './fireworks-completion-options';\nimport type { FireworksEmbeddingModelId } from './fireworks-embedding-options';\nimport { FireworksImageModel } from './fireworks-image-model';\nimport type { FireworksImageModelId } from './fireworks-image-options';\nimport { VERSION } from './version';\n\nexport type FireworksErrorData = z.infer<typeof fireworksErrorSchema>;\n\nconst fireworksErrorSchema = z.object({\n error: z.union([\n z.string(),\n z.object({\n message: z.string(),\n object: z.string().nullish(),\n type: z.string().nullish(),\n param: z.any().nullish(),\n code: z.union([z.string(), z.number()]).nullish(),\n }),\n ]),\n});\n\nconst fireworksErrorStructure: ProviderErrorStructure<FireworksErrorData> = {\n errorSchema: fireworksErrorSchema,\n errorToMessage: data =>\n typeof data.error === 'string' ? data.error : data.error.message,\n};\n\nexport interface FireworksProviderSettings {\n /**\n * Fireworks API key. Default value is taken from the `FIREWORKS_API_KEY`\n * environment variable.\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 FireworksProvider extends ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: FireworksChatModelId): LanguageModelV4;\n\n /**\n * Creates a chat model for text generation.\n */\n chatModel(modelId: FireworksChatModelId): LanguageModelV4;\n\n /**\n * Creates a completion model for text generation.\n */\n completionModel(modelId: FireworksCompletionModelId): LanguageModelV4;\n\n /**\n * Creates a chat model for text generation.\n */\n languageModel(modelId: FireworksChatModelId): LanguageModelV4;\n\n /**\n * Creates a text embedding model for text generation.\n */\n embeddingModel(modelId: FireworksEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: FireworksEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * Creates a model for image generation.\n */\n image(modelId: FireworksImageModelId): ImageModelV4;\n\n /**\n * Creates a model for image generation.\n */\n imageModel(modelId: FireworksImageModelId): ImageModelV4;\n}\n\nconst defaultBaseURL = 'https://api.fireworks.ai/inference/v1';\n\nexport function createFireworks(\n options: FireworksProviderSettings = {},\n): FireworksProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'FIREWORKS_API_KEY',\n description: 'Fireworks API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk-fireworks/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (modelType: string): CommonModelConfig => ({\n provider: `fireworks.${modelType}`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId: FireworksChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n ...getCommonModelConfig('chat'),\n includeUsage: true,\n errorStructure: fireworksErrorStructure,\n supportsStructuredOutputs: true,\n transformRequestBody: args => {\n const thinking = args.thinking as\n | { type?: string; budgetTokens?: number }\n | undefined;\n const reasoningHistory = args.reasoningHistory as string | undefined;\n const promptCacheKey = args.promptCacheKey as string | undefined;\n const serviceTier = args.serviceTier as string | undefined;\n\n const {\n thinking: _,\n reasoningHistory: __,\n promptCacheKey: ___,\n serviceTier: ____,\n reasoning_effort,\n ...rest\n } = args;\n\n return {\n ...rest,\n ...(reasoning_effort != null && {\n // Workaround since OpenAI spec allows for 5 reasoning levels, but Fireworks only supports 3 of them.\n reasoning_effort:\n reasoning_effort === 'minimal'\n ? 'low'\n : reasoning_effort === 'xhigh'\n ? 'high'\n : reasoning_effort,\n }),\n ...(promptCacheKey !== undefined && {\n prompt_cache_key: promptCacheKey,\n }),\n ...(serviceTier !== undefined && {\n service_tier: serviceTier,\n }),\n ...(thinking && {\n thinking: {\n type: thinking.type,\n ...(thinking.budgetTokens !== undefined && {\n budget_tokens: thinking.budgetTokens,\n }),\n },\n }),\n ...(reasoningHistory && {\n reasoning_history: reasoningHistory,\n }),\n };\n },\n });\n };\n\n const createCompletionModel = (modelId: FireworksCompletionModelId) =>\n new OpenAICompatibleCompletionLanguageModel(modelId, {\n ...getCommonModelConfig('completion'),\n includeUsage: true,\n errorStructure: fireworksErrorStructure,\n });\n\n const createEmbeddingModel = (modelId: FireworksEmbeddingModelId) =>\n new OpenAICompatibleEmbeddingModel(modelId, {\n ...getCommonModelConfig('embedding'),\n errorStructure: fireworksErrorStructure,\n });\n\n const createImageModel = (modelId: FireworksImageModelId) =>\n new FireworksImageModel(modelId, {\n ...getCommonModelConfig('image'),\n baseURL: baseURL ?? defaultBaseURL,\n });\n\n const provider = (modelId: FireworksChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n return provider;\n}\n\nexport const fireworks = createFireworks();\n"],"mappings":";;;;AAIA,MAAa,4BAA4B,iBACvC,UACE,EAAE,OAAO,EACP,YAAY,EAAE,OAAO,EACvB,CAAC,CACH,CACF;AAGA,MAAa,0BAA0B,iBACrC,UACE,EAAE,OAAO;CACP,IAAI,EAAE,OAAO;CACb,QAAQ,EAAE,OAAO;CACjB,QAAQ,EACL,OAAO,EACN,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS,EAC9B,CAAC,CAAC,CACD,SAAS;AACd,CAAC,CACH,CACF;;;AClBA,MAAa,mCAAmC,iBAC9C,UACE,EAAE,YAAY;;;;CAIZ,gBAAgB,EAAE,OAAO,CAAC,CAAC,SAAS;;;;CAKpC,qBAAqB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;;;;CAK/C,eAAe,EAAE,KAAK,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,SAAS;;;;CAKhD,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;;;;CAKjC,gBAAgB,EAAE,OAAO,CAAC,CAAC,SAAS;;;;CAKpC,mBAAmB,EAAE,QAAQ,CAAC,CAAC,SAAS;;;;CAKxC,kBAAkB,EAAE,OAAO,CAAC,CAAC,IAA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ACzC,eAAe,SAAS,aAC1B;KACF,EACF;KACA,GAAI,oBAAoB,EACtB,mBAAmB,iBACrB;IACF;GACF;EACF,CAAC;CACH;CAEA,MAAM,yBAAyB,YAC7B,IAAI,wCAAwC,SAAS;EACnD,GAAG,qBAAqB,YAAY;EACpC,cAAc;EACd,gBAAgB;CAClB,CAAC;CAEH,MAAM,wBAAwB,YAC5B,IAAI,+BAA+B,SAAS;EAC1C,GAAG,qBAAqB,WAAW;EACnC,gBAAgB;CAClB,CAAC;CAEH,MAAM,oBAAoB,YACxB,IAAI,oBAAoB,SAAS;EAC/B,GAAG,qBAAqB,OAAO;EAC/B,SAAS,WAAW;CACtB,CAAC;CAEH,MAAM,YAAY,YAAkC,gBAAgB,OAAO;CAE3E,SAAS,uBAAuB;CAChC,SAAS,kBAAkB;CAC3B,SAAS,YAAY;CACrB,SAAS,gBAAgB;CACzB,SAAS,iBAAiB;CAC1B,SAAS,qBAAqB;CAC9B,SAAS,QAAQ;CACjB,SAAS,aAAa;CACtB,OAAO;AACT;AAEA,MAAa,YAAY,gBAAgB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/fireworks-image-api.ts","../src/fireworks-image-model-options.ts","../src/fireworks-image-model.ts","../src/version.ts","../src/fireworks-provider.ts"],"sourcesContent":["import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// Schema for async submit response\nexport const asyncSubmitResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n request_id: z.string(),\n }),\n ),\n);\n\n// Schema for async poll response\nexport const asyncPollResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string(),\n status: z.string(),\n result: z\n .object({\n sample: z.string().optional(),\n })\n .nullable(),\n }),\n ),\n);\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport const fireworksImageModelOptionsSchema = lazySchema(() =>\n zodSchema(\n z.looseObject({\n /**\n * Classifier-free guidance scale for the image diffusion process.\n */\n guidance_scale: z.number().optional(),\n\n /**\n * Number of denoising steps for the image generation process.\n */\n num_inference_steps: z.number().int().optional(),\n\n /**\n * Desired output image format.\n */\n output_format: z.enum(['jpeg', 'png']).optional(),\n\n /**\n * URL to receive webhook notifications for async Kontext requests.\n */\n webhook_url: z.string().optional(),\n\n /**\n * Secret for webhook signature verification.\n */\n webhook_secret: z.string().optional(),\n\n /**\n * Whether Fireworks should automatically modify the prompt for more creative generation.\n */\n prompt_upsampling: z.boolean().optional(),\n\n /**\n * Moderation tolerance level for inputs and outputs.\n */\n safety_tolerance: z.number().int().min(0).max(6).optional(),\n\n /**\n * Guidance scale for legacy image_generation models.\n */\n cfg_scale: z.number().optional(),\n\n /**\n * Number of generation steps for legacy image_generation models.\n */\n steps: z.number().int().optional(),\n }),\n ),\n);\n\nexport type FireworksImageModelOptions = InferSchema<\n typeof fireworksImageModelOptionsSchema\n>;\n","import type { ImageModelV4, SharedV4Warning } from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertImageModelFileToDataUri,\n createBinaryResponseHandler,\n createJsonResponseHandler,\n createStatusCodeErrorResponseHandler,\n delay,\n getFromApi,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport {\n asyncPollResponseSchema,\n asyncSubmitResponseSchema,\n} from './fireworks-image-api';\nimport { fireworksImageModelOptionsSchema } from './fireworks-image-model-options';\nimport type { FireworksImageModelId } from './fireworks-image-options';\n\nconst DEFAULT_POLL_INTERVAL_MILLIS = 500;\nconst DEFAULT_POLL_TIMEOUT_MILLIS = 120000; // 2 minutes for image generation\n\ninterface FireworksImageModelBackendConfig {\n urlFormat: 'workflows' | 'workflows_async' | 'image_generation';\n supportsSize?: boolean;\n supportsEditing?: boolean;\n}\n\nconst modelToBackendConfig: Partial<\n Record<FireworksImageModelId, FireworksImageModelBackendConfig>\n> = {\n 'accounts/fireworks/models/flux-1-dev-fp8': {\n urlFormat: 'workflows',\n },\n 'accounts/fireworks/models/flux-1-schnell-fp8': {\n urlFormat: 'workflows',\n },\n 'accounts/fireworks/models/flux-kontext-pro': {\n urlFormat: 'workflows_async',\n supportsEditing: true,\n },\n 'accounts/fireworks/models/flux-kontext-max': {\n urlFormat: 'workflows_async',\n supportsEditing: true,\n },\n 'accounts/fireworks/models/playground-v2-5-1024px-aesthetic': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/japanese-stable-diffusion-xl': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/playground-v2-1024px-aesthetic': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/stable-diffusion-xl-1024-v1-0': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n 'accounts/fireworks/models/SSD-1B': {\n urlFormat: 'image_generation',\n supportsSize: true,\n },\n};\n\nfunction getUrlForModel(\n baseUrl: string,\n modelId: FireworksImageModelId,\n): string {\n const config = modelToBackendConfig[modelId];\n\n switch (config?.urlFormat) {\n case 'image_generation':\n return `${baseUrl}/image_generation/${modelId}`;\n case 'workflows_async':\n return `${baseUrl}/workflows/${modelId}`;\n case 'workflows':\n default:\n return `${baseUrl}/workflows/${modelId}/text_to_image`;\n }\n}\n\nfunction getPollUrlForModel(\n baseUrl: string,\n modelId: FireworksImageModelId,\n): string {\n return `${baseUrl}/workflows/${modelId}/get_result`;\n}\n\ninterface FireworksImageModelConfig {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string>;\n fetch?: FetchFunction;\n /**\n * Poll interval in milliseconds between status checks for async models.\n * Defaults to 500ms.\n */\n pollIntervalMillis?: number;\n /**\n * Overall timeout in milliseconds for polling before giving up.\n * Defaults to 120000ms (2 minutes).\n */\n pollTimeoutMillis?: number;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\nexport class FireworksImageModel implements ImageModelV4 {\n readonly specificationVersion = 'v4';\n readonly maxImagesPerCall = 1;\n\n get supportsFileInputs(): boolean | undefined {\n if (\n this.modelId === 'accounts/fireworks/models/flux-kontext-pro' ||\n this.modelId === 'accounts/fireworks/models/flux-kontext-max'\n ) {\n return true;\n }\n\n return [\n 'accounts/fireworks/models/flux-1-dev-fp8',\n 'accounts/fireworks/models/flux-1-schnell-fp8',\n 'accounts/fireworks/models/playground-v2-5-1024px-aesthetic',\n 'accounts/fireworks/models/japanese-stable-diffusion-xl',\n 'accounts/fireworks/models/playground-v2-1024px-aesthetic',\n 'accounts/fireworks/models/SSD-1B',\n 'accounts/fireworks/models/stable-diffusion-xl-1024-v1-0',\n ].includes(this.modelId)\n ? false\n : undefined;\n }\n\n get supportsMaskInputs(): boolean | undefined {\n return this.supportsFileInputs == null ? undefined : false;\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: FireworksImageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: FireworksImageModelId;\n config: FireworksImageModelConfig;\n }) {\n return new FireworksImageModel(options.modelId, options.config);\n }\n\n constructor(\n readonly modelId: FireworksImageModelId,\n private config: FireworksImageModelConfig,\n ) {}\n\n async doGenerate({\n prompt,\n n,\n size,\n aspectRatio,\n seed,\n providerOptions,\n headers,\n abortSignal,\n files,\n mask,\n }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<\n Awaited<ReturnType<ImageModelV4['doGenerate']>>\n > {\n const warnings: Array<SharedV4Warning> = [];\n\n const backendConfig = modelToBackendConfig[this.modelId];\n if (!backendConfig?.supportsSize && size != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'size',\n details:\n 'This model does not support the `size` option. Use `aspectRatio` instead.',\n });\n }\n\n // Use supportsSize as a proxy for whether the model does not support\n // aspectRatio. This invariant holds for the current set of models.\n if (backendConfig?.supportsSize && aspectRatio != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details: 'This model does not support the `aspectRatio` option.',\n });\n }\n\n // Handle files for image editing\n const hasInputImage = files != null && files.length > 0;\n let inputImage: string | undefined;\n\n if (hasInputImage) {\n inputImage = convertImageModelFileToDataUri(files[0]);\n\n if (files.length > 1) {\n warnings.push({\n type: 'other',\n message:\n 'Fireworks only supports a single input image. Additional images are ignored.',\n });\n }\n }\n\n // Warn about mask - Fireworks Kontext models don't support explicit masks\n if (mask != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'mask',\n details:\n 'Fireworks Kontext models do not support explicit masks. Use the prompt to describe the areas to edit.',\n });\n }\n\n const splitSize = size?.split('x');\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const combinedHeaders = combineHeaders(this.config.headers?.(), headers);\n const fireworksOptions =\n (await parseProviderOptions({\n provider: 'fireworks',\n providerOptions,\n schema: fireworksImageModelOptionsSchema,\n })) ?? {};\n\n const body = {\n prompt,\n aspect_ratio: aspectRatio,\n seed,\n samples: n,\n ...(inputImage && { input_image: inputImage }),\n ...(splitSize && { width: splitSize[0], height: splitSize[1] }),\n ...fireworksOptions,\n };\n\n // Handle async models that require polling (e.g., flux-kontext-*)\n if (backendConfig?.urlFormat === 'workflows_async') {\n return this.doGenerateAsync({\n body,\n headers: combinedHeaders,\n abortSignal,\n warnings,\n currentDate,\n });\n }\n\n // Handle sync models that return binary directly\n const { value: response, responseHeaders } = await postJsonToApi({\n url: getUrlForModel(this.config.baseURL, this.modelId),\n headers: combinedHeaders,\n body,\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n images: [response],\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n\n /**\n * Handles async image generation for models like flux-kontext-* that return\n * a request_id and require polling for results.\n */\n private async doGenerateAsync({\n body,\n headers,\n abortSignal,\n warnings,\n currentDate,\n }: {\n body: Record<string, unknown>;\n headers: Record<string, string | undefined>;\n abortSignal: AbortSignal | undefined;\n warnings: Array<SharedV4Warning>;\n currentDate: Date;\n }): Promise<Awaited<ReturnType<ImageModelV4['doGenerate']>>> {\n // Submit the generation request\n const { value: submitResponse } = await postJsonToApi({\n url: getUrlForModel(this.config.baseURL, this.modelId),\n headers,\n body,\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n asyncSubmitResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n const requestId = submitResponse.request_id;\n\n // Poll for the result\n const imageUrl = await this.pollForImageUrl({\n requestId,\n headers,\n abortSignal,\n });\n\n // Download the image from the URL. The URL comes from the provider\n // response and typically points at a CDN, so only send credentials when it\n // stays on the provider's own origin (never leak the API key to a CDN or an\n // attacker-named host).\n const { value: imageBytes, responseHeaders } = await getFromApi({\n url: imageUrl,\n // imageUrl comes from the provider response body.\n validateUrl: true,\n credentialedOrigin: this.config.baseURL,\n trustedOrigin: this.config.baseURL,\n headers,\n abortSignal,\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createBinaryResponseHandler(),\n fetch: this.config.fetch,\n });\n\n return {\n images: [imageBytes],\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n };\n }\n\n /**\n * Polls the get_result endpoint until the image is ready.\n */\n private async pollForImageUrl({\n requestId,\n headers,\n abortSignal,\n }: {\n requestId: string;\n headers: Record<string, string | undefined>;\n abortSignal: AbortSignal | undefined;\n }): Promise<string> {\n const pollIntervalMillis =\n this.config.pollIntervalMillis ?? DEFAULT_POLL_INTERVAL_MILLIS;\n const pollTimeoutMillis =\n this.config.pollTimeoutMillis ?? DEFAULT_POLL_TIMEOUT_MILLIS;\n\n const pollUrl = getPollUrlForModel(this.config.baseURL, this.modelId);\n\n const timeoutController = new AbortController();\n let didTimeout = false;\n const timeoutId = setTimeout(() => {\n didTimeout = true;\n timeoutController.abort();\n }, pollTimeoutMillis);\n const pollingAbortSignal =\n abortSignal == null\n ? timeoutController.signal\n : AbortSignal.any([abortSignal, timeoutController.signal]);\n\n try {\n while (true) {\n const { value: pollResponse } = await postJsonToApi({\n url: pollUrl,\n headers,\n body: { id: requestId },\n failedResponseHandler: createStatusCodeErrorResponseHandler(),\n successfulResponseHandler: createJsonResponseHandler(\n asyncPollResponseSchema,\n ),\n abortSignal: pollingAbortSignal,\n fetch: this.config.fetch,\n });\n\n const status = pollResponse.status;\n\n if (status === 'Ready') {\n const imageUrl = pollResponse.result?.sample;\n if (typeof imageUrl === 'string') {\n return imageUrl;\n }\n throw new Error(\n 'Fireworks poll response is Ready but missing result.sample',\n );\n }\n\n if (status === 'Error' || status === 'Failed') {\n throw new Error(\n `Fireworks image generation failed with status: ${status}`,\n );\n }\n\n // Wait before next poll attempt\n await delay(pollIntervalMillis, {\n abortSignal: pollingAbortSignal,\n });\n }\n } catch (error) {\n if (didTimeout) {\n throw new Error(\n `Fireworks image generation timed out after ${pollTimeoutMillis}ms`,\n );\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\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 {\n OpenAICompatibleChatLanguageModel,\n OpenAICompatibleCompletionLanguageModel,\n OpenAICompatibleEmbeddingModel,\n type ProviderErrorStructure,\n} from '@ai-sdk/openai-compatible';\nimport type {\n EmbeddingModelV4,\n ImageModelV4,\n LanguageModelV4,\n ProviderV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport type { FireworksChatModelId } from './fireworks-chat-options';\nimport type { FireworksCompletionModelId } from './fireworks-completion-options';\nimport type { FireworksEmbeddingModelId } from './fireworks-embedding-options';\nimport { FireworksImageModel } from './fireworks-image-model';\nimport type { FireworksImageModelId } from './fireworks-image-options';\nimport { VERSION } from './version';\n\nexport type FireworksErrorData = z.infer<typeof fireworksErrorSchema>;\n\nconst fireworksErrorSchema = z.object({\n error: z.union([\n z.string(),\n z.object({\n message: z.string(),\n object: z.string().nullish(),\n type: z.string().nullish(),\n param: z.any().nullish(),\n code: z.union([z.string(), z.number()]).nullish(),\n }),\n ]),\n});\n\nconst fireworksErrorStructure: ProviderErrorStructure<FireworksErrorData> = {\n errorSchema: fireworksErrorSchema,\n errorToMessage: data =>\n typeof data.error === 'string' ? data.error : data.error.message,\n};\n\nexport interface FireworksProviderSettings {\n /**\n * Fireworks API key. Default value is taken from the `FIREWORKS_API_KEY`\n * environment variable.\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 FireworksProvider extends ProviderV4 {\n /**\n * Creates a model for text generation.\n */\n (modelId: FireworksChatModelId): LanguageModelV4;\n\n /**\n * Creates a chat model for text generation.\n */\n chatModel(modelId: FireworksChatModelId): LanguageModelV4;\n\n /**\n * Creates a completion model for text generation.\n */\n completionModel(modelId: FireworksCompletionModelId): LanguageModelV4;\n\n /**\n * Creates a chat model for text generation.\n */\n languageModel(modelId: FireworksChatModelId): LanguageModelV4;\n\n /**\n * Creates a text embedding model for text generation.\n */\n embeddingModel(modelId: FireworksEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: FireworksEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * Creates a model for image generation.\n */\n image(modelId: FireworksImageModelId): ImageModelV4;\n\n /**\n * Creates a model for image generation.\n */\n imageModel(modelId: FireworksImageModelId): ImageModelV4;\n}\n\nconst defaultBaseURL = 'https://api.fireworks.ai/inference/v1';\n\nexport function createFireworks(\n options: FireworksProviderSettings = {},\n): FireworksProvider {\n const baseURL = withoutTrailingSlash(options.baseURL ?? defaultBaseURL);\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'FIREWORKS_API_KEY',\n description: 'Fireworks API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk-fireworks/${VERSION}`,\n );\n\n interface CommonModelConfig {\n provider: string;\n url: ({ path }: { path: string }) => string;\n headers: () => Record<string, string>;\n fetch?: FetchFunction;\n }\n\n const getCommonModelConfig = (modelType: string): CommonModelConfig => ({\n provider: `fireworks.${modelType}`,\n url: ({ path }) => `${baseURL}${path}`,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createChatModel = (modelId: FireworksChatModelId) => {\n return new OpenAICompatibleChatLanguageModel(modelId, {\n ...getCommonModelConfig('chat'),\n includeUsage: true,\n errorStructure: fireworksErrorStructure,\n supportsStructuredOutputs: true,\n transformRequestBody: (args, warnings) => {\n const thinking = args.thinking as\n | { type?: string; budgetTokens?: number }\n | undefined;\n const reasoningHistory = args.reasoningHistory as string | undefined;\n const promptCacheKey = args.promptCacheKey as string | undefined;\n const serviceTier = args.serviceTier as string | undefined;\n\n const {\n thinking: _,\n reasoningHistory: __,\n promptCacheKey: ___,\n serviceTier: ____,\n reasoning_effort,\n ...rest\n } = args;\n\n // Fireworks supports low, medium, and high reasoning levels.\n const mappedReasoningEffort =\n reasoning_effort === 'minimal'\n ? 'low'\n : reasoning_effort === 'xhigh' || reasoning_effort === 'max'\n ? 'high'\n : reasoning_effort;\n\n if (mappedReasoningEffort !== reasoning_effort) {\n warnings?.push({\n type: 'compatibility',\n feature: 'reasoning',\n details: `reasoning \"${reasoning_effort}\" is not directly supported by this model. mapped to effort \"${mappedReasoningEffort}\".`,\n });\n }\n\n return {\n ...rest,\n ...(reasoning_effort != null && {\n reasoning_effort: mappedReasoningEffort,\n }),\n ...(promptCacheKey !== undefined && {\n prompt_cache_key: promptCacheKey,\n }),\n ...(serviceTier !== undefined && {\n service_tier: serviceTier,\n }),\n ...(thinking && {\n thinking: {\n type: thinking.type,\n ...(thinking.budgetTokens !== undefined && {\n budget_tokens: thinking.budgetTokens,\n }),\n },\n }),\n ...(reasoningHistory && {\n reasoning_history: reasoningHistory,\n }),\n };\n },\n });\n };\n\n const createCompletionModel = (modelId: FireworksCompletionModelId) =>\n new OpenAICompatibleCompletionLanguageModel(modelId, {\n ...getCommonModelConfig('completion'),\n includeUsage: true,\n errorStructure: fireworksErrorStructure,\n });\n\n const createEmbeddingModel = (modelId: FireworksEmbeddingModelId) =>\n new OpenAICompatibleEmbeddingModel(modelId, {\n ...getCommonModelConfig('embedding'),\n errorStructure: fireworksErrorStructure,\n });\n\n const createImageModel = (modelId: FireworksImageModelId) =>\n new FireworksImageModel(modelId, {\n ...getCommonModelConfig('image'),\n baseURL: baseURL ?? defaultBaseURL,\n });\n\n const provider = (modelId: FireworksChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v4' as const;\n provider.completionModel = createCompletionModel;\n provider.chatModel = createChatModel;\n provider.languageModel = createChatModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n provider.image = createImageModel;\n provider.imageModel = createImageModel;\n return provider;\n}\n\nexport const fireworks = createFireworks();\n"],"mappings":";;;;AAIA,MAAa,4BAA4B,iBACvC,UACE,EAAE,OAAO,EACP,YAAY,EAAE,OAAO,EACvB,CAAC,CACH,CACF;AAGA,MAAa,0BAA0B,iBACrC,UACE,EAAE,OAAO;CACP,IAAI,EAAE,OAAO;CACb,QAAQ,EAAE,OAAO;CACjB,QAAQ,EACL,OAAO,EACN,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS,EAC9B,CAAC,CAAC,CACD,SAAS;AACd,CAAC,CACH,CACF;;;AClBA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YAAY,gBAAgB"}
|
package/docs/26-fireworks.mdx
CHANGED
|
@@ -63,6 +63,13 @@ const model = fireworks('accounts/fireworks/models/firefunction-v1');
|
|
|
63
63
|
|
|
64
64
|
### Reasoning Models
|
|
65
65
|
|
|
66
|
+
For models that support reasoning effort, use the top-level `reasoning` parameter.
|
|
67
|
+
Fireworks maps `'minimal'` to `'low'` and `'xhigh'` or `'max'` to `'high'`, returning
|
|
68
|
+
a compatibility warning whenever it coerces the effort. Streaming calls include
|
|
69
|
+
the warning in the `stream-start` event. Explicit
|
|
70
|
+
`providerOptions.fireworks.reasoningEffort` takes precedence over the top-level
|
|
71
|
+
setting.
|
|
72
|
+
|
|
66
73
|
Fireworks exposes the thinking of `deepseek-r1` in the generated text using the `<think>` tag.
|
|
67
74
|
You can use the `extractReasoningMiddleware` to extract this reasoning and expose it as a `reasoning` property on the result:
|
|
68
75
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/fireworks",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.67",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,16 +29,16 @@
|
|
|
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.64",
|
|
33
|
+
"@ai-sdk/provider": "4.0.23",
|
|
34
|
+
"@ai-sdk/provider-utils": "5.0.55"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@ai-sdk/test-server": "2.0.
|
|
37
|
+
"@ai-sdk/test-server": "2.0.4",
|
|
38
38
|
"@types/node": "22.19.19",
|
|
39
39
|
"@vercel/ai-tsconfig": "0.0.0",
|
|
40
40
|
"tsdown": "^0.23.0",
|
|
41
|
-
"typescript": "
|
|
41
|
+
"typescript": "6.0.3",
|
|
42
42
|
"zod": "3.25.76"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
@@ -147,7 +147,7 @@ export function createFireworks(
|
|
|
147
147
|
includeUsage: true,
|
|
148
148
|
errorStructure: fireworksErrorStructure,
|
|
149
149
|
supportsStructuredOutputs: true,
|
|
150
|
-
transformRequestBody: args => {
|
|
150
|
+
transformRequestBody: (args, warnings) => {
|
|
151
151
|
const thinking = args.thinking as
|
|
152
152
|
| { type?: string; budgetTokens?: number }
|
|
153
153
|
| undefined;
|
|
@@ -164,16 +164,26 @@ export function createFireworks(
|
|
|
164
164
|
...rest
|
|
165
165
|
} = args;
|
|
166
166
|
|
|
167
|
+
// Fireworks supports low, medium, and high reasoning levels.
|
|
168
|
+
const mappedReasoningEffort =
|
|
169
|
+
reasoning_effort === 'minimal'
|
|
170
|
+
? 'low'
|
|
171
|
+
: reasoning_effort === 'xhigh' || reasoning_effort === 'max'
|
|
172
|
+
? 'high'
|
|
173
|
+
: reasoning_effort;
|
|
174
|
+
|
|
175
|
+
if (mappedReasoningEffort !== reasoning_effort) {
|
|
176
|
+
warnings?.push({
|
|
177
|
+
type: 'compatibility',
|
|
178
|
+
feature: 'reasoning',
|
|
179
|
+
details: `reasoning "${reasoning_effort}" is not directly supported by this model. mapped to effort "${mappedReasoningEffort}".`,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
167
183
|
return {
|
|
168
184
|
...rest,
|
|
169
185
|
...(reasoning_effort != null && {
|
|
170
|
-
|
|
171
|
-
reasoning_effort:
|
|
172
|
-
reasoning_effort === 'minimal'
|
|
173
|
-
? 'low'
|
|
174
|
-
: reasoning_effort === 'xhigh'
|
|
175
|
-
? 'high'
|
|
176
|
-
: reasoning_effort,
|
|
186
|
+
reasoning_effort: mappedReasoningEffort,
|
|
177
187
|
}),
|
|
178
188
|
...(promptCacheKey !== undefined && {
|
|
179
189
|
prompt_cache_key: promptCacheKey,
|