Skip to content

Comments

feat: Add ModelsLab provider for image generation#1533

Open
adhikjoshi wants to merge 1 commit intoPortkey-AI:mainfrom
adhikjoshi:feat/modelslab-provider
Open

feat: Add ModelsLab provider for image generation#1533
adhikjoshi wants to merge 1 commit intoPortkey-AI:mainfrom
adhikjoshi:feat/modelslab-provider

Conversation

@adhikjoshi
Copy link

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

File Purpose
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 in provider map

Parameter Mapping

Portkey param ModelsLab param Notes
prompt prompt Required
model model_id Default: flux
n samples 1–4
size (e.g. 1024x1024) 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 authentication. The API key from providerOptions.apiKey is automatically injected into the request body as "key".

Async/Webhook: For slow models, ModelsLab returns "status": "processing" with a fetch_result poll URL. This provider surfaces that as an error message with the poll URL; consumers should use the webhook parameter for async workflows.


Usage

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 photorealistic sunset over mountain peaks",
    "model": "flux",
    "n": 1,
    "size": "1024x1024"
  }'

Response:

{
  "created": 1708512345,
  "data": [
    { "url": "https://...modelslab.com/.../output.png" }
  ]
}

API Reference


Checklist

  • Follows existing provider file structure (api.ts / imageGenerate.ts / index.ts)
  • Added provider constant to globals.ts
  • Registered in providers/index.ts
  • TypeScript compiles (no new errors)
  • Prettier check passes
  • Build succeeds (rollup -c)

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
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant