MCPcopy Create free account
hub / github.com/MiniMax-AI/OpenRoom / generateImageOpenAI

Function generateImageOpenAI

apps/webuiapps/src/lib/imageGenClient.ts:115–148  ·  view source on GitHub ↗
(
  prompt: string,
  config: ImageGenConfig,
)

Source from the content-addressed store, hash-verified

113}
114
115async function generateImageOpenAI(
116 prompt: string,
117 config: ImageGenConfig,
118): Promise<ImageGenResult> {
119 const targetUrl = `${config.baseUrl}/v1/images/generations`;
120 const body = {
121 model: config.model,
122 prompt,
123 n: 1,
124 response_format: 'b64_json',
125 };
126
127 const res = await fetch('/api/llm-proxy', {
128 method: 'POST',
129 headers: {
130 'Content-Type': 'application/json',
131 Authorization: `Bearer ${config.apiKey}`,
132 'X-LLM-Target-URL': targetUrl,
133 ...parseCustomHeaders(config.customHeaders),
134 },
135 body: JSON.stringify(body),
136 });
137
138 if (!res.ok) {
139 const text = await res.text();
140 throw new Error(`Image API error ${res.status}: ${text}`);
141 }
142
143 const data = await res.json();
144 const b64 = data.data?.[0]?.b64_json;
145 if (!b64) throw new Error('No image data in response');
146
147 return { base64: b64, mimeType: 'image/png' };
148}
149
150async function generateImageGemini(
151 prompt: string,

Callers 1

generateImageFunction · 0.85

Calls 1

parseCustomHeadersFunction · 0.70

Tested by

no test coverage detected