Commit f2b78f5
feat: add imageModel() method for image generation support (#366)
* feat: add imageModel() method for image generation support
Implements ImageModelV3 interface to enable image generation through
the AI SDK's generateImage() function. Uses OpenRouter's chat completions
endpoint with modalities: ['image', 'text'] to generate images.
Features:
- Supports aspectRatio parameter via image_config
- Supports seed parameter for reproducible generation
- Supports provider routing settings
- Returns warnings for unsupported features (n > 1, size)
- Throws UnsupportedFunctionalityError for image editing (files/mask)
Closes #317
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
* fix: address PR review feedback
- Change zod import to 'zod/v4' for consistency with rest of codebase
- Add .passthrough() to schema for forward compatibility
- Throw NoContentGeneratedError when choices array is empty
- Add test for empty choices array edge case
- Rename test to clarify it tests 'no images in message' case
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
* fix: use shared getBase64FromDataUrl and remove duplicate user field
- Use getBase64FromDataUrl from file-url-utils.ts instead of duplicating regex
- Remove duplicate user field from OpenRouterImageSettings (inherited from OpenRouterSharedSettings)
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
* feat: add runtime providerOptions support to image model
- Extract providerOptions.openrouter and spread into request body
- Matches chat model behavior for consistency
- Add test for runtime providerOptions support
Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>1 parent c6ae94d commit f2b78f5
File tree
8 files changed
+965
-0
lines changed- .changeset
- src
- image
- internal
- types
8 files changed
+965
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
0 commit comments