MCPcopy Create free account
hub / github.com/pollinations/pollinations / apiModelToModel

Function apiModelToModel

pollinations.ai/src/hooks/useModelList.ts:79–109  ·  view source on GitHub ↗
(model: RawModel, type: Model["type"])

Source from the content-addressed store, hash-verified

77}
78
79function apiModelToModel(model: RawModel, type: Model["type"]): Model | null {
80 const id = modelId(model);
81 if (!id) return null;
82
83 if (typeof model === "string") {
84 return {
85 id,
86 name: id,
87 title: id,
88 type,
89 hasImageInput: false,
90 hasAudioOutput: false,
91 hasVideoOutput: false,
92 };
93 }
94
95 return {
96 id,
97 name: id,
98 title: model.title || model.description?.split(" - ")[0]?.trim() || id,
99 description: model.description,
100 type,
101 hasImageInput: model.input_modalities?.includes("image") || false,
102 hasAudioOutput: model.output_modalities?.includes("audio") || false,
103 hasVideoOutput: model.output_modalities?.includes("video") || false,
104 inputModalities: model.input_modalities,
105 outputModalities: model.output_modalities,
106 voices: model.voices,
107 paid_only: model.paid_only,
108 };
109}
110
111async function fetchJson(url: string, headers?: Record<string, string>) {
112 const response = await fetch(url, { headers });

Callers 1

fetchCatalogModelsFunction · 0.85

Calls 1

modelIdFunction · 0.85

Tested by

no test coverage detected