feat: Add ModelsLab provider for image generation#1533
Open
adhikjoshi wants to merge 1 commit intoPortkey-AI:mainfrom
Open
feat: Add ModelsLab provider for image generation#1533adhikjoshi wants to merge 1 commit intoPortkey-AI:mainfrom
adhikjoshi wants to merge 1 commit intoPortkey-AI:mainfrom
Conversation
Adds ModelsLab (https://modelslab.com) as a new AI provider for image generation (text-to-image) via the Portkey AI Gateway. ModelsLab is a developer-first AI API platform offering: - 200+ AI models for image, video, voice, and 3D generation - Community models (Flux, SD, SDXL) and fine-tuned models - Pay-as-you-go pricing with async/webhook support ## What this PR adds - src/providers/modelslab/api.ts — Base URL, headers, endpoint routing - src/providers/modelslab/imageGenerate.ts — ProviderConfig + response transform - src/providers/modelslab/index.ts — Provider config registry - src/globals.ts — MODELSLAB provider constant - src/providers/index.ts — Register modelslab provider ## API Mapping | Portkey param | ModelsLab param | Notes | |---|---|---| | prompt | prompt | Required | | model | model_id | Default: 'flux' | | n | samples | 1-4 | | size (WxH) | width, height | Min 256px | | steps | num_inference_steps | 1-50, default 30 | | guidance_scale | guidance_scale | 1-20, default 7.5 | | seed | seed | | | negative_prompt | negative_prompt | | ## Auth ModelsLab uses key-in-body auth. The API key is automatically injected from providerOptions.apiKey into the JSON body as 'key'. ## Usage ```bash curl http://localhost:8787/v1/images/generations \ -H 'Content-Type: application/json' \ -H 'x-portkey-provider: modelslab' \ -H 'Authorization: Bearer YOUR_MODELSLAB_API_KEY' \ -d '{ "prompt": "a beautiful sunset over mountains", "model": "flux", "n": 1, "size": "1024x1024" }' ``` ## API Docs https://docs.modelslab.com
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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
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.
Summary
Adds ModelsLab as a new AI provider for image generation (text-to-image) via the Portkey AI Gateway.
ModelsLab is a developer-first AI API platform offering 200+ models for image, video, voice, and 3D generation. It currently routes to providers like Stability AI, FLUX, SDXL, and thousands of community fine-tuned models.
What this PR adds
src/providers/modelslab/api.tssrc/providers/modelslab/imageGenerate.tssrc/providers/modelslab/index.tssrc/globals.tsMODELSLABprovider constantsrc/providers/index.tsParameter Mapping
promptpromptmodelmodel_idfluxnsamplessize(e.g.1024x1024)width,heightstepsnum_inference_stepsguidance_scaleguidance_scaleseedseednegative_promptnegative_promptAuth: ModelsLab uses key-in-body authentication. The API key from
providerOptions.apiKeyis automatically injected into the request body as"key".Async/Webhook: For slow models, ModelsLab returns
"status": "processing"with afetch_resultpoll URL. This provider surfaces that as an error message with the poll URL; consumers should use thewebhookparameter for async workflows.Usage
Response:
{ "created": 1708512345, "data": [ { "url": "https://...modelslab.com/.../output.png" } ] }API Reference
Checklist
globals.tsproviders/index.tsrollup -c)