| const axios = require("axios"); |
|
|
| async function NanoBanana(prompt, imageUrl, cookie) { |
| try { |
| const api = `https://anabot.my.id/api/ai/geminiOption?prompt=${encodeURIComponent(prompt)}&type=NanoBanana&imageUrl=${encodeURIComponent(imageUrl)}&imageUrl2=&imageUrl3=&imageUrl4=&cookie=${encodeURIComponent(cookie)}&apikey=freeApikey`; |
|
|
| const response = await axios.get(api, { |
| headers: { 'Accept': 'application/json' } |
| }); |
|
|
| if (response.data && response.data.data && response.data.data.result) { |
| return { |
| success: true, |
| url: response.data.data.result.url, |
| prompt: prompt |
| }; |
| } |
|
|
| throw new Error('Gagal memproses gambar'); |
| } catch (err) { |
| throw new Error(err.response?.data?.message || err.message); |
| } |
| } |
|
|
| const handler = async (req, res) => { |
| try { |
| const { prompt, imageUrl, cookie, key } = req.query; |
|
|
| if (!key) { |
| return res.status(400).json({ |
| success: false, |
| error: 'Missing required parameter: key' |
| }); |
| } |
|
|
| if (!prompt) { |
| return res.status(400).json({ |
| success: false, |
| error: 'Missing required parameter: prompt' |
| }); |
| } |
|
|
| if (!imageUrl) { |
| return res.status(400).json({ |
| success: false, |
| error: 'Missing required parameter: imageUrl' |
| }); |
| } |
|
|
| if (!cookie) { |
| return res.status(400).json({ |
| success: false, |
| error: 'Missing required parameter: cookie' |
| }); |
| } |
|
|
| const result = await NanoBanana(prompt, imageUrl, cookie); |
|
|
| return res.json({ |
| author: "Herza", |
| success: true, |
| data: { |
| prompt: result.prompt, |
| image_url: result.url, |
| original_url: imageUrl |
| }, |
| timestamp: new Date().toISOString() |
| }); |
|
|
| } catch (error) { |
| res.status(500).json({ |
| success: false, |
| error: error.message, |
| timestamp: new Date().toISOString() |
| }); |
| } |
| }; |
|
|
| module.exports = { |
| name: 'Nano Banana', |
| description: 'AI Image Editing using Gemini - Edit images with text prompts', |
| type: 'GET', |
| routes: ['api/AI/nanobanana'], |
| tags: ['ai', 'image', 'editing', 'gemini', 'nanobanana'], |
| parameters: ['prompt', 'imageUrl', 'cookie', 'key'], |
| limit: 5, |
| enabled: true, |
| main: ['AI'], |
| handler, |
| NanoBanana |
| }; |