File size: 2,275 Bytes
7e9ddb1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
};