class GeminiExtension { getInfo() { return { id: 'geminiSimple', name: 'Gemini', blocks: [ { opcode: 'requestGeminiFromProxy', blockType: Scratch.BlockType.REPORTER, text: 'Ask Gemini [TEXT]', arguments: { TEXT: { type: Scratch.ArgumentType.STRING, defaultValue: 'Write a story about a magic backpack' } } } ] }; } async requestGeminiFromProxy({ TEXT }) { const requestPayload = { text: TEXT }; const url = 'https://api.rubyteam.tech/generateContent'; try { const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(requestPayload) }); if (!response.ok) { throw new Error(`Gemini Proxy Error: ${response.status} - ${response.statusText}`); } const responseData = await response.json(); return responseData.candidates[0].content.parts[0].text; } catch (error) { console.error('Gemini Proxy Error:', error.message); return 'Error: Request to proxy failed'; } } } Scratch.extensions.register(new GeminiExtension());