Skip to content

Commit

Permalink
feat (provider/fireworks): Support add'l image models. (#4316)
Browse files Browse the repository at this point in the history
  • Loading branch information
shaper authored Jan 8, 2025
1 parent 17a3cf9 commit e6dfef4
Show file tree
Hide file tree
Showing 9 changed files with 652 additions and 163 deletions.
6 changes: 6 additions & 0 deletions .changeset/smooth-dragons-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@ai-sdk/provider-utils': patch
'@ai-sdk/fireworks': patch
---

feat (provider/fireworks): Support add'l image models.
23 changes: 15 additions & 8 deletions content/docs/03-ai-sdk-core/35-image-generation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,18 @@ const { image, warnings } = await generateImage({

## Image Models

| Provider | Model | Sizes | Aspect Ratios |
| ----------------------------------------------------------------------- | ---------------------------------------------- | ------------------------------- | ----------------------------------------------- |
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#image-models) | `imagen-3.0-generate-001` | Use aspect ratio | 1:1, 3:4, 4:3, 9:16, 16:9 |
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#image-models) | `imagen-3.0-fast-generate-001` | Use aspect ratio | 1:1, 3:4, 4:3, 9:16, 16:9 |
| [OpenAI](/providers/ai-sdk-providers/openai#image-models) | `dall-e-3` | 1024x1024, 1792x1024, 1024x1792 | use size |
| [OpenAI](/providers/ai-sdk-providers/openai#image-models) | `dall-e-2` | 256x256, 512x512, 1024x1024 | use size |
| [Fireworks](/providers/ai-sdk-providers/fireworks#image-models) | `accounts/fireworks/models/flux-1-dev-fp8` | Use aspect ratio | 1:1, 2:3, 3:2, 4:5, 5:4, 16:9, 9:16, 9:21, 21:9 |
| [Fireworks](/providers/ai-sdk-providers/fireworks#image-models) | `accounts/fireworks/models/flux-1-schnell-fp8` | Use aspect ratio | 1:1, 2:3, 3:2, 4:5, 5:4, 16:9, 9:16, 9:21, 21:9 |
| Provider | Model | Sizes | Aspect Ratios |
| ----------------------------------------------------------------------- | ------------------------------------------------------------ | ------------------------------- | ----------------------------------------------- |
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#image-models) | `imagen-3.0-generate-001` | Use aspect ratio | 1:1, 3:4, 4:3, 9:16, 16:9 |
| [Google Vertex](/providers/ai-sdk-providers/google-vertex#image-models) | `imagen-3.0-fast-generate-001` | Use aspect ratio | 1:1, 3:4, 4:3, 9:16, 16:9 |
| [OpenAI](/providers/ai-sdk-providers/openai#image-models) | `dall-e-3` | 1024x1024, 1792x1024, 1024x1792 | use size |
| [OpenAI](/providers/ai-sdk-providers/openai#image-models) | `dall-e-2` | 256x256, 512x512, 1024x1024 | use size |
| [Fireworks](/providers/ai-sdk-providers/fireworks#image-models) | `accounts/fireworks/models/flux-1-dev-fp8` | Use aspect ratio | 1:1, 2:3, 3:2, 4:5, 5:4, 16:9, 9:16, 9:21, 21:9 |
| [Fireworks](/providers/ai-sdk-providers/fireworks#image-models) | `accounts/fireworks/models/flux-1-schnell-fp8` | Use aspect ratio | 1:1, 2:3, 3:2, 4:5, 5:4, 16:9, 9:16, 9:21, 21:9 |
| [Fireworks](/providers/ai-sdk-providers/fireworks#image-models) | `accounts/fireworks/models/playground-v2-5-1024px-aesthetic` | 640x1536 to 1536x640\* | use size |
| [Fireworks](/providers/ai-sdk-providers/fireworks#image-models) | `accounts/fireworks/models/japanese-stable-diffusion-xl` | 640x1536 to 1536x640\* | use size |
| [Fireworks](/providers/ai-sdk-providers/fireworks#image-models) | `accounts/fireworks/models/playground-v2-1024px-aesthetic` | 640x1536 to 1536x640\* | use size |
| [Fireworks](/providers/ai-sdk-providers/fireworks#image-models) | `accounts/fireworks/models/SSD-1B` | 640x1536 to 1536x640\* | use size |
| [Fireworks](/providers/ai-sdk-providers/fireworks#image-models) | `accounts/fireworks/models/stable-diffusion-xl-1024-v1-0` | 640x1536 to 1536x640\* | use size |

\* Supported sizes: 640x1536, 768x1344, 832x1216, 896x1152, 1024x1024, 1152x896, 1216x832, 1344x768, 1536x640
41 changes: 35 additions & 6 deletions content/providers/01-ai-sdk-providers/26-fireworks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,42 @@ const { image } = await generateImage({
```

<Note>
Fireworks models do not support the `size` parameter. Use the `aspectRatio`
parameter instead.
Model support for `size` and `aspectRatio` parameters varies. See the [Model
Capabilities](#model-capabilities-1) section below for supported dimensions,
or check the model's documentation on [Fireworks models
page](https://fireworks.ai/models) for more details.
</Note>

### Model Capabilities

| Model | Aspect Ratios |
| ---------------------------------------------- | ----------------------------------------------- |
| `accounts/fireworks/models/flux-1-dev-fp8` | 1:1, 2:3, 3:2, 4:5, 5:4, 16:9, 9:16, 9:21, 21:9 |
| `accounts/fireworks/models/flux-1-schnell-fp8` | 1:1, 2:3, 3:2, 4:5, 5:4, 16:9, 9:16, 9:21, 21:9 |
For all models supporting aspect ratios, the following aspect ratios are supported:

`1:1 (default), 2:3, 3:2, 4:5, 5:4, 16:9, 9:16, 9:21, 21:9`

For all models supporting size, the following sizes are supported:

`640 x 1536, 768 x 1344, 832 x 1216, 896 x 1152, 1024x1024 (default), 1152 x 896, 1216 x 832, 1344 x 768, 1536 x 640`

| Model | Dimensions Specification |
| ------------------------------------------------------------ | ------------------------ |
| `accounts/fireworks/models/flux-1-dev-fp8` | Aspect Ratio |
| `accounts/fireworks/models/flux-1-schnell-fp8` | Aspect Ratio |
| `accounts/fireworks/models/playground-v2-5-1024px-aesthetic` | Size |
| `accounts/fireworks/models/japanese-stable-diffusion-xl` | Size |
| `accounts/fireworks/models/playground-v2-1024px-aesthetic` | Size |
| `accounts/fireworks/models/SSD-1B` | Size |
| `accounts/fireworks/models/stable-diffusion-xl-1024-v1-0` | Size |

For more details, see the [Fireworks models page](https://fireworks.ai/models).

#### Stability AI Models

Fireworks also presents several Stability AI models backed by Stability AI API
keys and endpoint. The AI SDK Fireworks provider does not currently include
support for these models:

| Model ID |
| -------------------------------------- |
| `accounts/stability/models/sd3-turbo` |
| `accounts/stability/models/sd3-medium` |
| `accounts/stability/models/sd3` |
36 changes: 26 additions & 10 deletions packages/fireworks/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,50 @@
# AI SDK - Fireworks Provider

The **[Fireworks provider](https://sdk.vercel.ai/providers/ai-sdk-providers/fireworks)** for the [AI SDK](https://sdk.vercel.ai/docs) contains language model support for the [Fireworks](https://fireworks.ai) platform.
The **[Fireworks provider](https://sdk.vercel.ai/providers/ai-sdk-providers/fireworks)** for the [AI SDK](https://sdk.vercel.ai/docs) contains language model and image model support for the [Fireworks](https://fireworks.ai) platform.

## Setup

The Fireworks provider is available in the `@ai-sdk/fireworks` module. You can install it with

\```bash
```bash
npm i @ai-sdk/fireworks
\```
```

## Provider Instance

You can import the default provider instance `fireworks` from `@ai-sdk/fireworks`:

\```ts
```ts
import { fireworks } from '@ai-sdk/fireworks';
\```
```

## Example
## Language Model Example

\```ts
```ts
import { fireworks } from '@ai-sdk/fireworks';
import { generateText } from 'ai';

const { text } = await generateText({
model: fireworks('accounts/fireworks/models/llama-v2-13b-chat'),
prompt: 'Write a JavaScript function that sorts a list:',
model: fireworks('accounts/fireworks/models/deepseek-v3'),
prompt: 'Write a JavaScript function that sorts a list:',
});
\```
```

## Image Model Examples

```ts
import { fireworks } from '@ai-sdk/fireworks';
import { experimental_generateImage as generateImage } from 'ai';
import fs from 'fs';

const { image } = await generateImage({
model: fireworks.image('accounts/fireworks/models/flux-1-dev-fp8'),
prompt: 'A serene mountain landscape at sunset',
});
const filename = `image-${Date.now()}.png`;
fs.writeFileSync(filename, image.uint8Array);
console.log(`Image saved to ${filename}`);
```

## Documentation

Expand Down
Loading

0 comments on commit e6dfef4

Please sign in to comment.