-
Notifications
You must be signed in to change notification settings - Fork 770
feat: adds image generation capability to Workers AI API #1064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
VisargD
merged 5 commits into
Portkey-AI:main
from
unsync:feature/cloudflare-image-generate
May 5, 2025
Merged
feat: adds image generation capability to Workers AI API #1064
VisargD
merged 5 commits into
Portkey-AI:main
from
unsync:feature/cloudflare-image-generate
May 5, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
570d43e to
fcff6a4
Compare
Implements support for an image generation feature by adding a new API endpoint. Includes the configuration and response transformation for handling image generation requests, ensuring proper error handling and response formatting. Updates the main API configuration to integrate the newly created image generation functionality.
fcff6a4 to
589985f
Compare
narengogi
reviewed
Apr 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, only one comment
narengogi
approved these changes
Apr 30, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Author Description
Implements support for an image generation feature
Summary By MatterAI
🔄 What Changed
This PR adds image generation capability to the Workers AI API by implementing a new endpoint. The implementation includes configuration for handling image generation requests with parameters like prompt, negative_prompt, steps, size, and seed. It also includes response transformation to properly format the image data returned from the Workers AI service.
🔍 Impact of the Change
This change extends the API's capabilities to include image generation, allowing clients to generate images using the Workers AI models. The implementation follows the same pattern as other Workers AI features, reusing common error handling and response transformation patterns.
📁 Total Files Changed
7 files changed with 133 additions and 100 deletions. Key changes include:
imageGenerate.tsfile with configuration and response transformationutils.tsfile to centralize error handling🧪 Test Added
N/A - No tests were included in this PR.
🔒 Security Vulnerabilities
No security vulnerabilities detected.
Type of Change
How Has This Been Tested?
Screenshots (if applicable)
N/A
Checklist
Related Issues
N/A
Quality Recommendations
Add input validation for the image size parameter to ensure it's in the correct format before parsing
Consider adding error handling for the case when size parameter is malformed
Add unit tests for the new image generation functionality
Add documentation for the supported image models and their specific requirements
Sequence Diagram
sequenceDiagram participant Client participant API participant WorkersAiAPI participant ImageGenerate Client->>API: POST /imageGenerate Note over Client,API: prompt, negative_prompt, steps, size, seed API->>WorkersAiAPI: Route to Workers AI API Note over API,WorkersAiAPI: Configure endpoint using model WorkersAiAPI->>ImageGenerate: Process request Note over WorkersAiAPI,ImageGenerate: Transform parameters ImageGenerate->>WorkersAiAPI: Generate image Note over ImageGenerate,WorkersAiAPI: Process with model parameters WorkersAiAPI-->>Client: Return response Note over WorkersAiAPI,Client: b64_json image data