Add canonical puterId to image provider models (#2322)

* add canonical puterId to image provider models

* return fully qualified puterIds in AIImageGenerationService.list()

* add aliases to openai image models

---------

Co-authored-by: Neal Shah <30693865+ProgrammerIn-wonderland@users.noreply.github.com>
This commit is contained in:
velzie
2026-01-29 14:47:51 -05:00
committed by GitHub
parent de14bf7273
commit 1e1de413c5
5 changed files with 53 additions and 14 deletions
@@ -82,7 +82,7 @@ export class AIImageGenerationService extends BaseService {
},
};
getModel ({ modelId, provider}: { modelId: string, provider?: string }) {
getModel ({ modelId, provider }: { modelId: string, provider?: string }) {
const models = this.#modelIdMap[modelId];
if ( ! provider ) {
@@ -142,12 +142,23 @@ export class AIImageGenerationService extends BaseService {
// build model id map
for ( const model of await provider.models() ) {
model.id = model.id.trim().toLowerCase();
if ( ! this.#modelIdMap[model.id] ) {
this.#modelIdMap[model.id] = [];
}
this.#modelIdMap[model.id].push({ ...model, provider: providerName });
if ( model.puterId ) {
if ( model.aliases ) {
model.aliases.push(model.puterId);
} else {
model.aliases = [model.puterId];
}
}
if ( model.aliases ) {
for ( const alias of model.aliases ) {
for ( let alias of model.aliases ) {
alias = alias.trim().toLowerCase();
// join arrays which are aliased the same
if ( ! this.#modelIdMap[alias] ) {
this.#modelIdMap[alias] = this.#modelIdMap[model.id];
@@ -178,7 +189,7 @@ export class AIImageGenerationService extends BaseService {
}
list () {
return Object.keys(this.#modelIdMap).sort();
return this.models().map(m => (m.puterId || m.id)).sort();
}
async generate (parameters: IGenerateParams) {
@@ -23,8 +23,14 @@ export const GEMINI_DEFAULT_RATIO = { w: 1024, h: 1024 };
export const GEMINI_IMAGE_GENERATION_MODELS: IImageModel[] = [
{
puterId: 'google:google/gemini-2.5-flash-image',
id: 'gemini-2.5-flash-image',
aliases: ['gemini-2.5-flash-image-preview'],
aliases: [
'gemini-2.5-flash-image-preview', 'gemini-2.5-flash-image',
'google/gemini-2.5-flash-image-preview', 'google/gemini-2.5-flash-image',
'google:google/gemini-2.5-flash-image-preview',
],
name: 'Gemini 2.5 Flash Image',
version: '1.0',
costs_currency: 'usd-cents',
@@ -56,12 +62,17 @@ export const GEMINI_IMAGE_GENERATION_MODELS: IImageModel[] = [
],
},
{
puterId: 'google:google/gemini-3-pro-image',
id: 'gemini-3-pro-image',
name: 'Gemini 3 Pro Image',
version: '1.0',
costs_currency: 'usd-cents',
index_cost_key: '1K:1x1',
aliases: ['gemini-3-pro-image-preview'],
aliases: [
'gemini-3-flash-image-preview', 'gemini-3-flash-image',
'google/gemini-3-flash-image-preview', 'google/gemini-3-flash-image',
'google:google/gemini-3-flash-image-preview',
],
allowedQualityLevels: ['1K', '2K', '4K'],
allowedRatios: [
{ w: 1, h: 1 },
@@ -1,7 +1,10 @@
import { IImageModel } from '../types';
export const OPEN_AI_IMAGE_GENERATION_MODELS: IImageModel[] = [
{ id: 'gpt-image-1.5',
{
puterId: 'openai:openai/gpt-image-1.5',
id: 'gpt-image-1.5',
aliases: ['openai/gpt-image-1.5'],
name: 'GPT Image 1.5',
version: '1.5',
costs_currency: 'usd-cents',
@@ -20,7 +23,10 @@ export const OPEN_AI_IMAGE_GENERATION_MODELS: IImageModel[] = [
allowedQualityLevels: ['low', 'medium', 'high'],
allowedRatios: [{ w: 1024, h: 1024 }, { w: 1024, h: 1536 }, { w: 1536, h: 1024 }],
},
{ id: 'gpt-image-1-mini',
{
puterId: 'openai:openai/gpt-image-1-mini',
id: 'gpt-image-1-mini',
aliases: ['openai/gpt-image-1-mini'],
name: 'GPT Image 1 Mini',
version: '1.0',
costs_currency: 'usd-cents',
@@ -39,7 +45,10 @@ export const OPEN_AI_IMAGE_GENERATION_MODELS: IImageModel[] = [
allowedQualityLevels: ['low', 'medium', 'high'],
allowedRatios: [{ w: 1024, h: 1024 }, { w: 1024, h: 1536 }, { w: 1536, h: 1024 }],
},
{ id: 'gpt-image-1',
{
puterId: 'openai:openai/gpt-image-1',
id: 'gpt-image-1',
aliases: ['openai/gpt-image-1'],
name: 'GPT Image 1',
version: '1.0',
costs_currency: 'usd-cents',
@@ -58,7 +67,10 @@ export const OPEN_AI_IMAGE_GENERATION_MODELS: IImageModel[] = [
allowedQualityLevels: ['low', 'medium', 'high'],
allowedRatios: [{ w: 1024, h: 1024 }, { w: 1024, h: 1536 }, { w: 1536, h: 1024 }],
},
{ id: 'dall-e-3',
{
puterId: 'openai:openai/dall-e-3',
id: 'dall-e-3',
aliases: ['openai/dall-e-3'],
name: 'DALL·E 3',
version: '1.0',
costs_currency: 'usd-cents',
@@ -74,7 +86,10 @@ export const OPEN_AI_IMAGE_GENERATION_MODELS: IImageModel[] = [
allowedQualityLevels: ['', 'hd'],
allowedRatios: [{ w: 1024, h: 1024 }, { w: 1024, h: 1792 }, { w: 1792, h: 1024 }],
},
{ id: 'dall-e-2',
{
puterId: 'openai:openai/dall-e-2',
id: 'dall-e-2',
aliases: ['openai/dall-e-2'],
name: 'DALL·E 2',
version: '1.0',
costs_currency: 'usd-cents',
@@ -2,8 +2,9 @@ import { IImageModel } from '../types';
export const XAI_IMAGE_GENERATION_MODELS: IImageModel[] = [
{
puterId: 'x-ai:x-ai/grok-2-image',
id: 'grok-2-image',
aliases: ['grok-image'],
aliases: ['grok-image', 'x-ai/grok-image', 'x-ai/grok-2-image'],
name: 'Grok 2 Image',
version: '1.0',
costs_currency: 'usd-cents',
@@ -1,6 +1,9 @@
export interface IImageModel {
id: string;
name: string;
puterId?: string;
provider?: string;
aliases?: string[];
description?: string;
version?: string;
costs_currency: string;
@@ -8,8 +11,6 @@ export interface IImageModel {
costs: Record<string, number>;
allowedQualityLevels?: string[];
allowedRatios?: { w: number, h: number }[];
provider?: string;
aliases?: string[];
}
export interface IGenerateParams {
@@ -26,4 +27,4 @@ export interface IImageProvider {
models (): Promise<IImageModel[]> | IImageModel[];
getDefaultModel (): string;
}
}