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

Function generateImage

apps/chat/src/utils/api.js:502–540  ·  view source on GitHub ↗
(prompt, options = {})

Source from the content-addressed store, hash-verified

500};
501
502export const generateImage = async (prompt, options = {}) => {
503 const {
504 model = "flux",
505 width = 1024,
506 height = 1024,
507 seed = Math.floor(Math.random() * 2147483647),
508 nologo = false,
509 enhance = false,
510 nofeed = false,
511 safe = false,
512 quality = "medium",
513 } = options;
514
515 const params = new URLSearchParams({
516 model,
517 width,
518 height,
519 seed,
520 enhance,
521 nologo,
522 nofeed,
523 safe,
524 quality,
525 });
526 const url = `${BASE_URL}/image/${encodeURIComponent(prompt)}?${params}`;
527 const token = getApiToken();
528 const headers = token ? { Authorization: `Bearer ${token}` } : {};
529 const response = await fetch(url, { headers });
530 if (!response.ok) throw await parseApiError(response);
531
532 const blob = await response.blob();
533 return new Promise((resolve, reject) => {
534 const reader = new FileReader();
535 reader.onloadend = () =>
536 resolve({ url: reader.result, prompt, model, width, height, seed });
537 reader.onerror = reject;
538 reader.readAsDataURL(blob);
539 });
540};
541
542export const generateVideo = async (prompt, options = {}) => {
543 const {

Callers 1

AppFunction · 0.90

Calls 4

getApiTokenFunction · 0.85
blobMethod · 0.80
parseApiErrorFunction · 0.70
fetchFunction · 0.50

Tested by

no test coverage detected