Created
February 2, 2026 04:28
-
-
Save lardratboy/b3aea5144ca4c1c3bedc2c9affaeb516 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function generateArtifactImage(signature) { | |
| // Convert signature (e.g. "0101-1110-...") into a more descriptive prompt | |
| const complexity = (signature.match(/1/g) || []).length; | |
| const prompt = `A mystical cosmic artifact, a geometric totem floating in space. | |
| The artifact has a ${complexity > 5 ? 'complex' : 'simple'} crystalline structure | |
| inspired by the pattern: ${signature}. Neon bioluminescent colors, | |
| ethereal nebula background, 8k, digital art, sci-fi relic.`; | |
| try { | |
| const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent?key=${apiKey}`, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ | |
| contents: [{ parts: [{ text: prompt }] }], | |
| generationConfig: { responseModalities: ['TEXT', 'IMAGE'] } | |
| }) | |
| }); | |
| const result = await response.json(); | |
| const base64 = result.candidates?.[0]?.content?.parts?.find(p => p.inlineData)?.inlineData?.data; | |
| return base64 ? `data:image/png;base64,${base64}` : null; | |
| } catch (e) { | |
| console.error("Image generation failed", e); | |
| return null; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment