> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bettertoken.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini चित्र संपादन API

> BetterToken की Gemini API से Nano Banana चित्र संपादित करें। संदर्भ चित्र और निर्देश भेजें, ऑनलाइन अनुरोध आज़माएं और उत्तर से चित्र डेटा पढ़ें।

export const GeminiImageInput = ({labels}) => {
  const [images, setImages] = useState([]);
  const [busy, setBusy] = useState(false);
  const [feedback, setFeedback] = useState("");
  const selection = useRef(0);
  const inputId = useId();
  const readImages = async event => {
    const version = ++selection.current;
    const files = Array.from(event.target.files || []);
    setImages([]);
    setFeedback("");
    if (files.some(file => !["image/png", "image/jpeg"].includes(file.type))) {
      setFeedback(labels[4]);
      setBusy(false);
      return;
    }
    setBusy(true);
    try {
      const next = await Promise.all(files.map(file => new Promise((resolve, reject) => {
        const reader = new FileReader();
        reader.onload = () => resolve({
          name: file.name,
          type: file.type,
          data: String(reader.result).split(",")[1]
        });
        reader.onerror = reject;
        reader.onabort = reject;
        reader.readAsDataURL(file);
      })));
      if (version === selection.current) setImages(next);
    } catch {
      if (version === selection.current) setFeedback(labels[5]);
    } finally {
      if (version === selection.current) setBusy(false);
    }
  };
  const copy = async value => {
    try {
      await navigator.clipboard.writeText(value);
      setFeedback(labels[2]);
    } catch {
      setFeedback(labels[3]);
    }
  };
  return <section className="bt-gemini-input not-prose" aria-label={labels[0]}>
      <label htmlFor={inputId}>{labels[0]}</label>
      <input id={inputId} type="file" accept="image/png,image/jpeg" multiple onChange={readImages} />
      <p>{labels[7]}</p>
      <p role="status" aria-live="polite">{busy ? labels[6] : feedback}</p>
      {images.map((image, index) => <div key={index} className="bt-gemini-input-image">
          <div className="bt-gemini-input-header">
            <img src={"data:" + image.type + ";base64," + image.data} alt={image.name} />
            <span>{image.name}</span>
            <code>{image.type}</code>
            <button type="button" title={labels[1]} aria-label={labels[1] + " " + image.name} onClick={() => copy(image.data)}><Icon icon="copy" size={16} /></button>
          </div>
          <textarea aria-label={labels[1] + " " + image.name} rows={3} readOnly value={image.data} spellCheck={false} />
        </div>)}
    </section>;
};

Nano Banana Pro, 2 या 2.1 को संदर्भ चित्र और संपादन निर्देश देकर बदला हुआ चित्र बनाएं।

`POST /v1beta/models/{model}:generateContent`

टेक्स्ट से चित्र और चित्र संपादन एक ही endpoint उपयोग करते हैं। संपादन के अनुरोध में संदर्भ चित्र जोड़ा जाता है।

## संदर्भ चित्र तैयार करें

टेक्स्ट और हर चित्र अलग part में रखें। `inlineData.data` में Data URL उपसर्ग के बिना मूल base64 दें। PNG या JPEG संदर्भ उपयोग करें; यह endpoint JSON लेता है, multipart या चित्र URL नहीं।

भेजने से पहले `REPLACE_WITH_IMAGE_BASE64` को अपने चित्र के base64 से बदलें और फ़ाइल के अनुसार `inlineData.mimeType` दें। उदाहरण का निर्देश कप के लिए है; अन्य विषय हो तो निर्देश भी बदलें।

<GeminiImageInput labels={["संदर्भ चित्र","base64 कॉपी करें","कॉपी हो गया","नीचे का base64 चुनकर कॉपी करें।","PNG या JPEG चित्र चुनें।","चित्र पढ़ा नहीं जा सका। फिर से चुनें।","चित्र तैयार हो रहे हैं...","चित्र स्थानीय रूप से बदले जाते हैं। Playground में inlineData.data को कॉपी किए base64 से बदलें और inlineData.mimeType में दिखाया गया MIME प्रकार दें। हर अतिरिक्त चित्र अलग part में रखें।"]} />

## अनुरोध आज़माएं

पहले संदर्भ चित्र तैयार करें। **x-goog-api-key** में BetterToken API Key दें और **model** चुनें। **contents** में संपादन निर्देश और चित्र डेटा दें। जांचें कि `inlineData.data` बदला गया है और `inlineData.mimeType` फ़ाइल से मेल खाता है, फिर **Send** दबाएं।

<Note>
  **Send** दबाने से वास्तविक निर्माण अनुरोध जाता है और शुल्क लग सकता है। synchronous प्रतिक्रिया की प्रतीक्षा करें। timeout या कनेक्शन टूटने पर, फिर भेजने से पहले उपयोग रिकॉर्ड और अनुरोध का परिणाम जांचें।
</Note>

तीनों में `1K`, `2K` और `4K` हैं। Nano Banana 2 और 2.1 में 14 अनुपात और Pro में 10 अनुपात समर्थित हैं। `X-BetterToken-Max-Images` लौटाए और बिल किए जाने वाले चित्रों की सीमा है, निश्चित संख्या की गारंटी नहीं। [समर्थित अनुपात](/hi/api-reference/nano-banana#aspect-ratios)

<Warning>
  BetterToken API खोज की मदद से चित्र बनाना समर्थित नहीं करता, जिसमें Google वेब खोज और चित्र खोज grounding शामिल हैं। खोज टूल न जोड़ें।
</Warning>

बिना streaming वाला `generateContent` उपयोग करें। इस कनेक्शन में Files / `fileData`, Batch, Interactions और streaming समर्थित नहीं हैं।

## उत्तर पढ़ें

चित्र `candidates[].content.parts[].inlineData` में मिलते हैं। सभी parts पढ़ें, `thought: true` छोड़ें, `data` डिकोड करें और `mimeType` से फ़ाइल एक्सटेंशन चुनें। चित्र हमेशा पहले part में या PNG में नहीं होता।

## संबंधित गाइड

* [टेक्स्ट से चित्र](/hi/api-reference/gemini-images-generations)
* [SDK, चित्र सहेजना और लगातार संपादन](/hi/api-reference/nano-banana)
* [मॉडल परिचय](/hi/model-updates/nano-banana)
* <a href={"https://bettertoken.ai/pricing"}>मॉडल कैटलॉग</a>


## OpenAPI

````yaml api-reference/gemini-images-edits.hi.json POST /v1beta/models/{model}:generateContent
openapi: 3.1.0
info:
  title: Gemini चित्र संपादन API
  description: >-
    BetterToken की Gemini API से Nano Banana चित्र संपादित करें। संदर्भ चित्र और
    निर्देश भेजें, ऑनलाइन अनुरोध आज़माएं और उत्तर से चित्र डेटा पढ़ें।
  version: 1.0.0
servers:
  - url: https://bettertoken.ai
security:
  - geminiApiKey: []
paths:
  /v1beta/models/{model}:generateContent:
    post:
      summary: Gemini चित्र संपादन API
      description: >-
        Nano Banana Pro, 2 या 2.1 को संदर्भ चित्र और संपादन निर्देश देकर बदला
        हुआ चित्र बनाएं। BetterToken API खोज की मदद से चित्र बनाना समर्थित नहीं
        करता, जिसमें Google वेब खोज और चित्र खोज grounding शामिल हैं। खोज टूल न
        जोड़ें।
      operationId: editGeminiImage_hi
      parameters:
        - name: model
          in: path
          required: true
          description: BetterToken मॉडल ID। तीन Nano Banana मॉडल में से चुनें।
          schema:
            type: string
            enum:
              - nano-banana-pro
              - nano-banana-2
              - nano-banana-2.1
            default: nano-banana-2.1
        - name: X-BetterToken-Max-Images
          in: header
          description: >-
            लौटाए और बिल किए जाने वाले चित्रों की अधिकतम संख्या, गारंटी नहीं।
            डिफ़ॉल्ट 1।
          schema:
            type: integer
            minimum: 1
            maximum: 4
            default: 1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - contents
              properties:
                contents:
                  type: array
                  description: >-
                    बातचीत का इतिहास। अगले संपादन के लिए मॉडल का पूरा content और
                    thoughtSignature रखें।
                  minItems: 1
                  items:
                    type: object
                    required:
                      - parts
                    properties:
                      role:
                        type: string
                        description: >-
                          नए अनुरोध में user और इतिहास के पुराने मॉडल उत्तर में
                          model।
                        enum:
                          - user
                          - model
                        default: user
                      parts:
                        type: array
                        description: >-
                          टेक्स्ट और चित्र। text तथा inlineData अलग parts में
                          रखें।
                        minItems: 1
                        items:
                          anyOf:
                            - type: object
                              required:
                                - text
                              properties:
                                text:
                                  type: string
                                  description: चित्र विवरण या संपादन निर्देश।
                                  example: >-
                                    मग को लाल कर दें। उसका आकार, पृष्ठभूमि और
                                    रोशनी वही रखें।
                              additionalProperties: true
                            - type: object
                              required:
                                - inlineData
                              properties:
                                inlineData:
                                  type: object
                                  description: base64 में शामिल संदर्भ चित्र।
                                  required:
                                    - mimeType
                                    - data
                                  properties:
                                    mimeType:
                                      type: string
                                      description: संदर्भ चित्र का MIME प्रकार।
                                      enum:
                                        - image/png
                                        - image/jpeg
                                      example: image/png
                                    data:
                                      type: string
                                      description: >-
                                        मूल चित्र के bytes का base64, Data URL
                                        prefix के बिना। भेजने से पहले
                                        REPLACE_WITH_IMAGE_BASE64 को अपने PNG या
                                        JPEG के डेटा से बदलें।
                                      contentEncoding: base64
                                      example: REPLACE_WITH_IMAGE_BASE64
                                  additionalProperties: false
                              additionalProperties: true
                    additionalProperties: false
                generationConfig:
                  type: object
                  description: चित्र निर्माण सेटिंग।
                  properties:
                    responseModalities:
                      type: array
                      description: चित्र आउटपुट स्पष्ट रूप से मांगें।
                      items:
                        type: string
                        enum:
                          - IMAGE
                      default:
                        - IMAGE
                    candidateCount:
                      type: integer
                      enum:
                        - 1
                      default: 1
                      description: छोड़ दें या पूर्णांक 1 दें। मूल स्तर पर n न भेजें।
                    imageConfig:
                      type: object
                      description: आउटपुट चित्र सेटिंग।
                      properties:
                        imageSize:
                          type: string
                          description: आउटपुट रिज़ॉल्यूशन। बड़ा K उपयोग करें।
                          enum:
                            - 1K
                            - 2K
                            - 4K
                          default: 1K
                        aspectRatio:
                          type: string
                          description: >-
                            अनुपात। Pro में 10; 2 और 2.1 में 1:4, 4:1, 1:8 और
                            8:1 भी हैं।
                          enum:
                            - '1:1'
                            - '1:4'
                            - '1:8'
                            - '2:3'
                            - '3:2'
                            - '3:4'
                            - '4:1'
                            - '4:3'
                            - '4:5'
                            - '5:4'
                            - '8:1'
                            - '9:16'
                            - '16:9'
                            - '21:9'
                          default: '1:1'
                      additionalProperties: false
                  additionalProperties: false
              additionalProperties: false
            example:
              contents:
                - role: user
                  parts:
                    - text: >-
                        मग को लाल कर दें। उसका आकार, पृष्ठभूमि और रोशनी वही
                        रखें।
                    - inlineData:
                        mimeType: image/png
                        data: REPLACE_WITH_IMAGE_BASE64
              generationConfig:
                responseModalities:
                  - IMAGE
                candidateCount: 1
                imageConfig:
                  imageSize: 1K
                  aspectRatio: '1:1'
      responses:
        '200':
          description: परिणाम। अंतिम चित्र parts और finishReason जांचें।
          content:
            application/json:
              schema:
                type: object
                properties:
                  candidates:
                    type: array
                    items:
                      type: object
                      properties:
                        content:
                          type: object
                          properties:
                            role:
                              type: string
                            parts:
                              type: array
                              items:
                                type: object
                                properties:
                                  text:
                                    type: string
                                  thought:
                                    type: boolean
                                  thoughtSignature:
                                    type: string
                                  inlineData:
                                    type: object
                                    properties:
                                      mimeType:
                                        type: string
                                      data:
                                        type: string
                                        contentEncoding: base64
                        finishReason:
                          type: string
                  promptFeedback:
                    type: object
                    additionalProperties: true
                  usageMetadata:
                    type: object
                    additionalProperties: true
              example:
                candidates:
                  - content:
                      role: model
                      parts:
                        - inlineData:
                            mimeType: image/png
                            data: BASE64_IMAGE_DATA
                    finishReason: STOP
        '400':
          description: अमान्य पैरामीटर या असमर्थित सुविधा।
        '401':
          description: API Key नहीं है या अमान्य है।
        '402':
          description: बैलेंस अपर्याप्त है।
        '429':
          description: अनुरोध सीमा या सेवा व्यस्त है।
        '500':
          description: निर्माण त्रुटि। दोबारा भेजने से पहले परिणाम जांचें।
components:
  securitySchemes:
    geminiApiKey:
      type: apiKey
      in: header
      name: x-goog-api-key
      description: BetterToken API Key।

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.