Gjenerimi i imazhit Nano Banana

Kërkoni të krijoni prototipa aplikacionesh plotësisht funksionale dhe të plota me ndërfaqen e përdoruesit dhe shikoni Nano Banana 2 të integruar me mjete, të dhëna dhe ekosistemin Gemini të botës reale. E gjitha kjo përpara se të shkruani një rresht të vetëm kodi.
  • Provo një aplikacion Nano Banana 2
  • Ose ndërtoni vetë nga udhëzimet:
    • revistëLondërrivendosbananekafeneartikullqenizometrike
    • revistë
      Gjeneruar nga Nano Banana 2
      Pyetje: "Një foto e një kopertine me shkëlqim reviste, kopertina minimale blu ka fjalët e mëdha të trasha Nano Banana. Teksti është me shkronja serif dhe mbush pamjen. Asnjë tekst tjetër. Përpara tekstit ka një portret të një personi me një fustan elegant dhe minimalist. Ajo mban me shaka numrin 2, i cili është pika qendrore."
      Vendos numrin e botimit dhe datën "Shkurt 2026" në cep së bashku me një barkod. Revista është në një raft pranë një muri të suvatuar me portokalli, brenda një dyqani firmash.
    • Londër
      Gjeneruar nga Nano Banana Pro
      Nxitje: "Paraqitni një skenë të qartë, 45° nga lart poshtë, vizatimore 3D miniaturë izometrike të Londrës, duke paraqitur monumentet dhe elementët e saj arkitektonikë më ikonikë. Përdorni tekstura të buta dhe të rafinuara me materiale realiste PBR dhe ndriçim dhe hije të buta dhe të gjalla. Integroni kushtet aktuale të motit direkt në mjedisin e qytetit për të krijuar një atmosferë atmosferike gjithëpërfshirëse. Përdorni një kompozim të pastër dhe minimalist me një sfond të butë me ngjyra të forta. Në qendër të sipërme, vendosni titullin "Londër" me tekst të madh të trashë, një ikonë të spikatur moti poshtë tij, pastaj datën (tekst i vogël) dhe temperaturën (tekst mesatar). I gjithë teksti duhet të jetë i qendërzuar me hapësira të qëndrueshme dhe mund të mbivendoset lehtë me majat e ndërtesave."
      Mësoni më shumë rreth mbështetjes së kërkimit dhe provojeni në AI Studio
    • ketzal
      Gjeneruar nga Nano Banana 2
      Njoftim: "Përdorni kërkimin e imazheve për të gjetur imazhe të sakta të një zogu të shkëlqyer ketzal. Krijoni një sfond të bukur 3:2 të këtij zogu, me një gradient natyral nga lart poshtë dhe kompozim minimal."
      Përdorni tokëzimin e Kërkimit të Imazheve në Google me Nano Banana 2. Provojeni në AI Studio.
    • banane
      Gjeneruar nga Nano Banana Pro
      Nxitje: "Vendoseni këtë logo në një reklamë luksoze për një parfum me aromë bananeje. Logoja është integruar në mënyrë të përkryer në shishe."
    • kafene
      Gjeneruar nga Nano Banana Pro
      Njoftim: "Një foto e një skene të përditshme në një kafene të mbushur me njerëz që shërben mëngjes. Në plan të parë është një burrë anime me flokë blu, njëri prej personave është një skicues me laps, një tjetër është një person që punon me argjilë"
      Eksperimentoni me stile të ndryshme artistike me Nano Banana në AI Studio
    • artikull
      Gjeneruar nga Nano Banana Pro
      Njoftim: "Përdorni kërkimin për të gjetur se si është pritur lançimi i Gemini 3 Flash. Përdorni këtë informacion për të shkruar një artikull të shkurtër rreth tij (me tituj). Ktheni një foto të artikullit ashtu siç u shfaq në një revistë me shkëlqim të fokusuar në dizajn. Është një foto e një faqeje të vetme të palosur, që tregon artikullin rreth Gemini 3 Flash. Një foto kryesore. Titulli është me serif."
      Gjeneroni tekst të saktë nga kërkimi . Provoni Nano Banana në AI Studio.
    • qen
      Gjeneruar nga Nano Banana Pro
      Njoftim: "Një ikonë që përfaqëson një qen të lezetshëm. Sfondi është i bardhë. Krijoni ikonat në një stil 3D shumëngjyrësh dhe të prekshëm. Pa tekst."
      Krijo ikona, afishe dhe asete me Nano Banana në AI Studio
    • izometrike
      Gjeneruar nga Nano Banana 2
      Nxitje: "Bëni një foto që është në mënyrë perfekte izometrike. Nuk është një miniaturë, është një foto e kapur që rastësisht është në mënyrë perfekte izometrike. Është një foto e një kopshti të bukur modern. Ka një pishinë të madhe në formë 2 dhe fjalët: Nano Banana 2."

    Nano Banana është emri për aftësitë e gjenerimit të imazheve native të Gemini. Gemini mund të gjenerojë dhe përpunojë imazhe në mënyrë bisedore me tekst, imazhe ose një kombinim të të dyjave. Kjo ju lejon të krijoni, modifikoni dhe përsërisni pamjet me një kontroll të paparë.

    Nano Banana i referohet dy modeleve të dallueshme të disponueshme në Gemini API:

    • Nano Banana 2 : Modeli Gemini 3.1 Flash Image Preview ( gemini-3.1-flash-image-preview ). Ky model shërben si homologu me efikasitet të lartë i Gemini 3 Pro Image, i optimizuar për raste përdorimi nga zhvilluesit me shpejtësi dhe volum të lartë.
    • Nano Banana Pro : Modeli i Parapamjes së Imazhit Gemini 3 Pro ( gemini-3-pro-image-preview ). Ky model është projektuar për prodhimin profesional të aseteve, duke përdorur arsyetim të avancuar ("Të Menduarit") për të ndjekur udhëzime komplekse dhe për të paraqitur tekst me besnikëri të lartë.
    • Nano Banana : Modeli Gemini 2.5 Flash Image ( gemini-2.5-flash-image ). Ky model është projektuar për shpejtësi dhe efikasitet, i optimizuar për detyra me volum të lartë dhe me vonesë të ulët.

    Të gjitha imazhet e gjeneruara përfshijnë një filigran SynthID .

    Gjenerimi i imazhit (tekst-në-imazh)

    Python

    from google import genai
    from google.genai import types
    from PIL import Image
    
    client = genai.Client()
    
    prompt = ("Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme")
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[prompt],
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("generated_image.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const prompt =
        "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme";
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("gemini-native-image.png", buffer);
          console.log("Image saved as gemini-native-image.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
      "context"
      "fmt"
      "log"
      "os"
      "google.golang.org/genai"
    )
    
    func main() {
    
      ctx := context.Background()
      client, err := genai.NewClient(ctx, nil)
      if err != nil {
          log.Fatal(err)
      }
    
      result, _ := client.Models.GenerateContent(
          ctx,
          "gemini-3.1-flash-image-preview",
          genai.Text("Create a picture of a nano banana dish in a " +
                     " fancy restaurant with a Gemini theme"),
      )
    
      for _, part := range result.Candidates[0].Content.Parts {
          if part.Text != "" {
              fmt.Println(part.Text)
          } else if part.InlineData != nil {
              imageBytes := part.InlineData.Data
              outputFilename := "gemini_generated_image.png"
              _ = os.WriteFile(outputFilename, imageBytes, 0644)
          }
      }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class TextToImage {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme",
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("_01_generated_image.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{
          "parts": [
            {"text": "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"}
          ]
        }]
      }'
    

    Redaktimi i imazhit (tekst dhe imazh në imazh)

    Kujtesë : Sigurohuni që keni të drejtat e nevojshme për çdo imazh që ngarkoni. Mos gjeneroni përmbajtje që shkel të drejtat e të tjerëve, duke përfshirë video ose imazhe që mashtrojnë, ngacmojnë ose dëmtojnë. Përdorimi juaj i këtij shërbimi gjenerues të IA-së i nënshtrohet Politikës sonë të Përdorimit të Ndaluar .

    Jepni një imazh dhe përdorni udhëzime tekstuale për të shtuar, hequr ose modifikuar elementë, për të ndryshuar stilin ose për të rregulluar gradimin e ngjyrave.

    Shembulli i mëposhtëm demonstron ngarkimin e imazheve të koduara base64 . Për imazhe të shumëfishta, ngarkesa më të mëdha dhe lloje MIME të mbështetura, kontrolloni faqen Kuptimi i imazheve .

    Python

    from google import genai
    from google.genai import types
    from PIL import Image
    
    client = genai.Client()
    
    prompt = (
        "Create a picture of my cat eating a nano-banana in a "
        "fancy restaurant under the Gemini constellation",
    )
    
    image = Image.open("/path/to/cat_image.png")
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[prompt, image],
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("generated_image.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const imagePath = "path/to/cat_image.png";
      const imageData = fs.readFileSync(imagePath);
      const base64Image = imageData.toString("base64");
    
      const prompt = [
        { text: "Create a picture of my cat eating a nano-banana in a" +
                "fancy restaurant under the Gemini constellation" },
        {
          inlineData: {
            mimeType: "image/png",
            data: base64Image,
          },
        },
      ];
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("gemini-native-image.png", buffer);
          console.log("Image saved as gemini-native-image.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
     "context"
     "fmt"
     "log"
     "os"
     "google.golang.org/genai"
    )
    
    func main() {
    
     ctx := context.Background()
     client, err := genai.NewClient(ctx, nil)
     if err != nil {
         log.Fatal(err)
     }
    
     imagePath := "/path/to/cat_image.png"
     imgData, _ := os.ReadFile(imagePath)
    
     parts := []*genai.Part{
       genai.NewPartFromText("Create a picture of my cat eating a nano-banana in a fancy restaurant under the Gemini constellation"),
       &genai.Part{
         InlineData: &genai.Blob{
           MIMEType: "image/png",
           Data:     imgData,
         },
       },
     }
    
     contents := []*genai.Content{
       genai.NewContentFromParts(parts, genai.RoleUser),
     }
    
     result, _ := client.Models.GenerateContent(
         ctx,
         "gemini-3.1-flash-image-preview",
         contents,
     )
    
     for _, part := range result.Candidates[0].Content.Parts {
         if part.Text != "" {
             fmt.Println(part.Text)
         } else if part.InlineData != nil {
             imageBytes := part.InlineData.Data
             outputFilename := "gemini_generated_image.png"
             _ = os.WriteFile(outputFilename, imageBytes, 0644)
         }
     }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.Content;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    
    public class TextAndImageToImage {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              Content.fromParts(
                  Part.fromText("""
                      Create a picture of my cat eating a nano-banana in
                      a fancy restaurant under the Gemini constellation
                      """),
                  Part.fromBytes(
                      Files.readAllBytes(
                          Path.of("src/main/resources/cat.jpg")),
                      "image/jpeg")),
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("gemini_generated_image.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
        -H "x-goog-api-key: $GEMINI_API_KEY" \
        -H 'Content-Type: application/json' \
        -d "{
          \"contents\": [{
            \"parts\":[
                {\"text\": \"'Create a picture of my cat eating a nano-banana in a fancy restaurant under the Gemini constellation\"},
                {
                  \"inline_data\": {
                    \"mime_type\":\"image/jpeg\",
                    \"data\": \"<BASE64_IMAGE_DATA>\"
                  }
                }
            ]
          }]
        }"
    

    Redaktimi i imazhit me shumë kthesa

    Vazhdoni të gjeneroni dhe modifikoni imazhe në mënyrë bisedore. Mënyra e rekomanduar për të përsëritur imazhet është biseda ose biseda me shumë kthesa. Shembulli i mëposhtëm tregon një sugjerim për të gjeneruar një infografik rreth fotosintezës.

    Python

    from google import genai
    from google.genai import types
    
    client = genai.Client()
    
    chat = client.chats.create(
        model="gemini-3.1-flash-image-preview",
        config=types.GenerateContentConfig(
            response_modalities=['TEXT', 'IMAGE'],
            tools=[{"google_search": {}}]
        )
    )
    
    message = "Create a vibrant infographic that explains photosynthesis as if it were a recipe for a plant's favorite food. Show the \"ingredients\" (sunlight, water, CO2) and the \"finished dish\" (sugar/energy). The style should be like a page from a colorful kids' cookbook, suitable for a 4th grader."
    
    response = chat.send_message(message)
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif image:= part.as_image():
            image.save("photosynthesis.png")
    

    Javascript

    import { GoogleGenAI } from "@google/genai";
    
    const ai = new GoogleGenAI({});
    
    async function main() {
      const chat = ai.chats.create({
        model: "gemini-3.1-flash-image-preview",
        config: {
          responseModalities: ['TEXT', 'IMAGE'],
          tools: [{googleSearch: {}}],
        },
      });
    }
    
    await main();
    
    const message = "Create a vibrant infographic that explains photosynthesis as if it were a recipe for a plant's favorite food. Show the \"ingredients\" (sunlight, water, CO2) and the \"finished dish\" (sugar/energy). The style should be like a page from a colorful kids' cookbook, suitable for a 4th grader."
    
    let response = await chat.sendMessage({message});
    
    for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("photosynthesis.png", buffer);
          console.log("Image saved as photosynthesis.png");
        }
    }
    

    Shko

    package main
    
    import (
        "context"
        "fmt"
        "log"
        "os"
    
        "google.golang.org/genai"
    )
    
    func main() {
        ctx := context.Background()
        client, err := genai.NewClient(ctx, nil)
        if err != nil {
            log.Fatal(err)
        }
        defer client.Close()
    
        model := client.GenerativeModel("gemini-3.1-flash-image-preview")
        model.GenerationConfig = &pb.GenerationConfig{
            ResponseModalities: []pb.ResponseModality{genai.Text, genai.Image},
        }
        chat := model.StartChat()
    
        message := "Create a vibrant infographic that explains photosynthesis as if it were a recipe for a plant's favorite food. Show the \"ingredients\" (sunlight, water, CO2) and the \"finished dish\" (sugar/energy). The style should be like a page from a colorful kids' cookbook, suitable for a 4th grader."
    
        resp, err := chat.SendMessage(ctx, genai.Text(message))
        if err != nil {
            log.Fatal(err)
        }
    
        for _, part := range resp.Candidates[0].Content.Parts {
            if txt, ok := part.(genai.Text); ok {
                fmt.Printf("%s", string(txt))
            } else if img, ok := part.(genai.ImageData); ok {
                err := os.WriteFile("photosynthesis.png", img.Data, 0644)
                if err != nil {
                    log.Fatal(err)
                }
            }
        }
    }
    

    Java

    import com.google.genai.Chat;
    import com.google.genai.Client;
    import com.google.genai.types.Content;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.GoogleSearch;
    import com.google.genai.types.ImageConfig;
    import com.google.genai.types.Part;
    import com.google.genai.types.RetrievalConfig;
    import com.google.genai.types.Tool;
    import com.google.genai.types.ToolConfig;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    
    public class MultiturnImageEditing {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
    
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .tools(Tool.builder()
                  .googleSearch(GoogleSearch.builder().build())
                  .build())
              .build();
    
          Chat chat = client.chats.create("gemini-3.1-flash-image-preview", config);
    
          GenerateContentResponse response = chat.sendMessage("""
              Create a vibrant infographic that explains photosynthesis
              as if it were a recipe for a plant's favorite food.
              Show the "ingredients" (sunlight, water, CO2)
              and the "finished dish" (sugar/energy).
              The style should be like a page from a colorful
              kids' cookbook, suitable for a 4th grader.
              """);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("photosynthesis.png"), blob.data().get());
              }
            }
          }
          // ...
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{
          "role": "user",
          "parts": [
            {"text": "Create a vibrant infographic that explains photosynthesis as if it were a recipe for a plants favorite food. Show the \"ingredients\" (sunlight, water, CO2) and the \"finished dish\" (sugar/energy). The style should be like a page from a colorful kids cookbook, suitable for a 4th grader."}
          ]
        }],
        "generationConfig": {
          "responseModalities": ["TEXT", "IMAGE"]
        }
      }'
    
    Infografik i gjeneruar nga inteligjenca artificiale rreth fotosintezës
    Infografik i gjeneruar nga inteligjenca artificiale rreth fotosintezës

    Pastaj mund të përdorni të njëjtin bisedë për të ndryshuar gjuhën në grafik në spanjisht.

    Python

    message = "Update this infographic to be in Spanish. Do not change any other elements of the image."
    aspect_ratio = "16:9" # "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"
    resolution = "2K" # "512px", "1K", "2K", "4K"
    
    response = chat.send_message(message,
        config=types.GenerateContentConfig(
            image_config=types.ImageConfig(
                aspect_ratio=aspect_ratio,
                image_size=resolution
            ),
        ))
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif image:= part.as_image():
            image.save("photosynthesis_spanish.png")
    

    Javascript

    const message = 'Update this infographic to be in Spanish. Do not change any other elements of the image.';
    const aspectRatio = '16:9';
    const resolution = '2K';
    
    let response = await chat.sendMessage({
      message,
      config: {
        responseModalities: ['TEXT', 'IMAGE'],
        imageConfig: {
          aspectRatio: aspectRatio,
          imageSize: resolution,
        },
        tools: [{googleSearch: {}}],
      },
    });
    
    for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("photosynthesis2.png", buffer);
          console.log("Image saved as photosynthesis2.png");
        }
    }
    

    Shko

    message = "Update this infographic to be in Spanish. Do not change any other elements of the image."
    aspect_ratio = "16:9" // "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"
    resolution = "2K"     // "512px", "1K", "2K", "4K"
    
    model.GenerationConfig.ImageConfig = &pb.ImageConfig{
        AspectRatio: aspect_ratio,
        ImageSize:   resolution,
    }
    
    resp, err = chat.SendMessage(ctx, genai.Text(message))
    if err != nil {
        log.Fatal(err)
    }
    
    for _, part := range resp.Candidates[0].Content.Parts {
        if txt, ok := part.(genai.Text); ok {
            fmt.Printf("%s", string(txt))
        } else if img, ok := part.(genai.ImageData); ok {
            err := os.WriteFile("photosynthesis_spanish.png", img.Data, 0644)
            if err != nil {
                log.Fatal(err)
            }
        }
    }
    

    Java

    String aspectRatio = "16:9"; // "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"
    String resolution = "2K"; // "512px", "1K", "2K", "4K"
    
    config = GenerateContentConfig.builder()
        .responseModalities("TEXT", "IMAGE")
        .imageConfig(ImageConfig.builder()
            .aspectRatio(aspectRatio)
            .imageSize(resolution)
            .build())
        .build();
    
    response = chat.sendMessage(
        "Update this infographic to be in Spanish. " + 
        "Do not change any other elements of the image.",
        config);
    
    for (Part part : response.parts()) {
      if (part.text().isPresent()) {
        System.out.println(part.text().get());
      } else if (part.inlineData().isPresent()) {
        var blob = part.inlineData().get();
        if (blob.data().isPresent()) {
          Files.write(Paths.get("photosynthesis_spanish.png"), blob.data().get());
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H 'Content-Type: application/json' \
      -d '{
        "contents": [
          {
            "role": "user",
            "parts": [{"text": "Create a vibrant infographic that explains photosynthesis..."}]
          },
          {
            "role": "model",
            "parts": [{"inline_data": {"mime_type": "image/png", "data": "<PREVIOUS_IMAGE_DATA>"}}]
          },
          {
            "role": "user",
            "parts": [{"text": "Update this infographic to be in Spanish. Do not change any other elements of the image."}]
          }
        ],
        "tools": [{"google_search": {}}],
        "generationConfig": {
          "responseModalities": ["TEXT", "IMAGE"],
          "imageConfig": {
            "aspectRatio": "16:9",
            "imageSize": "2K"
          }
        }
      }'
    
    Infografik i gjeneruar nga inteligjenca artificiale i fotosintezës në spanjisht
    Infografik i gjeneruar nga inteligjenca artificiale i fotosintezës në spanjisht

    E re me modelet Gemini 3 Image

    Gemini 3 ofron modele të gjenerimit dhe redaktimit të imazheve të teknologjisë së fundit. Gemini 3.1 Flash Image është i optimizuar për shpejtësi dhe raste përdorimi me volum të lartë, dhe Gemini 3 Pro Image është i optimizuar për prodhimin profesional të aseteve. I projektuar për të përballuar rrjedhat më sfiduese të punës përmes arsyetimit të avancuar, ato shkëlqejnë në detyra komplekse krijimi dhe modifikimi me shumë kthesa.

    • Dalje me rezolucion të lartë : Aftësi të integruara gjenerimi për pamje 1K, 2K dhe 4K.
      • Imazhja Flash Gemini 3.1 shton rezolucionin më të vogël prej 512px (0.5K).
    • Renderim i avancuar i tekstit : I aftë të gjenerojë tekst të lexueshëm dhe të stilizuar për infografikë, menu, diagrame dhe asete marketingu.
    • Bazë me Kërkimin në Google : Modeli mund të përdorë Kërkimin në Google si një mjet për të verifikuar faktet dhe për të gjeneruar imazhe bazuar në të dhëna në kohë reale (p.sh., harta aktuale të motit, grafikë të aksioneve, ngjarje të fundit).
      • Gemini 3.1 Flash Image shton integrimin e Google Image Search Grounding së bashku me Web Search.
    • Modaliteti i të menduarit : Modeli përdor një proces "të të menduarit" për të arsyetuar përmes pyetjeve komplekse. Ai gjeneron "imazhe mendimi" të ndërmjetme (të dukshme në sfond, por jo të ngarkuara) për të rafinuar kompozimin përpara se të prodhojë rezultatin përfundimtar me cilësi të lartë.
    • Deri në 14 imazhe referuese : Tani mund të përzieni deri në 14 imazhe referuese për të prodhuar imazhin përfundimtar.
    • Raporte të reja aspektesh : Pamja paraprake e imazhit Gemini 3.1 Flash shton raporte aspektesh 1:4, 4:1, 1:8 dhe 8:1.

    Përdorni deri në 14 imazhe referuese

    Modelet e imazheve Gemini 3 ju lejojnë të përzieni deri në 14 imazhe referuese. Këto 14 imazhe mund të përfshijnë sa vijon:

    Pamje paraprake e imazhit të flashit Gemini 3.1 Pamje paraprake e imazhit të Gemini 3 Pro
    Deri në 10 imazhe të objekteve me besueshmëri të lartë për t'u përfshirë në imazhin përfundimtar Deri në 6 imazhe të objekteve me besueshmëri të lartë për t'u përfshirë në imazhin përfundimtar
    Deri në 4 imazhe të personazheve për të ruajtur qëndrueshmërinë e personazheve Deri në 5 imazhe të personazheve për të ruajtur qëndrueshmërinë e personazheve

    Python

    from google import genai
    from google.genai import types
    from PIL import Image
    
    prompt = "An office group photo of these people, they are making funny faces."
    aspect_ratio = "5:4" # "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"
    resolution = "2K" # "512px", "1K", "2K", "4K"
    
    client = genai.Client()
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[
            prompt,
            Image.open('person1.png'),
            Image.open('person2.png'),
            Image.open('person3.png'),
            Image.open('person4.png'),
            Image.open('person5.png'),
        ],
        config=types.GenerateContentConfig(
            response_modalities=['TEXT', 'IMAGE'],
            image_config=types.ImageConfig(
                aspect_ratio=aspect_ratio,
                image_size=resolution
            ),
        )
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif image:= part.as_image():
            image.save("office.png")
    

    Javascript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const prompt =
          'An office group photo of these people, they are making funny faces.';
      const aspectRatio = '5:4';
      const resolution = '2K';
    
    const contents = [
      { text: prompt },
      {
        inlineData: {
          mimeType: "image/jpeg",
          data: base64ImageFile1,
        },
      },
      {
        inlineData: {
          mimeType: "image/jpeg",
          data: base64ImageFile2,
        },
      },
      {
        inlineData: {
          mimeType: "image/jpeg",
          data: base64ImageFile3,
        },
      },
      {
        inlineData: {
          mimeType: "image/jpeg",
          data: base64ImageFile4,
        },
      },
      {
        inlineData: {
          mimeType: "image/jpeg",
          data: base64ImageFile5,
        },
      }
    ];
    
    const response = await ai.models.generateContent({
        model: 'gemini-3.1-flash-image-preview',
        contents: contents,
        config: {
          responseModalities: ['TEXT', 'IMAGE'],
          imageConfig: {
            aspectRatio: aspectRatio,
            imageSize: resolution,
          },
        },
      });
    
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("image.png", buffer);
          console.log("Image saved as image.png");
        }
      }
    
    }
    
    main();
    

    Shko

    package main
    
    import (
        "context"
        "fmt"
        "log"
        "os"
    
        "google.golang.org/genai"
    )
    
    func main() {
        ctx := context.Background()
        client, err := genai.NewClient(ctx, nil)
        if err != nil {
            log.Fatal(err)
        }
        defer client.Close()
    
        model := client.GenerativeModel("gemini-3.1-flash-image-preview")
        model.GenerationConfig = &pb.GenerationConfig{
            ResponseModalities: []pb.ResponseModality{genai.Text, genai.Image},
            ImageConfig: &pb.ImageConfig{
                AspectRatio: "5:4",
                ImageSize:   "2K",
            },
        }
    
        img1, err := os.ReadFile("person1.png")
        if err != nil { log.Fatal(err) }
        img2, err := os.ReadFile("person2.png")
        if err != nil { log.Fatal(err) }
        img3, err := os.ReadFile("person3.png")
        if err != nil { log.Fatal(err) }
        img4, err := os.ReadFile("person4.png")
        if err != nil { log.Fatal(err) }
        img5, err := os.ReadFile("person5.png")
        if err != nil { log.Fatal(err) }
    
        parts := []genai.Part{
            genai.Text("An office group photo of these people, they are making funny faces."),
            genai.ImageData{MIMEType: "image/png", Data: img1},
            genai.ImageData{MIMEType: "image/png", Data: img2},
            genai.ImageData{MIMEType: "image/png", Data: img3},
            genai.ImageData{MIMEType: "image/png", Data: img4},
            genai.ImageData{MIMEType: "image/png", Data: img5},
        }
    
        resp, err := model.GenerateContent(ctx, parts...)
        if err != nil {
            log.Fatal(err)
        }
    
        for _, part := range resp.Candidates[0].Content.Parts {
            if txt, ok := part.(genai.Text); ok {
                fmt.Printf("%s", string(txt))
            } else if img, ok := part.(genai.ImageData); ok {
                err := os.WriteFile("office.png", img.Data, 0644)
                if err != nil {
                    log.Fatal(err)
                }
            }
        }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.Content;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.ImageConfig;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    
    public class GroupPhoto {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .imageConfig(ImageConfig.builder()
                  .aspectRatio("5:4")
                  .imageSize("2K")
                  .build())
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              Content.fromParts(
                  Part.fromText("An office group photo of these people, they are making funny faces."),
                  Part.fromBytes(Files.readAllBytes(Path.of("person1.png")), "image/png"),
                  Part.fromBytes(Files.readAllBytes(Path.of("person2.png")), "image/png"),
                  Part.fromBytes(Files.readAllBytes(Path.of("person3.png")), "image/png"),
                  Part.fromBytes(Files.readAllBytes(Path.of("person4.png")), "image/png"),
                  Part.fromBytes(Files.readAllBytes(Path.of("person5.png")), "image/png")
              ), config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("office.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
        -H "x-goog-api-key: $GEMINI_API_KEY" \
        -H 'Content-Type: application/json' \
        -d "{
          \"contents\": [{
            \"parts\":[
                {\"text\": \"An office group photo of these people, they are making funny faces.\"},
                {\"inline_data\": {\"mime_type\":\"image/png\", \"data\": \"<BASE64_DATA_IMG_1>\"}},
                {\"inline_data\": {\"mime_type\":\"image/png\", \"data\": \"<BASE64_DATA_IMG_2>\"}},
                {\"inline_data\": {\"mime_type\":\"image/png\", \"data\": \"<BASE64_DATA_IMG_3>\"}},
                {\"inline_data\": {\"mime_type\":\"image/png\", \"data\": \"<BASE64_DATA_IMG_4>\"}},
                {\"inline_data\": {\"mime_type\":\"image/png\", \"data\": \"<BASE64_DATA_IMG_5>\"}}
            ]
          }],
          \"generationConfig\": {
            \"responseModalities\": [\"TEXT\", \"IMAGE\"],
            \"imageConfig\": {
              \"aspectRatio\": \"5:4\",
              \"imageSize\": \"2K\"
            }
          }
        }"
    
    Foto grupore zyre e gjeneruar nga inteligjenca artificiale
    Foto grupore zyre e gjeneruar nga inteligjenca artificiale

    Bazë me Kërkimin në Google

    Përdorni mjetin e Kërkimit në Google për të gjeneruar imazhe bazuar në informacione në kohë reale, siç janë parashikimet e motit, grafikët e aksioneve ose ngjarjet e fundit.

    Vini re se kur përdorni Grounding me Google Search me gjenerimin e imazheve, rezultatet e kërkimit të bazuara në imazhe nuk i kalohen modelit të gjenerimit dhe përjashtohen nga përgjigja (shih Grounding me Google Image Search )

    Python

    from google import genai
    prompt = "Visualize the current weather forecast for the next 5 days in San Francisco as a clean, modern weather chart. Add a visual on what I should wear each day"
    aspect_ratio = "16:9" # "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"
    
    client = genai.Client()
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=prompt,
        config=types.GenerateContentConfig(
            response_modalities=['Text', 'Image'],
            image_config=types.ImageConfig(
                aspect_ratio=aspect_ratio,
            ),
            tools=[{"google_search": {}}]
        )
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif image:= part.as_image():
            image.save("weather.png")
    

    Javascript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const prompt = 'Visualize the current weather forecast for the next 5 days in San Francisco as a clean, modern weather chart. Add a visual on what I should wear each day';
      const aspectRatio = '16:9';
      const resolution = '2K';
    
    const response = await ai.models.generateContent({
        model: 'gemini-3.1-flash-image-preview',
        contents: prompt,
        config: {
          responseModalities: ['TEXT', 'IMAGE'],
          imageConfig: {
            aspectRatio: aspectRatio,
            imageSize: resolution,
          },
        tools: [{ googleSearch: {} }]
        },
      });
    
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("image.png", buffer);
          console.log("Image saved as image.png");
        }
      }
    
    }
    
    main();
    
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.GoogleSearch;
    import com.google.genai.types.ImageConfig;
    import com.google.genai.types.Part;
    import com.google.genai.types.Tool;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class SearchGrounding {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .imageConfig(ImageConfig.builder()
                  .aspectRatio("16:9")
                  .build())
              .tools(Tool.builder()
                  .googleSearch(GoogleSearch.builder().build())
                  .build())
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview", """
                  Visualize the current weather forecast for the next 5 days
                  in San Francisco as a clean, modern weather chart.
                  Add a visual on what I should wear each day
                  """,
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("weather.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{"parts": [{"text": "Visualize the current weather forecast for the next 5 days in San Francisco as a clean, modern weather chart. Add a visual on what I should wear each day"}]}],
        "tools": [{"google_search": {}}],
        "generationConfig": {
          "responseModalities": ["TEXT", "IMAGE"],
          "imageConfig": {"aspectRatio": "16:9"}
        }
      }'
    
    Grafik moti pesë-ditor i gjeneruar nga inteligjenca artificiale për San Franciskon
    Grafik moti pesë-ditor i gjeneruar nga inteligjenca artificiale për San Franciskon

    Përgjigja përfshin groundingMetadata e cila përmban fushat e mëposhtme të kërkuara:

    • searchEntryPoint : Përmban HTML dhe CSS për të paraqitur sugjerimet e kërkuara të kërkimit.
    • groundingChunks : Kthen 3 burimet kryesore të internetit të përdorura për të tokëzuar imazhin e gjeneruar

    Grounding with Google Image Search u lejon modeleve të përdorin imazhet e uebit të marra nëpërmjet Google Image Search si kontekst vizual për gjenerimin e imazheve. Image Search është një lloj i ri kërkimi brenda mjetit ekzistues Grounding with Google Search, i cili funksionon së bashku me Web Search standard.

    Për të aktivizuar Kërkimin e Imazheve, konfiguroni mjetin googleSearch në kërkesën tuaj API dhe specifikoni imageSearch brenda objektit searchTypes . Kërkimi i Imazheve mund të përdoret në mënyrë të pavarur ose së bashku me Kërkimin në Ueb.

    Python

    from google import genai
    prompt = "A detailed painting of a Timareta butterfly resting on a flower"
    
    client = genai.Client()
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=prompt,
        config=types.GenerateContentConfig(
            response_modalities=["IMAGE"],
            tools=[
                types.Tool(google_search=types.GoogleSearch(
                    search_types=types.SearchTypes(
                        web_search=types.WebSearch(),
                        image_search=types.ImageSearch()
                    )
                ))
            ]
        )
    )
    
    # Display grounding sources if available
    if response.candidates and response.candidates[0].grounding_metadata and response.candidates[0].grounding_metadata.search_entry_point:
        display(HTML(response.candidates[0].grounding_metadata.search_entry_point.rendered_content))
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const prompt = "A detailed painting of a Timareta butterfly resting on a flower";
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
        config: {
          responseModalities: ["IMAGE"],
          tools: [
            {
              googleSearch: {
                searchTypes: {
                  webSearch: {},
                  imageSearch: {}
                }
              }
            }
          ]
        }
      });
    
      // Display grounding sources if available
      if (response.candidates && response.candidates[0].groundingMetadata && response.candidates[0].groundingMetadata.searchEntryPoint) {
          console.log(response.candidates[0].groundingMetadata.searchEntryPoint.renderedContent);
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
      "context"
      "fmt"
      "log"
    
      "google.golang.org/genai"
      pb "google.golang.org/genai/schema"
    )
    
    func main() {
      ctx := context.Background()
      client, err := genai.NewClient(ctx, nil)
      if err != nil {
        log.Fatal(err)
      }
      defer client.Close()
    
      model := client.GenerativeModel("gemini-3.1-flash-image-preview")
      model.Tools = []*pb.Tool{
        {
          GoogleSearch: &pb.GoogleSearch{
            SearchTypes: &pb.SearchTypes{
              WebSearch:   &pb.WebSearch{},
              ImageSearch: &pb.ImageSearch{},
            },
          },
        },
      }
      model.GenerationConfig = &pb.GenerationConfig{
        ResponseModalities: []pb.ResponseModality{genai.Image},
      }
    
      prompt := "A detailed painting of a Timareta butterfly resting on a flower"
      resp, err := model.GenerateContent(ctx, genai.Text(prompt))
      if err != nil {
        log.Fatal(err)
      }
    
      if resp.Candidates[0].GroundingMetadata != nil && resp.Candidates[0].GroundingMetadata.SearchEntryPoint != nil {
        fmt.Println(resp.Candidates[0].GroundingMetadata.SearchEntryPoint.RenderedContent)
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{"parts": [{"text": "A detailed painting of a Timareta butterfly resting on a flower"}]}],
        "tools": [{"google_search": {"searchTypes": {"webSearch": {}, "imageSearch": {}}}}],
        "generationConfig": {
          "responseModalities": ["IMAGE"]
        }
      }'
    

    Kërkesat e ekranit

    Kur përdorni Kërkimin e Imazheve brenda Grounding me Kërkimin Google, duhet të përmbushni kushtet e mëposhtme:

    • Atribuimi i burimit : Duhet të jepni një lidhje për në faqen e internetit që përmban imazhin burimor ("faqja që përmban", jo vetë skedari i imazhit) në një mënyrë që përdoruesi ta njohë si lidhje.
    • Navigim direkt : Nëse zgjidhni të shfaqni edhe imazhet burimore, duhet të ofroni një shteg të drejtpërdrejtë me një klikim nga imazhet burimore në faqen e internetit burimore që i përmban ato. Çdo zbatim tjetër që vonon ose abstrakton aksesin e përdoruesit fundor në faqen e internetit burimore, duke përfshirë, por pa u kufizuar në, çdo shteg me shumë klikime ose përdorimin e një shikuesi të ndërmjetëm të imazheve, nuk lejohet.

    Përgjigje

    Për përgjigjet e bazuara duke përdorur kërkimin e imazheve, API ofron atribuim dhe meta të dhëna të qarta për të lidhur rezultatin e tij me burime të verifikuara. Fushat kryesore në objektin groundingMetadata përfshijnë:

    • imageSearchQueries : Pyetjet specifike të përdorura nga modeli për kontekstin vizual (kërkim imazhi).
    • groundingChunks : Përmban informacionin burimor për rezultatet e marra. Për burimet e imazheve, këto do të kthehen si URL ridrejtuese duke përdorur një lloj të ri të pjesës së imazhit. Kjo pjesë përfshin:

      • uri : URL-ja e faqes së internetit për atribuim (faqja e destinacionit).
      • image_uri : URL-ja e drejtpërdrejtë e imazhit.
    • groundingSupports : Ofron përputhje specifike që lidhin përmbajtjen e gjeneruar me burimin e saj përkatës të citimit në pjesë.

    • searchEntryPoint : Përfshin çipin "Kërkimi në Google" që përmban HTML dhe CSS në përputhje me standardet për të paraqitur Sugjerimet e Kërkimit.

    Gjeneroni imazhe me rezolucion deri në 4K

    Modelet e imazheve Gemini 3 gjenerojnë imazhe 1K si parazgjedhje, por mund të prodhojnë edhe imazhe 2K, 4K dhe 512px (05.K) (vetëm Imazh Flash Gemini 3.1). Për të gjeneruar asete me rezolucion më të lartë, specifikoni madhësinë e image_sizegeneration_config .

    Duhet të përdorni një 'K' me shkronjë të madhe (p.sh. 512px (05.K), 1K, 2K, 4K). Parametrat me shkronjë të vogël (p.sh., 1k) do të refuzohen.

    Python

    from google import genai
    from google.genai import types
    
    prompt = "Da Vinci style anatomical sketch of a dissected Monarch butterfly. Detailed drawings of the head, wings, and legs on textured parchment with notes in English."
    aspect_ratio = "1:1" # "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"
    resolution = "1K" # "512px", "1K", "2K", "4K"
    
    client = genai.Client()
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=prompt,
        config=types.GenerateContentConfig(
            response_modalities=['TEXT', 'IMAGE'],
            image_config=types.ImageConfig(
                aspect_ratio=aspect_ratio,
                image_size=resolution
            ),
        )
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif image:= part.as_image():
            image.save("butterfly.png")
    

    Javascript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const prompt =
          'Da Vinci style anatomical sketch of a dissected Monarch butterfly. Detailed drawings of the head, wings, and legs on textured parchment with notes in English.';
      const aspectRatio = '1:1';
      const resolution = '1K';
    
      const response = await ai.models.generateContent({
        model: 'gemini-3.1-flash-image-preview',
        contents: prompt,
        config: {
          responseModalities: ['TEXT', 'IMAGE'],
          imageConfig: {
            aspectRatio: aspectRatio,
            imageSize: resolution,
          },
        },
      });
    
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("image.png", buffer);
          console.log("Image saved as image.png");
        }
      }
    
    }
    
    main();
    

    Shko

    package main
    
    import (
        "context"
        "fmt"
        "log"
        "os"
    
        "google.golang.org/genai"
    )
    
    func main() {
        ctx := context.Background()
        client, err := genai.NewClient(ctx, nil)
        if err != nil {
            log.Fatal(err)
        }
        defer client.Close()
    
        model := client.GenerativeModel("gemini-3.1-flash-image-preview")
        model.GenerationConfig = &pb.GenerationConfig{
            ResponseModalities: []pb.ResponseModality{genai.Text, genai.Image},
            ImageConfig: &pb.ImageConfig{
                AspectRatio: "1:1",
                ImageSize:   "1K",
            },
        }
    
        prompt := "Da Vinci style anatomical sketch of a dissected Monarch butterfly. Detailed drawings of the head, wings, and legs on textured parchment with notes in English."
        resp, err := model.GenerateContent(ctx, genai.Text(prompt))
        if err != nil {
            log.Fatal(err)
        }
    
        for _, part := range resp.Candidates[0].Content.Parts {
            if txt, ok := part.(genai.Text); ok {
                fmt.Printf("%s", string(txt))
            } else if img, ok := part.(genai.ImageData); ok {
                err := os.WriteFile("butterfly.png", img.Data, 0644)
                if err != nil {
                    log.Fatal(err)
                }
            }
        }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.GoogleSearch;
    import com.google.genai.types.ImageConfig;
    import com.google.genai.types.Part;
    import com.google.genai.types.Tool;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class HiRes {
        public static void main(String[] args) throws IOException {
    
          try (Client client = new Client()) {
            GenerateContentConfig config = GenerateContentConfig.builder()
                .responseModalities("TEXT", "IMAGE")
                .imageConfig(ImageConfig.builder()
                    .aspectRatio("16:9")
                    .imageSize("4K")
                    .build())
                .build();
    
            GenerateContentResponse response = client.models.generateContent(
                "gemini-3.1-flash-image-preview", """
                  Da Vinci style anatomical sketch of a dissected Monarch butterfly.
                  Detailed drawings of the head, wings, and legs on textured
                  parchment with notes in English.
                  """,
                config);
    
            for (Part part : response.parts()) {
              if (part.text().isPresent()) {
                System.out.println(part.text().get());
              } else if (part.inlineData().isPresent()) {
                var blob = part.inlineData().get();
                if (blob.data().isPresent()) {
                  Files.write(Paths.get("butterfly.png"), blob.data().get());
                }
              }
            }
          }
        }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{"parts": [{"text": "Da Vinci style anatomical sketch of a dissected Monarch butterfly. Detailed drawings of the head, wings, and legs on textured parchment with notes in English."}]}],
        "tools": [{"google_search": {}}],
        "generationConfig": {
          "responseModalities": ["TEXT", "IMAGE"],
          "imageConfig": {"aspectRatio": "1:1", "imageSize": "1K"}
        }
      }'
    

    Më poshtë është një shembull imazhi i gjeneruar nga kjo kërkesë:

    Skicë anatomike në stilin Da Vinçi të gjeneruar nga inteligjenca artificiale e një fluture Monarch të disektuar.
    Skicë anatomike në stilin Da Vinçi të gjeneruar nga inteligjenca artificiale e një fluture Monarch të disektuar.

    Procesi i të menduarit

    Modelet e imazheve Gemini 3 janë modele të të menduarit që përdorin një proces arsyetimi ("Thinking") për kërkesa komplekse. Kjo veçori është aktivizuar si parazgjedhje dhe nuk mund të çaktivizohet në API. Për të mësuar më shumë rreth procesit të të menduarit, shihni udhëzuesin Gemini Thinking .

    Modeli gjeneron deri në dy imazhe të ndërmjetme për të testuar përbërjen dhe logjikën. Imazhi i fundit brenda Thinking është gjithashtu imazhi përfundimtar i renderuar.

    Mund të kontrolloni mendimet që çojnë në imazhin përfundimtar që po prodhohet.

    Python

    for part in response.parts:
        if part.thought:
            if part.text:
                print(part.text)
            elif image:= part.as_image():
                image.show()
    

    Javascript

    for (const part of response.candidates[0].content.parts) {
      if (part.thought) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, 'base64');
          fs.writeFileSync('image.png', buffer);
          console.log('Image saved as image.png');
        }
      }
    }
    

    Kontrollimi i niveleve të të menduarit

    Me Gemini 3.1 Flash Image, ju mund të kontrolloni sasinë e të menduarit që përdor modeli për të balancuar cilësinë dhe vonesën. Niveli i parazgjedhur thinkingLevel është minimal , dhe nivelet e mbështetura janë minimal dhe high .

    Mund të shtoni vlerën booleane includeThoughts për të përcaktuar nëse mendimet e gjeneruara nga modeli kthehen në përgjigje apo mbeten të fshehura.

    Python

    from google import genai
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents="A futuristic city built inside a giant glass bottle floating in space",
        config=types.GenerateContentConfig(
            response_modalities=["IMAGE"],
            thinking_config=types.ThinkingConfig(
                thinking_level="High",
                include_thoughts=True
            ),
        )
    )
    
    for part in response.parts:
        if part.thought: # Skip outputting thoughts
          continue
        if part.text:
          display(Markdown(part.text))
        elif image:= part.as_image():
          image.show()
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: "A futuristic city built inside a giant glass bottle floating in space",
        config: {
          responseModalities: ["IMAGE"],
          thinkingConfig: {
            thinkingLevel: "High",
            includeThoughts: true
          },
        },
      });
    
      for (const part of response.candidates[0].content.parts) {
        if (part.thought) { // Skip outputting thoughts
          continue;
        }
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("image.png", buffer);
          console.log("Image saved as image.png");
        }
      }
    }
    main();
    

    Shko

    package main
    
    import (
        "context"
        "fmt"
        "log"
        "os"
    
        "google.golang.org/genai"
        pb "google.golang.org/genai/schema"
    )
    
    func main() {
        ctx := context.Background()
        client, err := genai.NewClient(ctx, nil)
        if err != nil {
            log.Fatal(err)
        }
        defer client.Close()
    
        model := client.GenerativeModel("gemini-3.1-flash-image-preview")
        model.GenerationConfig = &pb.GenerationConfig{
            ResponseModalities: []pb.ResponseModality{genai.Image},
            ThinkingConfig: &pb.ThinkingConfig{
                ThinkingLevel:   "High",
                IncludeThoughts: true,
            },
        }
    
        prompt := "A futuristic city built inside a giant glass bottle floating in space"
        resp, err := model.GenerateContent(ctx, genai.Text(prompt))
        if err != nil {
            log.Fatal(err)
        }
    
        for _, part := range resp.Candidates[0].Content.Parts {
            if part.Thought { // Skip outputting thoughts
                continue
            }
            if txt, ok := part.(genai.Text); ok {
                fmt.Printf("%s", string(txt))
            } else if img, ok := part.(genai.ImageData); ok {
                err := os.WriteFile("image.png", img.Data, 0644)
                if err != nil {
                    log.Fatal(err)
                }
            }
        }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{"parts": [{"text": "A futuristic city built inside a giant glass bottle floating in space"}]}],
        "generationConfig": {
          "responseModalities": ["IMAGE"],
          "thinkingConfig": {
            "thinkingLevel": "High",
            "includeThoughts": true
          }
        }
      }'
    

    Vini re se tokenët e të menduarit faturohen pavarësisht nëse includeThoughts është vendosur në true ose false , pasi procesi i të menduarit ndodh gjithmonë si parazgjedhje, pavarësisht nëse e shikoni procesin apo jo.

    Nënshkrimet e Mendimit

    Nënshkrimet e mendimit janë përfaqësime të koduara të procesit të brendshëm të të menduarit të modelit dhe përdoren për të ruajtur kontekstin e arsyetimit në ndërveprimet me shumë kthesa. Të gjitha përgjigjet përfshijnë një fushë thought_signature . Si rregull i përgjithshëm, nëse merrni një nënshkrim mendimi në një përgjigje modeli, duhet ta kaloni atë pikërisht ashtu siç e keni marrë kur keni dërguar historikun e bisedës në kthesën tjetër. Mosqarkullimi i nënshkrimeve të mendimit mund të shkaktojë dështimin e përgjigjes. Kontrolloni dokumentacionin e nënshkrimit të mendimit për më shumë shpjegime të nënshkrimeve në përgjithësi.

    Ja se si funksionojnë nënshkrimet e mendimit:

    • Të gjitha pjesët inline_data me mimetype të imazhit që janë pjesë e përgjigjes duhet të kenë nënshkrim.
    • Nëse ka disa pjesë teksti në fillim (para ndonjë imazhi) menjëherë pas mendimeve, pjesa e parë e tekstit duhet të ketë gjithashtu një nënshkrim.
    • Nëse pjesët inline_data me mimetype imazhit janë pjesë e mendimeve, ato nuk do të kenë nënshkrime.

    Kodi i mëposhtëm tregon një shembull se ku përfshihen nënshkrimet e mendimit:

    [
      {
        "inline_data": {
          "data": "<base64_image_data_0>",
          "mime_type": "image/png"
        },
        "thought": true // Thoughts don't have signatures
      },
      {
        "inline_data": {
          "data": "<base64_image_data_1>",
          "mime_type": "image/png"
        },
        "thought": true // Thoughts don't have signatures
      },
      {
        "inline_data": {
          "data": "<base64_image_data_2>",
          "mime_type": "image/png"
        },
        "thought": true // Thoughts don't have signatures
      },
      {
        "text": "Here is a step-by-step guide to baking macarons, presented in three separate images.\n\n### Step 1: Piping the Batter\n\nThe first step after making your macaron batter is to pipe it onto a baking sheet. This requires a steady hand to create uniform circles.\n\n",
        "thought_signature": "<Signature_A>" // The first non-thought part always has a signature
      },
      {
        "inline_data": {
          "data": "<base64_image_data_3>",
          "mime_type": "image/png"
        },
        "thought_signature": "<Signature_B>" // All image parts have a signatures
      },
      {
        "text": "\n\n### Step 2: Baking and Developing Feet\n\nOnce piped, the macarons are baked in the oven. A key sign of a successful bake is the development of \"feet\"—the ruffled edge at the base of each macaron shell.\n\n"
        // Follow-up text parts don't have signatures
      },
      {
        "inline_data": {
          "data": "<base64_image_data_4>",
          "mime_type": "image/png"
        },
        "thought_signature": "<Signature_C>" // All image parts have a signatures
      },
      {
        "text": "\n\n### Step 3: Assembling the Macaron\n\nThe final step is to pair the cooled macaron shells by size and sandwich them together with your desired filling, creating the classic macaron dessert.\n\n"
      },
      {
        "inline_data": {
          "data": "<base64_image_data_5>",
          "mime_type": "image/png"
        },
        "thought_signature": "<Signature_D>" // All image parts have a signatures
      }
    ]
    

    Mënyra të tjera të gjenerimit të imazheve

    Gemini mbështet mënyra të tjera të ndërveprimit me imazhe bazuar në strukturën dhe kontekstin e shpejtë, duke përfshirë:

    • Tekst në imazh(e) dhe tekst (të ndërthurur): Nxjerr imazhe me tekst të lidhur.
      • Shembull i kërkesës: "Gjeneroni një recetë të ilustruar për një paella."
    • Imazh(e) dhe tekst në imazh(e) dhe tekst (të ndërthurura) : Përdor imazhet dhe tekstin e futur për të krijuar imazhe dhe tekst të rinj të lidhur.
      • Shembull i kërkesës: (Me një imazh të një dhome të mobiluar) "Çfarë ngjyrash të tjera divanesh do të funksiononin në hapësirën time? A mund ta përditësoni imazhin?"

    Gjeneroni imazhe në grup

    Nëse duhet të gjeneroni shumë imazhe, mund të përdorni Batch API . Do të merrni limite më të larta shpejtësie në këmbim të një përpunimi deri në 24 orë.

    Kontrolloni dokumentacionin e gjenerimit të imazheve Batch API dhe librin e gatimit për shembuj dhe kod të imazheve Batch API.

    Udhëzues dhe strategji nxitëse

    Zotërimi i gjenerimit të imazheve fillon me një parim themelor:

    Përshkruani skenën, mos renditni vetëm fjalë kyçe. Pika e fortë e modelit është kuptimi i thellë i gjuhës. Një paragraf narrativ dhe përshkrues pothuajse gjithmonë do të prodhojë një imazh më të mirë dhe më koherent sesa një listë fjalësh të shkëputura nga njëra-tjetra.

    Udhëzime për gjenerimin e imazheve

    Strategjitë e mëposhtme do t'ju ndihmojnë të krijoni sugjerime efektive për të gjeneruar pikërisht imazhet që po kërkoni.

    1. Skena fotorealiste

    Për imazhe realiste, përdorni terma fotografikë. Përmendni këndet e kamerave, llojet e lenteve, ndriçimin dhe detajet e imëta për ta udhëhequr modelin drejt një rezultati fotorealist.

    Shabllon

    A photorealistic [shot type] of [subject], [action or expression], set in
    [environment]. The scene is illuminated by [lighting description], creating
    a [mood] atmosphere. Captured with a [camera/lens details], emphasizing
    [key textures and details]. The image should be in a [aspect ratio] format.
    

    Nxitje

    A photorealistic close-up portrait of an elderly Japanese ceramicist with
    deep, sun-etched wrinkles and a warm, knowing smile. He is carefully
    inspecting a freshly glazed tea bowl. The setting is his rustic,
    sun-drenched workshop. The scene is illuminated by soft, golden hour light
    streaming through a window, highlighting the fine texture of the clay.
    Captured with an 85mm portrait lens, resulting in a soft, blurred background
    (bokeh). The overall mood is serene and masterful. Vertical portrait
    orientation.
    

    Python

    from google import genai
    from google.genai import types
    
    client = genai.Client()
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents="A photorealistic close-up portrait of an elderly Japanese ceramicist with deep, sun-etched wrinkles and a warm, knowing smile. He is carefully inspecting a freshly glazed tea bowl. The setting is his rustic, sun-drenched workshop with pottery wheels and shelves of clay pots in the background. The scene is illuminated by soft, golden hour light streaming through a window, highlighting the fine texture of the clay and the fabric of his apron. Captured with an 85mm portrait lens, resulting in a soft, blurred background (bokeh). The overall mood is serene and masterful.",
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("photorealistic_example.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const prompt =
        "A photorealistic close-up portrait of an elderly Japanese ceramicist with deep, sun-etched wrinkles and a warm, knowing smile. He is carefully inspecting a freshly glazed tea bowl. The setting is his rustic, sun-drenched workshop with pottery wheels and shelves of clay pots in the background. The scene is illuminated by soft, golden hour light streaming through a window, highlighting the fine texture of the clay and the fabric of his apron. Captured with an 85mm portrait lens, resulting in a soft, blurred background (bokeh). The overall mood is serene and masterful.";
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("photorealistic_example.png", buffer);
          console.log("Image saved as photorealistic_example.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
        "context"
        "fmt"
        "log"
        "os"
        "google.golang.org/genai"
    )
    
    func main() {
    
        ctx := context.Background()
        client, err := genai.NewClient(ctx, nil)
        if err != nil {
            log.Fatal(err)
        }
    
        result, _ := client.Models.GenerateContent(
            ctx,
            "gemini-3.1-flash-image-preview",
            genai.Text("A photorealistic close-up portrait of an elderly Japanese ceramicist with deep, sun-etched wrinkles and a warm, knowing smile. He is carefully inspecting a freshly glazed tea bowl. The setting is his rustic, sun-drenched workshop with pottery wheels and shelves of clay pots in the background. The scene is illuminated by soft, golden hour light streaming through a window, highlighting the fine texture of the clay and the fabric of his apron. Captured with an 85mm portrait lens, resulting in a soft, blurred background (bokeh). The overall mood is serene and masterful."),
        )
    
        for _, part := range result.Candidates[0].Content.Parts {
            if part.Text != "" {
                fmt.Println(part.Text)
            } else if part.InlineData != nil {
                imageBytes := part.InlineData.Data
                outputFilename := "photorealistic_example.png"
                _ = os.WriteFile(outputFilename, imageBytes, 0644)
            }
        }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class PhotorealisticScene {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              """
              A photorealistic close-up portrait of an elderly Japanese ceramicist
              with deep, sun-etched wrinkles and a warm, knowing smile. He is
              carefully inspecting a freshly glazed tea bowl. The setting is his
              rustic, sun-drenched workshop with pottery wheels and shelves of
              clay pots in the background. The scene is illuminated by soft,
              golden hour light streaming through a window, highlighting the
              fine texture of the clay and the fabric of his apron. Captured
              with an 85mm portrait lens, resulting in a soft, blurred
              background (bokeh). The overall mood is serene and masterful.
              """,
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("photorealistic_example.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{
          "parts": [
            {"text": "A photorealistic close-up portrait of an elderly Japanese ceramicist with deep, sun-etched wrinkles and a warm, knowing smile. He is carefully inspecting a freshly glazed tea bowl. The setting is his rustic, sun-drenched workshop with pottery wheels and shelves of clay pots in the background. The scene is illuminated by soft, golden hour light streaming through a window, highlighting the fine texture of the clay and the fabric of his apron. Captured with an 85mm portrait lens, resulting in a soft, blurred background (bokeh). The overall mood is serene and masterful."}
          ]
        }]
      }'
    
    Një portret fotorealist nga afër i një qeramisti të moshuar japonez...
    Një portret fotorealist nga afër i një qeramisti të moshuar japonez...

    2. Ilustrime dhe afishe të stilizuara

    Për të krijuar afishe, ikona ose asete, ji i qartë në lidhje me stilin dhe kërko një sfond transparent.

    Shabllon

    A [style] sticker of a [subject], featuring [key characteristics] and a
    [color palette]. The design should have [line style] and [shading style].
    The background must be transparent.
    

    Nxitje

    A kawaii-style sticker of a happy red panda wearing a tiny bamboo hat. It's
    munching on a green bamboo leaf. The design features bold, clean outlines,
    simple cel-shading, and a vibrant color palette. The background must be white.
    

    Python

    from google import genai
    from google.genai import types
    
    client = genai.Client()
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents="A kawaii-style sticker of a happy red panda wearing a tiny bamboo hat. It's munching on a green bamboo leaf. The design features bold, clean outlines, simple cel-shading, and a vibrant color palette. The background must be white.",
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("red_panda_sticker.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const prompt =
        "A kawaii-style sticker of a happy red panda wearing a tiny bamboo hat. It's munching on a green bamboo leaf. The design features bold, clean outlines, simple cel-shading, and a vibrant color palette. The background must be white.";
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("red_panda_sticker.png", buffer);
          console.log("Image saved as red_panda_sticker.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
        "context"
        "fmt"
        "log"
        "os"
        "google.golang.org/genai"
    )
    
    func main() {
    
        ctx := context.Background()
        client, err := genai.NewClient(ctx, nil)
        if err != nil {
            log.Fatal(err)
        }
    
        result, _ := client.Models.GenerateContent(
            ctx,
            "gemini-3.1-flash-image-preview",
            genai.Text("A kawaii-style sticker of a happy red panda wearing a tiny bamboo hat. It's munching on a green bamboo leaf. The design features bold, clean outlines, simple cel-shading, and a vibrant color palette. The background must be white."),
        )
    
        for _, part := range result.Candidates[0].Content.Parts {
            if part.Text != "" {
                fmt.Println(part.Text)
            } else if part.InlineData != nil {
                imageBytes := part.InlineData.Data
                outputFilename := "red_panda_sticker.png"
                _ = os.WriteFile(outputFilename, imageBytes, 0644)
            }
        }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class StylizedIllustration {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              """
              A kawaii-style sticker of a happy red panda wearing a tiny bamboo
              hat. It's munching on a green bamboo leaf. The design features
              bold, clean outlines, simple cel-shading, and a vibrant color
              palette. The background must be white.
              """,
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("red_panda_sticker.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{
          "parts": [
            {"text": "A kawaii-style sticker of a happy red panda wearing a tiny bamboo hat. It is munching on a green bamboo leaf. The design features bold, clean outlines, simple cel-shading, and a vibrant color palette. The background must be white."}
          ]
        }]
      }'
    
    Një ngjitëse në stilin kawaii e një të kuqeje të lumtur...
    Një ngjitëse në stilin kawaii e një panda të kuqe të lumtur...

    3. Tekst i saktë në imazhe

    Gemini shkëlqen në paraqitjen e tekstit. Jini të qartë në lidhje me tekstin, stilin e shkronjave (në mënyrë përshkruese) dhe dizajnin e përgjithshëm. Përdorni Gemini 3 Pro Image Preview për prodhim profesional të aseteve.

    Shabllon

    Create a [image type] for [brand/concept] with the text "[text to render]"
    in a [font style]. The design should be [style description], with a
    [color scheme].
    

    Nxitje

    Create a modern, minimalist logo for a coffee shop called 'The Daily Grind'. The text should be in a clean, bold, sans-serif font. The color scheme is black and white. Put the logo in a circle. Use a coffee bean in a clever way.
    

    Python

    from google import genai
    from google.genai import types    
    
    client = genai.Client()
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents="Create a modern, minimalist logo for a coffee shop called 'The Daily Grind'. The text should be in a clean, bold, sans-serif font. The color scheme is black and white. Put the logo in a circle. Use a coffee bean in a clever way.",
        config=types.GenerateContentConfig(
            image_config=types.ImageConfig(
                aspect_ratio="1:1",
            )
        )
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("logo_example.jpg")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const prompt =
        "Create a modern, minimalist logo for a coffee shop called 'The Daily Grind'. The text should be in a clean, bold, sans-serif font. The color scheme is black and white. Put the logo in a circle. Use a coffee bean in a clever way.";
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
        config: {
          imageConfig: {
            aspectRatio: "1:1",
          },
        },
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("logo_example.jpg", buffer);
          console.log("Image saved as logo_example.jpg");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
        "context"
        "fmt"
        "log"
        "os"
        "google.golang.org/genai"
    )
    
    func main() {
    
        ctx := context.Background()
        client, err := genai.NewClient(ctx, nil)
        if err != nil {
            log.Fatal(err)
        }
    
        result, _ := client.Models.GenerateContent(
            ctx,
            "gemini-3.1-flash-image-preview",
            genai.Text("Create a modern, minimalist logo for a coffee shop called 'The Daily Grind'. The text should be in a clean, bold, sans-serif font. The color scheme is black and white. Put the logo in a circle. Use a coffee bean in a clever way."),
            &genai.GenerateContentConfig{
                ImageConfig: &genai.ImageConfig{
                  AspectRatio: "1:1",
                },
            },
        )
    
        for _, part := range result.Candidates[0].Content.Parts {
            if part.Text != "" {
                fmt.Println(part.Text)
            } else if part.InlineData != nil {
                imageBytes := part.InlineData.Data
                outputFilename := "logo_example.jpg"
                _ = os.WriteFile(outputFilename, imageBytes, 0644)
            }
        }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    import com.google.genai.types.ImageConfig;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class AccurateTextInImages {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .imageConfig(ImageConfig.builder()
                  .aspectRatio("1:1")
                  .build())
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              """
              Create a modern, minimalist logo for a coffee shop called 'The Daily Grind'. The text should be in a clean, bold, sans-serif font. The color scheme is black and white. Put the logo in a circle. Use a coffee bean in a clever way.
              """,
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("logo_example.jpg"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{
          "parts": [
            {"text": "Create a modern, minimalist logo for a coffee shop called The Daily Grind. The text should be in a clean, bold, sans-serif font. The color scheme is black and white. Put the logo in a circle. Use a coffee bean in a clever way."}
          ]
        }],
        "generationConfig": {
          "imageConfig": {
            "aspectRatio": "1:1"
          }
        }
      }'
    
    Krijo një logo moderne dhe minimaliste për një kafene të quajtur 'The Daily Grind'...
    Krijo një logo moderne dhe minimaliste për një kafene të quajtur 'The Daily Grind'...

    4. Makete produktesh dhe fotografi komerciale

    Perfekt për krijimin e fotove të pastra dhe profesionale të produkteve për tregtinë elektronike, reklamimin ose krijimin e markave.

    Shabllon

    A high-resolution, studio-lit product photograph of a [product description]
    on a [background surface/description]. The lighting is a [lighting setup,
    e.g., three-point softbox setup] to [lighting purpose]. The camera angle is
    a [angle type] to showcase [specific feature]. Ultra-realistic, with sharp
    focus on [key detail]. [Aspect ratio].
    

    Nxitje

    A high-resolution, studio-lit product photograph of a minimalist ceramic
    coffee mug in matte black, presented on a polished concrete surface. The
    lighting is a three-point softbox setup designed to create soft, diffused
    highlights and eliminate harsh shadows. The camera angle is a slightly
    elevated 45-degree shot to showcase its clean lines. Ultra-realistic, with
    sharp focus on the steam rising from the coffee. Square image.
    

    Python

    from google import genai
    from google.genai import types
    
    client = genai.Client()
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents="A high-resolution, studio-lit product photograph of a minimalist ceramic coffee mug in matte black, presented on a polished concrete surface. The lighting is a three-point softbox setup designed to create soft, diffused highlights and eliminate harsh shadows. The camera angle is a slightly elevated 45-degree shot to showcase its clean lines. Ultra-realistic, with sharp focus on the steam rising from the coffee. Square image.",
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("product_mockup.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const prompt =
        "A high-resolution, studio-lit product photograph of a minimalist ceramic coffee mug in matte black, presented on a polished concrete surface. The lighting is a three-point softbox setup designed to create soft, diffused highlights and eliminate harsh shadows. The camera angle is a slightly elevated 45-degree shot to showcase its clean lines. Ultra-realistic, with sharp focus on the steam rising from the coffee. Square image.";
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("product_mockup.png", buffer);
          console.log("Image saved as product_mockup.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
        "context"
        "fmt"
        "log"
        "os"
        "google.golang.org/genai"
    )
    
    func main() {
    
        ctx := context.Background()
        client, err := genai.NewClient(ctx, nil)
        if err != nil {
            log.Fatal(err)
        }
    
        result, _ := client.Models.GenerateContent(
            ctx,
            "gemini-3.1-flash-image-preview",
            genai.Text("A high-resolution, studio-lit product photograph of a minimalist ceramic coffee mug in matte black, presented on a polished concrete surface. The lighting is a three-point softbox setup designed to create soft, diffused highlights and eliminate harsh shadows. The camera angle is a slightly elevated 45-degree shot to showcase its clean lines. Ultra-realistic, with sharp focus on the steam rising from the coffee. Square image."),
        )
    
        for _, part := range result.Candidates[0].Content.Parts {
            if part.Text != "" {
                fmt.Println(part.Text)
            } else if part.InlineData != nil {
                imageBytes := part.InlineData.Data
                outputFilename := "product_mockup.png"
                _ = os.WriteFile(outputFilename, imageBytes, 0644)
            }
        }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class ProductMockup {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              """
              A high-resolution, studio-lit product photograph of a minimalist
              ceramic coffee mug in matte black, presented on a polished
              concrete surface. The lighting is a three-point softbox setup
              designed to create soft, diffused highlights and eliminate harsh
              shadows. The camera angle is a slightly elevated 45-degree shot
              to showcase its clean lines. Ultra-realistic, with sharp focus
              on the steam rising from the coffee. Square image.
              """,
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("product_mockup.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{
          "parts": [
            {"text": "A high-resolution, studio-lit product photograph of a minimalist ceramic coffee mug in matte black, presented on a polished concrete surface. The lighting is a three-point softbox setup designed to create soft, diffused highlights and eliminate harsh shadows. The camera angle is a slightly elevated 45-degree shot to showcase its clean lines. Ultra-realistic, with sharp focus on the steam rising from the coffee. Square image."}
          ]
        }]
      }'
    
    Një fotografi produkti me rezolucion të lartë, e ndriçuar nga studioja, e një filxhani minimalist kafeje prej qeramike...
    Një fotografi produkti me rezolucion të lartë, e ndriçuar nga studioja, e një filxhani minimalist kafeje prej qeramike...

    5. Dizajn minimalist dhe negativ i hapësirës

    Shkëlqyeshëm për krijimin e sfondeve për faqet e internetit, prezantimet ose materialet e marketingut ku teksti do të mbivendoset.

    Shabllon

    A minimalist composition featuring a single [subject] positioned in the
    [bottom-right/top-left/etc.] of the frame. The background is a vast, empty
    [color] canvas, creating significant negative space. Soft, subtle lighting.
    [Aspect ratio].
    

    Nxitje

    A minimalist composition featuring a single, delicate red maple leaf
    positioned in the bottom-right of the frame. The background is a vast, empty
    off-white canvas, creating significant negative space for text. Soft,
    diffused lighting from the top left. Square image.
    

    Python

    from google import genai
    from google.genai import types    
    
    client = genai.Client()
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents="A minimalist composition featuring a single, delicate red maple leaf positioned in the bottom-right of the frame. The background is a vast, empty off-white canvas, creating significant negative space for text. Soft, diffused lighting from the top left. Square image.",
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("minimalist_design.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const prompt =
        "A minimalist composition featuring a single, delicate red maple leaf positioned in the bottom-right of the frame. The background is a vast, empty off-white canvas, creating significant negative space for text. Soft, diffused lighting from the top left. Square image.";
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("minimalist_design.png", buffer);
          console.log("Image saved as minimalist_design.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
        "context"
        "fmt"
        "log"
        "os"
        "google.golang.org/genai"
    )
    
    func main() {
    
        ctx := context.Background()
        client, err := genai.NewClient(ctx, nil)
        if err != nil {
            log.Fatal(err)
        }
    
        result, _ := client.Models.GenerateContent(
            ctx,
            "gemini-3.1-flash-image-preview",
            genai.Text("A minimalist composition featuring a single, delicate red maple leaf positioned in the bottom-right of the frame. The background is a vast, empty off-white canvas, creating significant negative space for text. Soft, diffused lighting from the top left. Square image."),
        )
    
        for _, part := range result.Candidates[0].Content.Parts {
            if part.Text != "" {
                fmt.Println(part.Text)
            } else if part.InlineData != nil {
                imageBytes := part.InlineData.Data
                outputFilename := "minimalist_design.png"
                _ = os.WriteFile(outputFilename, imageBytes, 0644)
            }
        }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class MinimalistDesign {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              """
              A minimalist composition featuring a single, delicate red maple
              leaf positioned in the bottom-right of the frame. The background
              is a vast, empty off-white canvas, creating significant negative
              space for text. Soft, diffused lighting from the top left.
              Square image.
              """,
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("minimalist_design.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{
          "parts": [
            {"text": "A minimalist composition featuring a single, delicate red maple leaf positioned in the bottom-right of the frame. The background is a vast, empty off-white canvas, creating significant negative space for text. Soft, diffused lighting from the top left. Square image."}
          ]
        }]
      }'
    
    Një kompozim minimalist që paraqet një gjethe të vetme panje të kuqe delikate...
    Një kompozim minimalist që paraqet një gjethe të vetme panje të kuqe delikate...

    6. Art sekuencial (Paneli komik / Storyboard)

    Ndërtohet mbi qëndrueshmërinë e personazheve dhe përshkrimin e skenës për të krijuar panele për rrëfim vizual. Për saktësi me tekstin dhe aftësinë e rrëfimit, këto sugjerime funksionojnë më mirë me Gemini 3 Pro dhe Gemini 3.1 Flash Image Preview.

    Shabllon

    Make a 3 panel comic in a [style]. Put the character in a [type of scene].
    

    Nxitje

    Make a 3 panel comic in a gritty, noir art style with high-contrast black and white inks. Put the character in a humurous scene.
    

    Python

    from google import genai
    from google.genai import types
    from PIL import Image
    
    client = genai.Client()
    
    image_input = Image.open('/path/to/your/man_in_white_glasses.jpg')
    text_input = "Make a 3 panel comic in a gritty, noir art style with high-contrast black and white inks. Put the character in a humurous scene."
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[text_input, image_input],
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("comic_panel.jpg")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const imagePath = "/path/to/your/man_in_white_glasses.jpg";
      const imageData = fs.readFileSync(imagePath);
      const base64Image = imageData.toString("base64");
    
      const prompt = [
        {text: "Make a 3 panel comic in a gritty, noir art style with high-contrast black and white inks. Put the character in a humurous scene."},
        {
          inlineData: {
            mimeType: "image/jpeg",
            data: base64Image,
          },
        },
      ];
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("comic_panel.jpg", buffer);
          console.log("Image saved as comic_panel.jpg");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
        "context"
        "fmt"
        "log"
        "os"
        "google.golang.org/genai"
    )
    
    func main() {
    
        ctx := context.Background()
        client, err := genai.NewClient(ctx, nil)
        if err != nil {
            log.Fatal(err)
        }
    
        imagePath := "/path/to/your/man_in_white_glasses.jpg"
        imgData, _ := os.ReadFile(imagePath)
    
        parts := []*genai.Part{
          genai.NewPartFromText("Make a 3 panel comic in a gritty, noir art style with high-contrast black and white inks. Put the character in a humurous scene."),
          &genai.Part{
            InlineData: &genai.Blob{
              MIMEType: "image/jpeg",
              Data:     imgData,
            },
          },
        }
    
        contents := []*genai.Content{
          genai.NewContentFromParts(parts, genai.RoleUser),
        }
    
        result, _ := client.Models.GenerateContent(
            ctx,
            "gemini-3.1-flash-image-preview",
            contents,
        )
    
        for _, part := range result.Candidates[0].Content.Parts {
            if part.Text != "" {
                fmt.Println(part.Text)
            } else if part.InlineData != nil {
                imageBytes := part.InlineData.Data
                outputFilename := "comic_panel.jpg"
                _ = os.WriteFile(outputFilename, imageBytes, 0644)
            }
        }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.Content;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    
    public class ComicPanel {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              Content.fromParts(
                  Part.fromText("""
                      Make a 3 panel comic in a gritty, noir art style with high-contrast black and white inks. Put the character in a humurous scene.
                      """),
                  Part.fromBytes(
                      Files.readAllBytes(
                          Path.of("/path/to/your/man_in_white_glasses.jpg")),
                      "image/jpeg")),
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("comic_panel.jpg"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{
          "parts": [
            {"text": "Make a 3 panel comic in a gritty, noir art style with high-contrast black and white inks. Put the character in a humurous scene."},
            {"inline_data": {"mime_type": "image/jpeg", "data": "<BASE64_IMAGE_DATA>"}}
          ]
        }]
      }'
    

    Hyrje

    Prodhimi

    Burrë me syze të bardha
    Fut imazhin
    Krijo një komik me 3 panele në një stil arti të ashpër, noir...
    Krijo një komik me 3 panele në një stil arti të ashpër, noir...

    Përdorni Kërkimin në Google për të gjeneruar imazhe bazuar në informacione të fundit ose në kohë reale. Kjo është e dobishme për lajmet, motin dhe tema të tjera të ndjeshme ndaj kohës.

    Nxitje

    Make a simple but stylish graphic of last night's Arsenal game in the Champion's League
    

    Python

    from google import genai
    from google.genai import types
    prompt = "Make a simple but stylish graphic of last night's Arsenal game in the Champion's League"
    aspect_ratio = "16:9" # "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"
    
    client = genai.Client()
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=prompt,
        config=types.GenerateContentConfig(
            response_modalities=['Text', 'Image'],
            image_config=types.ImageConfig(
                aspect_ratio=aspect_ratio,
            ),
            tools=[{"google_search": {}}]
        )
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif image:= part.as_image():
            image.save("football-score.jpg")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const prompt = "Make a simple but stylish graphic of last night's Arsenal game in the Champion's League";
    
      const aspectRatio = '16:9';
      const resolution = '2K';
    
    const response = await ai.models.generateContent({
        model: 'gemini-3.1-flash-image-preview',
        contents: prompt,
        config: {
          responseModalities: ['TEXT', 'IMAGE'],
          imageConfig: {
            aspectRatio: aspectRatio,
            imageSize: resolution,
          },
          tools: [{"google_search": {}}],
        },
      });
    
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("football-score.jpg", buffer);
          console.log("Image saved as football-score.jpg");
        }
      }
    
    }
    
    main();
    
    

    Shko

    package main
    
    import (
        "context"
        "fmt"
        "log"
        "os"
    
        "google.golang.org/genai"
        pb "google.golang.org/genai/schema"
    )
    
    func main() {
        ctx := context.Background()
        client, err := genai.NewClient(ctx, nil)
        if err != nil {
            log.Fatal(err)
        }
        defer client.Close()
    
        model := client.GenerativeModel("gemini-3.1-flash-image-preview")
        model.Tools = []*pb.Tool{
            pb.NewGoogleSearchTool(),
        }
        model.GenerationConfig = &pb.GenerationConfig{
            ResponseModalities: []pb.ResponseModality{genai.Text, genai.Image},
            ImageConfig: &pb.ImageConfig{
                AspectRatio: "16:9",
            },
        }
    
        prompt := "Make a simple but stylish graphic of last night's Arsenal game in the Champion's League"
        resp, err := model.GenerateContent(ctx, genai.Text(prompt))
        if err != nil {
            log.Fatal(err)
        }
    
        for _, part := range resp.Candidates[0].Content.Parts {
            if txt, ok := part.(genai.Text); ok {
                fmt.Printf("%s", string(txt))
            } else if img, ok := part.(genai.ImageData); ok {
                err := os.WriteFile("football-score.jpg", img.Data, 0644)
                if err != nil {
                    log.Fatal(err)
                }
            }
        }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.GoogleSearch;
    import com.google.genai.types.ImageConfig;
    import com.google.genai.types.Part;
    import com.google.genai.types.Tool;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class SearchGrounding {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .imageConfig(ImageConfig.builder()
                  .aspectRatio("16:9")
                  .build())
              .tools(Tool.builder()
                  .googleSearch(GoogleSearch.builder().build())
                  .build())
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview", """
                  Make a simple but stylish graphic of last night's Arsenal game in the Champion's League
                  """,
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("football-score.jpg"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{"parts": [{"text": "Make a simple but stylish graphic of last nights Arsenal game in the Champions League"}]}],
        "tools": [{"google_search": {}}],
        "generationConfig": {
          "responseModalities": ["TEXT", "IMAGE"],
          "imageConfig": {"aspectRatio": "16:9"}
        }
      }'
    
    Grafik i gjeneruar nga inteligjenca artificiale i një rezultati të futbollit të Arsenalit
    Grafik i gjeneruar nga inteligjenca artificiale i një rezultati të futbollit të Arsenalit

    Udhëzime për redaktimin e imazheve

    Këto shembuj tregojnë se si të ofroni imazhe së bashku me kërkesat e tekstit për redaktim, kompozim dhe transferim stili.

    1. Shtimi dhe heqja e elementeve

    Jepni një imazh dhe përshkruani ndryshimin tuaj. Modeli do të përputhet me stilin, ndriçimin dhe perspektivën e imazhit origjinal.

    Shabllon

    Using the provided image of [subject], please [add/remove/modify] [element]
    to/from the scene. Ensure the change is [description of how the change should
    integrate].
    

    Nxitje

    "Using the provided image of my cat, please add a small, knitted wizard hat
    on its head. Make it look like it's sitting comfortably and matches the soft
    lighting of the photo."
    

    Python

    from google import genai
    from google.genai import types
    from PIL import Image
    
    client = genai.Client()
    
    # Base image prompt: "A photorealistic picture of a fluffy ginger cat sitting on a wooden floor, looking directly at the camera. Soft, natural light from a window."
    image_input = Image.open('/path/to/your/cat_photo.png')
    text_input = """Using the provided image of my cat, please add a small, knitted wizard hat on its head. Make it look like it's sitting comfortably and not falling off."""
    
    # Generate an image from a text prompt
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[text_input, image_input],
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("cat_with_hat.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const imagePath = "/path/to/your/cat_photo.png";
      const imageData = fs.readFileSync(imagePath);
      const base64Image = imageData.toString("base64");
    
      const prompt = [
        { text: "Using the provided image of my cat, please add a small, knitted wizard hat on its head. Make it look like it's sitting comfortably and not falling off." },
        {
          inlineData: {
            mimeType: "image/png",
            data: base64Image,
          },
        },
      ];
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("cat_with_hat.png", buffer);
          console.log("Image saved as cat_with_hat.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
      "context"
      "fmt"
      "log"
      "os"
      "google.golang.org/genai"
    )
    
    func main() {
    
      ctx := context.Background()
      client, err := genai.NewClient(ctx, nil)
      if err != nil {
          log.Fatal(err)
      }
    
      imagePath := "/path/to/your/cat_photo.png"
      imgData, _ := os.ReadFile(imagePath)
    
      parts := []*genai.Part{
        genai.NewPartFromText("Using the provided image of my cat, please add a small, knitted wizard hat on its head. Make it look like it's sitting comfortably and not falling off."),
        &genai.Part{
          InlineData: &genai.Blob{
            MIMEType: "image/png",
            Data:     imgData,
          },
        },
      }
    
      contents := []*genai.Content{
        genai.NewContentFromParts(parts, genai.RoleUser),
      }
    
      result, _ := client.Models.GenerateContent(
          ctx,
          "gemini-3.1-flash-image-preview",
          contents,
      )
    
      for _, part := range result.Candidates[0].Content.Parts {
          if part.Text != "" {
              fmt.Println(part.Text)
          } else if part.InlineData != nil {
              imageBytes := part.InlineData.Data
              outputFilename := "cat_with_hat.png"
              _ = os.WriteFile(outputFilename, imageBytes, 0644)
          }
      }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.Content;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    
    public class AddRemoveElements {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              Content.fromParts(
                  Part.fromText("""
                      Using the provided image of my cat, please add a small,
                      knitted wizard hat on its head. Make it look like it's
                      sitting comfortably and not falling off.
                      """),
                  Part.fromBytes(
                      Files.readAllBytes(
                          Path.of("/path/to/your/cat_photo.png")),
                      "image/png")),
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("cat_with_hat.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
        -H "x-goog-api-key: $GEMINI_API_KEY" \
        -H 'Content-Type: application/json' \
        -d "{
          \"contents\": [{
            \"parts\":[
                {\"text\": \"Using the provided image of my cat, please add a small, knitted wizard hat on its head. Make it look like it's sitting comfortably and not falling off.\"},
                {
                  \"inline_data\": {
                    \"mime_type\":\"image/png\",
                    \"data\": \"<BASE64_IMAGE_DATA>\"
                  }
                }
            ]
          }]
        }"
    

    Hyrje

    Prodhimi

    Një fotografi fotorealiste e një maceje xhenxhefili me qime..
    Një fotografi fotorealiste e një maceje xhenxhefili me qime të buta...
    Duke përdorur imazhin e dhënë të maces sime, ju lutem shtoni një kapelë magjistari të vogël të thurur...
    Duke përdorur imazhin e dhënë të maces sime, ju lutem shtoni një kapelë magjistari të vogël të thurur...

    2. Inpainting (Maskimi semantik)

    Përcaktoni në mënyrë bisedore një "maskë" për të modifikuar një pjesë specifike të një imazhi duke e lënë pjesën tjetër të paprekur.

    Shabllon

    Using the provided image, change only the [specific element] to [new
    element/description]. Keep everything else in the image exactly the same,
    preserving the original style, lighting, and composition.
    

    Nxitje

    "Using the provided image of a living room, change only the blue sofa to be
    a vintage, brown leather chesterfield sofa. Keep the rest of the room,
    including the pillows on the sofa and the lighting, unchanged."
    

    Python

    from google import genai
    from google.genai import types
    from PIL import Image
    
    client = genai.Client()
    
    # Base image prompt: "A wide shot of a modern, well-lit living room with a prominent blue sofa in the center. A coffee table is in front of it and a large window is in the background."
    living_room_image = Image.open('/path/to/your/living_room.png')
    text_input = """Using the provided image of a living room, change only the blue sofa to be a vintage, brown leather chesterfield sofa. Keep the rest of the room, including the pillows on the sofa and the lighting, unchanged."""
    
    # Generate an image from a text prompt
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[living_room_image, text_input],
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("living_room_edited.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const imagePath = "/path/to/your/living_room.png";
      const imageData = fs.readFileSync(imagePath);
      const base64Image = imageData.toString("base64");
    
      const prompt = [
        {
          inlineData: {
            mimeType: "image/png",
            data: base64Image,
          },
        },
        { text: "Using the provided image of a living room, change only the blue sofa to be a vintage, brown leather chesterfield sofa. Keep the rest of the room, including the pillows on the sofa and the lighting, unchanged." },
      ];
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("living_room_edited.png", buffer);
          console.log("Image saved as living_room_edited.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
      "context"
      "fmt"
      "log"
      "os"
      "google.golang.org/genai"
    )
    
    func main() {
    
      ctx := context.Background()
      client, err := genai.NewClient(ctx, nil)
      if err != nil {
          log.Fatal(err)
      }
    
      imagePath := "/path/to/your/living_room.png"
      imgData, _ := os.ReadFile(imagePath)
    
      parts := []*genai.Part{
        &genai.Part{
          InlineData: &genai.Blob{
            MIMEType: "image/png",
            Data:     imgData,
          },
        },
        genai.NewPartFromText("Using the provided image of a living room, change only the blue sofa to be a vintage, brown leather chesterfield sofa. Keep the rest of the room, including the pillows on the sofa and the lighting, unchanged."),
      }
    
      contents := []*genai.Content{
        genai.NewContentFromParts(parts, genai.RoleUser),
      }
    
      result, _ := client.Models.GenerateContent(
          ctx,
          "gemini-3.1-flash-image-preview",
          contents,
      )
    
      for _, part := range result.Candidates[0].Content.Parts {
          if part.Text != "" {
              fmt.Println(part.Text)
          } else if part.InlineData != nil {
              imageBytes := part.InlineData.Data
              outputFilename := "living_room_edited.png"
              _ = os.WriteFile(outputFilename, imageBytes, 0644)
          }
      }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.Content;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    
    public class Inpainting {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              Content.fromParts(
                  Part.fromBytes(
                      Files.readAllBytes(
                          Path.of("/path/to/your/living_room.png")),
                      "image/png"),
                  Part.fromText("""
                      Using the provided image of a living room, change
                      only the blue sofa to be a vintage, brown leather
                      chesterfield sofa. Keep the rest of the room,
                      including the pillows on the sofa and the lighting,
                      unchanged.
                      """)),
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("living_room_edited.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
        -H "x-goog-api-key: $GEMINI_API_KEY" \
        -H 'Content-Type: application/json' \
        -d "{
          \"contents\": [{
            \"parts\":[
                {
                  \"inline_data\": {
                    \"mime_type\":\"image/png\",
                    \"data\": \"<BASE64_IMAGE_DATA>\"
                  }
                },
                {\"text\": \"Using the provided image of a living room, change only the blue sofa to be a vintage, brown leather chesterfield sofa. Keep the rest of the room, including the pillows on the sofa and the lighting, unchanged.\"}
            ]
          }]
        }"
    

    Hyrje

    Prodhimi

    Një pamje e gjerë e një dhome ndenjeje moderne dhe të ndriçuar mirë...
    Një pamje e gjerë e një dhome ndenjeje moderne dhe të ndriçuar mirë...
    Duke përdorur imazhin e dhënë të një dhome ndenjeje, ndryshoni vetëm divanin blu në një divan prej lëkure vintage, ngjyrë kafe, të stilit Chesterfield...
    Duke përdorur imazhin e dhënë të një dhome ndenjeje, ndryshoni vetëm divanin blu në një divan prej lëkure vintage, ngjyrë kafe, të stilit Chesterfield...

    3. Transferimi i stilit

    Jepni një imazh dhe kërkojini modelit të rikrijojë përmbajtjen e tij në një stil artistik të ndryshëm.

    Shabllon

    Transform the provided photograph of [subject] into the artistic style of [artist/art style]. Preserve the original composition but render it with [description of stylistic elements].
    

    Nxitje

    "Transform the provided photograph of a modern city street at night into the artistic style of Vincent van Gogh's 'Starry Night'. Preserve the original composition of buildings and cars, but render all elements with swirling, impasto brushstrokes and a dramatic palette of deep blues and bright yellows."
    

    Python

    from google import genai
    from google.genai import types
    from PIL import Image
    
    client = genai.Client()
    
    # Base image prompt: "A photorealistic, high-resolution photograph of a busy city street in New York at night, with bright neon signs, yellow taxis, and tall skyscrapers."
    city_image = Image.open('/path/to/your/city.png')
    text_input = """Transform the provided photograph of a modern city street at night into the artistic style of Vincent van Gogh's 'Starry Night'. Preserve the original composition of buildings and cars, but render all elements with swirling, impasto brushstrokes and a dramatic palette of deep blues and bright yellows."""
    
    # Generate an image from a text prompt
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[city_image, text_input],
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("city_style_transfer.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const imagePath = "/path/to/your/city.png";
      const imageData = fs.readFileSync(imagePath);
      const base64Image = imageData.toString("base64");
    
      const prompt = [
        {
          inlineData: {
            mimeType: "image/png",
            data: base64Image,
          },
        },
        { text: "Transform the provided photograph of a modern city street at night into the artistic style of Vincent van Gogh's 'Starry Night'. Preserve the original composition of buildings and cars, but render all elements with swirling, impasto brushstrokes and a dramatic palette of deep blues and bright yellows." },
      ];
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("city_style_transfer.png", buffer);
          console.log("Image saved as city_style_transfer.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
      "context"
      "fmt"
      "log"
      "os"
      "google.golang.org/genai"
    )
    
    func main() {
    
      ctx := context.Background()
      client, err := genai.NewClient(ctx, nil)
      if err != nil {
          log.Fatal(err)
      }
    
      imagePath := "/path/to/your/city.png"
      imgData, _ := os.ReadFile(imagePath)
    
      parts := []*genai.Part{
        &genai.Part{
          InlineData: &genai.Blob{
            MIMEType: "image/png",
            Data:     imgData,
          },
        },
        genai.NewPartFromText("Transform the provided photograph of a modern city street at night into the artistic style of Vincent van Gogh's 'Starry Night'. Preserve the original composition of buildings and cars, but render all elements with swirling, impasto brushstrokes and a dramatic palette of deep blues and bright yellows."),
      }
    
      contents := []*genai.Content{
        genai.NewContentFromParts(parts, genai.RoleUser),
      }
    
      result, _ := client.Models.GenerateContent(
          ctx,
          "gemini-3.1-flash-image-preview",
          contents,
      )
    
      for _, part := range result.Candidates[0].Content.Parts {
          if part.Text != "" {
              fmt.Println(part.Text)
          } else if part.InlineData != nil {
              imageBytes := part.InlineData.Data
              outputFilename := "city_style_transfer.png"
              _ = os.WriteFile(outputFilename, imageBytes, 0644)
          }
      }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.Content;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    
    public class StyleTransfer {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              Content.fromParts(
                  Part.fromBytes(
                      Files.readAllBytes(
                          Path.of("/path/to/your/city.png")),
                      "image/png"),
                  Part.fromText("""
                      Transform the provided photograph of a modern city
                      street at night into the artistic style of
                      Vincent van Gogh's 'Starry Night'. Preserve the
                      original composition of buildings and cars, but
                      render all elements with swirling, impasto
                      brushstrokes and a dramatic palette of deep blues
                      and bright yellows.
                      """)),
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("city_style_transfer.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
        -H "x-goog-api-key: $GEMINI_API_KEY" \
        -H 'Content-Type: application/json' \
        -d "{
          \"contents\": [{
            \"parts\":[
                {
                  \"inline_data\": {
                    \"mime_type\":\"image/png\",
                    \"data\": \"<BASE64_IMAGE_DATA>\"
                  }
                },
                {\"text\": \"Transform the provided photograph of a modern city street at night into the artistic style of Vincent van Gogh's 'Starry Night'. Preserve the original composition of buildings and cars, but render all elements with swirling, impasto brushstrokes and a dramatic palette of deep blues and bright yellows.\"}
            ]
          }]
        }"
    

    Hyrje

    Prodhimi

    Një fotografi fotorealiste me rezolucion të lartë e një rruge të qytetit të ngarkuar...
    Një fotografi fotorealiste me rezolucion të lartë e një rruge të qytetit të ngarkuar...
    Transformoni fotografinë e dhënë të një rruge moderne të qytetit natën...
    Transformoni fotografinë e dhënë të një rruge moderne të qytetit natën...

    4. Kompozim i avancuar: Kombinimi i imazheve të shumëfishta

    Jepni imazhe të shumta si kontekst për të krijuar një skenë të re, të përbërë. Kjo është perfekte për makete produktesh ose kolazhe krijuese.

    Shabllon

    Create a new image by combining the elements from the provided images. Take
    the [element from image 1] and place it with/on the [element from image 2].
    The final image should be a [description of the final scene].
    

    Nxitje

    "Create a professional e-commerce fashion photo. Take the blue floral dress
    from the first image and let the woman from the second image wear it.
    Generate a realistic, full-body shot of the woman wearing the dress, with
    the lighting and shadows adjusted to match the outdoor environment."
    

    Python

    from google import genai
    from google.genai import types
    from PIL import Image
    
    client = genai.Client()
    
    # Base image prompts:
    # 1. Dress: "A professionally shot photo of a blue floral summer dress on a plain white background, ghost mannequin style."
    # 2. Model: "Full-body shot of a woman with her hair in a bun, smiling, standing against a neutral grey studio background."
    dress_image = Image.open('/path/to/your/dress.png')
    model_image = Image.open('/path/to/your/model.png')
    
    text_input = """Create a professional e-commerce fashion photo. Take the blue floral dress from the first image and let the woman from the second image wear it. Generate a realistic, full-body shot of the woman wearing the dress, with the lighting and shadows adjusted to match the outdoor environment."""
    
    # Generate an image from a text prompt
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[dress_image, model_image, text_input],
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("fashion_ecommerce_shot.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const imagePath1 = "/path/to/your/dress.png";
      const imageData1 = fs.readFileSync(imagePath1);
      const base64Image1 = imageData1.toString("base64");
      const imagePath2 = "/path/to/your/model.png";
      const imageData2 = fs.readFileSync(imagePath2);
      const base64Image2 = imageData2.toString("base64");
    
      const prompt = [
        {
          inlineData: {
            mimeType: "image/png",
            data: base64Image1,
          },
        },
        {
          inlineData: {
            mimeType: "image/png",
            data: base64Image2,
          },
        },
        { text: "Create a professional e-commerce fashion photo. Take the blue floral dress from the first image and let the woman from the second image wear it. Generate a realistic, full-body shot of the woman wearing the dress, with the lighting and shadows adjusted to match the outdoor environment." },
      ];
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("fashion_ecommerce_shot.png", buffer);
          console.log("Image saved as fashion_ecommerce_shot.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
      "context"
      "fmt"
      "log"
      "os"
      "google.golang.org/genai"
    )
    
    func main() {
    
      ctx := context.Background()
      client, err := genai.NewClient(ctx, nil)
      if err != nil {
          log.Fatal(err)
      }
    
      imgData1, _ := os.ReadFile("/path/to/your/dress.png")
      imgData2, _ := os.ReadFile("/path/to/your/model.png")
    
      parts := []*genai.Part{
        &genai.Part{
          InlineData: &genai.Blob{
            MIMEType: "image/png",
            Data:     imgData1,
          },
        },
        &genai.Part{
          InlineData: &genai.Blob{
            MIMEType: "image/png",
            Data:     imgData2,
          },
        },
        genai.NewPartFromText("Create a professional e-commerce fashion photo. Take the blue floral dress from the first image and let the woman from the second image wear it. Generate a realistic, full-body shot of the woman wearing the dress, with the lighting and shadows adjusted to match the outdoor environment."),
      }
    
      contents := []*genai.Content{
        genai.NewContentFromParts(parts, genai.RoleUser),
      }
    
      result, _ := client.Models.GenerateContent(
          ctx,
          "gemini-3.1-flash-image-preview",
          contents,
      )
    
      for _, part := range result.Candidates[0].Content.Parts {
          if part.Text != "" {
              fmt.Println(part.Text)
          } else if part.InlineData != nil {
              imageBytes := part.InlineData.Data
              outputFilename := "fashion_ecommerce_shot.png"
              _ = os.WriteFile(outputFilename, imageBytes, 0644)
          }
      }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.Content;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    
    public class AdvancedComposition {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              Content.fromParts(
                  Part.fromBytes(
                      Files.readAllBytes(
                          Path.of("/path/to/your/dress.png")),
                      "image/png"),
                  Part.fromBytes(
                      Files.readAllBytes(
                          Path.of("/path/to/your/model.png")),
                      "image/png"),
                  Part.fromText("""
                      Create a professional e-commerce fashion photo.
                      Take the blue floral dress from the first image and
                      let the woman from the second image wear it. Generate
                      a realistic, full-body shot of the woman wearing the
                      dress, with the lighting and shadows adjusted to
                      match the outdoor environment.
                      """)),
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("fashion_ecommerce_shot.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
        -H "x-goog-api-key: $GEMINI_API_KEY" \
        -H 'Content-Type: application/json' \
        -d "{
          \"contents\": [{
            \"parts\":[
                {
                  \"inline_data\": {
                    \"mime_type\":\"image/png\",
                    \"data\": \"<BASE64_IMAGE_DATA_1>\"
                  }
                },
                {
                  \"inline_data\": {
                    \"mime_type\":\"image/png\",
                    \"data\": \"<BASE64_IMAGE_DATA_2>\"
                  }
                },
                {\"text\": \"Create a professional e-commerce fashion photo. Take the blue floral dress from the first image and let the woman from the second image wear it. Generate a realistic, full-body shot of the woman wearing the dress, with the lighting and shadows adjusted to match the outdoor environment.\"}
            ]
          }]
        }"
    

    Hyrja 1

    Hyrja 2

    Prodhimi

    Një foto e shkrepur profesionalisht e një fustani veror me lule blu...
    Një foto e shkrepur profesionalisht e një fustani veror me lule blu...
    Foto e plotë e një gruaje me flokët e mbledhura topuz...
    Foto e plotë e një gruaje me flokët e mbledhura topuz...
    Krijo një foto profesionale mode për tregtinë elektronike...
    Krijo një foto profesionale mode për tregtinë elektronike...

    5. Ruajtja e detajeve me besnikëri të lartë

    Për t'u siguruar që detajet kritike (si një fytyrë ose logo) ruhen gjatë një redaktimi, përshkruajini ato me shumë detaje së bashku me kërkesën tuaj për redaktim.

    Shabllon

    Using the provided images, place [element from image 2] onto [element from
    image 1]. Ensure that the features of [element from image 1] remain
    completely unchanged. The added element should [description of how the
    element should integrate].
    

    Nxitje

    "Take the first image of the woman with brown hair, blue eyes, and a neutral
    expression. Add the logo from the second image onto her black t-shirt.
    Ensure the woman's face and features remain completely unchanged. The logo
    should look like it's naturally printed on the fabric, following the folds
    of the shirt."
    

    Python

    from google import genai
    from google.genai import types
    from PIL import Image
    
    client = genai.Client()
    
    # Base image prompts:
    # 1. Woman: "A professional headshot of a woman with brown hair and blue eyes, wearing a plain black t-shirt, against a neutral studio background."
    # 2. Logo: "A simple, modern logo with the letters 'G' and 'A' in a white circle."
    woman_image = Image.open('/path/to/your/woman.png')
    logo_image = Image.open('/path/to/your/logo.png')
    text_input = """Take the first image of the woman with brown hair, blue eyes, and a neutral expression. Add the logo from the second image onto her black t-shirt. Ensure the woman's face and features remain completely unchanged. The logo should look like it's naturally printed on the fabric, following the folds of the shirt."""
    
    # Generate an image from a text prompt
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[woman_image, logo_image, text_input],
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("woman_with_logo.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const imagePath1 = "/path/to/your/woman.png";
      const imageData1 = fs.readFileSync(imagePath1);
      const base64Image1 = imageData1.toString("base64");
      const imagePath2 = "/path/to/your/logo.png";
      const imageData2 = fs.readFileSync(imagePath2);
      const base64Image2 = imageData2.toString("base64");
    
      const prompt = [
        {
          inlineData: {
            mimeType: "image/png",
            data: base64Image1,
          },
        },
        {
          inlineData: {
            mimeType: "image/png",
            data: base64Image2,
          },
        },
        { text: "Take the first image of the woman with brown hair, blue eyes, and a neutral expression. Add the logo from the second image onto her black t-shirt. Ensure the woman's face and features remain completely unchanged. The logo should look like it's naturally printed on the fabric, following the folds of the shirt." },
      ];
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("woman_with_logo.png", buffer);
          console.log("Image saved as woman_with_logo.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
      "context"
      "fmt"
      "log"
      "os"
      "google.golang.org/genai"
    )
    
    func main() {
    
      ctx := context.Background()
      client, err := genai.NewClient(ctx, nil)
      if err != nil {
          log.Fatal(err)
      }
    
      imgData1, _ := os.ReadFile("/path/to/your/woman.png")
      imgData2, _ := os.ReadFile("/path/to/your/logo.png")
    
      parts := []*genai.Part{
        &genai.Part{
          InlineData: &genai.Blob{
            MIMEType: "image/png",
            Data:     imgData1,
          },
        },
        &genai.Part{
          InlineData: &genai.Blob{
            MIMEType: "image/png",
            Data:     imgData2,
          },
        },
        genai.NewPartFromText("Take the first image of the woman with brown hair, blue eyes, and a neutral expression. Add the logo from the second image onto her black t-shirt. Ensure the woman's face and features remain completely unchanged. The logo should look like it's naturally printed on the fabric, following the folds of the shirt."),
      }
    
      contents := []*genai.Content{
        genai.NewContentFromParts(parts, genai.RoleUser),
      }
    
      result, _ := client.Models.GenerateContent(
          ctx,
          "gemini-3.1-flash-image-preview",
          contents,
      )
    
      for _, part := range result.Candidates[0].Content.Parts {
          if part.Text != "" {
              fmt.Println(part.Text)
          } else if part.InlineData != nil {
              imageBytes := part.InlineData.Data
              outputFilename := "woman_with_logo.png"
              _ = os.WriteFile(outputFilename, imageBytes, 0644)
          }
      }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.Content;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    
    public class HighFidelity {
      public static void main(String[] args) throws IOException {
    
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              Content.fromParts(
                  Part.fromBytes(
                      Files.readAllBytes(
                          Path.of("/path/to/your/woman.png")),
                      "image/png"),
                  Part.fromBytes(
                      Files.readAllBytes(
                          Path.of("/path/to/your/logo.png")),
                      "image/png"),
                  Part.fromText("""
                      Take the first image of the woman with brown hair,
                      blue eyes, and a neutral expression. Add the logo
                      from the second image onto her black t-shirt.
                      Ensure the woman's face and features remain
                      completely unchanged. The logo should look like
                      it's naturally printed on the fabric, following
                      the folds of the shirt.
                      """)),
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("woman_with_logo.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
        -H "x-goog-api-key: $GEMINI_API_KEY" \
        -H 'Content-Type: application/json' \
        -d "{
          \"contents\": [{
            \"parts\":[
                {
                  \"inline_data\": {
                    \"mime_type\":\"image/png\",
                    \"data\": \"<BASE64_IMAGE_DATA_1>\"
                  }
                },
                {
                  \"inline_data\": {
                    \"mime_type\":\"image/png\",
                    \"data\": \"<BASE64_IMAGE_DATA_2>\"
                  }
                },
                {\"text\": \"Take the first image of the woman with brown hair, blue eyes, and a neutral expression. Add the logo from the second image onto her black t-shirt. Ensure the woman's face and features remain completely unchanged. The logo should look like it's naturally printed on the fabric, following the folds of the shirt.\"}
            ]
          }]
        }"
    

    Hyrja 1

    Hyrja 2

    Prodhimi

    Një foto profesionale e një gruaje me flokë kafe dhe sy blu...
    Një foto profesionale e një gruaje me flokë kafe dhe sy blu...
    Një logo e thjeshtë dhe moderne me shkronjat 'G' dhe 'A'...
    Një logo e thjeshtë dhe moderne me shkronjat 'G' dhe 'A'...
    Merrni imazhin e parë të gruas me flokë kafe, sy blu dhe një shprehje neutrale...
    Merrni imazhin e parë të gruas me flokë kafe, sy blu dhe një shprehje neutrale...

    6. Jepini jetë diçkaje

    Ngarko një skicë ose vizatim të përafërt dhe kërkoji modelit ta rafinojë atë në një imazh të përfunduar.

    Shabllon

    Turn this rough [medium] sketch of a [subject] into a [style description]
    photo. Keep the [specific features] from the sketch but add [new details/materials].
    

    Nxitje

    "Turn this rough pencil sketch of a futuristic car into a polished photo of the finished concept car in a showroom. Keep the sleek lines and low profile from the sketch but add metallic blue paint and neon rim lighting."
    

    Python

    from google import genai
    from PIL import Image
    
    client = genai.Client()
    
    # Base image prompt: "A rough pencil sketch of a flat sports car on white paper."
    sketch_image = Image.open('/path/to/your/car_sketch.png')
    text_input = """Turn this rough pencil sketch of a futuristic car into a polished photo of the finished concept car in a showroom. Keep the sleek lines and low profile from the sketch but add metallic blue paint and neon rim lighting."""
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[sketch_image, text_input],
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("car_photo.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const imagePath = "/path/to/your/car_sketch.png";
      const imageData = fs.readFileSync(imagePath);
      const base64Image = imageData.toString("base64");
    
      const prompt = [
        {
          inlineData: {
            mimeType: "image/png",
            data: base64Image,
          },
        },
        { text: "Turn this rough pencil sketch of a futuristic car into a polished photo of the finished concept car in a showroom. Keep the sleek lines and low profile from the sketch but add metallic blue paint and neon rim lighting." },
      ];
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("car_photo.png", buffer);
          console.log("Image saved as car_photo.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
      "context"
      "fmt"
      "log"
      "os"
      "google.golang.org/genai"
    )
    
    func main() {
    
      ctx := context.Background()
      client, err := genai.NewClient(ctx, nil)
      if err != nil {
          log.Fatal(err)
      }
    
      imgData, _ := os.ReadFile("/path/to/your/car_sketch.png")
    
      parts := []*genai.Part{
        &genai.Part{
          InlineData: &genai.Blob{
            MIMEType: "image/png",
            Data:     imgData,
          },
        },
        genai.NewPartFromText("Turn this rough pencil sketch of a futuristic car into a polished photo of the finished concept car in a showroom. Keep the sleek lines and low profile from the sketch but add metallic blue paint and neon rim lighting."),
      }
    
      contents := []*genai.Content{
        genai.NewContentFromParts(parts, genai.RoleUser),
      }
    
      result, _ := client.Models.GenerateContent(
          ctx,
          "gemini-3.1-flash-image-preview",
          contents,
      )
    
      for _, part := range result.Candidates[0].Content.Parts {
          if part.Text != "" {
              fmt.Println(part.Text)
          } else if part.InlineData != nil {
              imageBytes := part.InlineData.Data
              outputFilename := "car_photo.png"
              _ = os.WriteFile(outputFilename, imageBytes, 0644)
          }
      }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.Content;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    
    public class BringToLife {
      public static void main(String[] args) throws IOException {
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              Content.fromParts(
                  Part.fromBytes(
                      Files.readAllBytes(
                          Path.of("/path/to/your/car_sketch.png")),
                      "image/png"),
                  Part.fromText("""
                      Turn this rough pencil sketch of a futuristic car into a polished photo of the finished concept car in a showroom. Keep the sleek lines and low profile from the sketch but add metallic blue paint and neon rim lighting.
                      """)),
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("car_photo.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
        -H "x-goog-api-key: $GEMINI_API_KEY" \
        -H 'Content-Type: application/json' \
        -d "{
          \"contents\": [{
            \"parts\":[
                {
                  \"inline_data\": {
                    \"mime_type\":\"image/png\",
                    \"data\": \"<BASE64_IMAGE_DATA>\"
                  }
                },
                {\"text\": \"Turn this rough pencil sketch of a futuristic car into a polished photo of the finished concept car in a showroom. Keep the sleek lines and low profile from the sketch but add metallic blue paint and neon rim lighting.\"}
            ]
          }]
        }"
    

    Hyrje

    Prodhimi

    Skicë e një makine
    Skicë e përafërt e një makine
    Rezultati që tregon konceptin përfundimtar të makinës
    Foto e lëmuar e një makine

    7. Konsistenca e personazheve: Pamje 360 ​​gradë

    Mund të gjeneroni pamje 360 ​​gradë të një personazhi duke kërkuar në mënyrë iterative kënde të ndryshme. Për rezultate më të mira, përfshini imazhe të gjeneruara më parë në kërkesat pasuese për të ruajtur qëndrueshmërinë. Për poza komplekse, përfshini një imazh reference të pozës së dëshiruar.

    Shabllon

    A studio portrait of [person] against [background], [looking forward/in profile looking right/etc.]
    

    Nxitje

    A studio portrait of this man against white, in profile looking right
    

    Python

    from google import genai
    from google.genai import types
    from PIL import Image
    
    client = genai.Client()
    
    image_input = Image.open('/path/to/your/man_in_white_glasses.jpg')
    text_input = """A studio portrait of this man against white, in profile looking right"""
    
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[text_input, image_input],
    )
    
    for part in response.parts:
        if part.text is not None:
            print(part.text)
        elif part.inline_data is not None:
            image = part.as_image()
            image.save("man_right_profile.png")
    

    JavaScript

    import { GoogleGenAI } from "@google/genai";
    import * as fs from "node:fs";
    
    async function main() {
    
      const ai = new GoogleGenAI({});
    
      const imagePath = "/path/to/your/man_in_white_glasses.jpg";
      const imageData = fs.readFileSync(imagePath);
      const base64Image = imageData.toString("base64");
    
      const prompt = [
        { text: "A studio portrait of this man against white, in profile looking right" },
        {
          inlineData: {
            mimeType: "image/jpeg",
            data: base64Image,
          },
        },
      ];
    
      const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
      });
      for (const part of response.candidates[0].content.parts) {
        if (part.text) {
          console.log(part.text);
        } else if (part.inlineData) {
          const imageData = part.inlineData.data;
          const buffer = Buffer.from(imageData, "base64");
          fs.writeFileSync("man_right_profile.png", buffer);
          console.log("Image saved as man_right_profile.png");
        }
      }
    }
    
    main();
    

    Shko

    package main
    
    import (
      "context"
      "fmt"
      "log"
      "os"
      "google.golang.org/genai"
    )
    
    func main() {
    
      ctx := context.Background()
      client, err := genai.NewClient(ctx, nil)
      if err != nil {
          log.Fatal(err)
      }
    
      imagePath := "/path/to/your/man_in_white_glasses.jpg"
      imgData, _ := os.ReadFile(imagePath)
    
      parts := []*genai.Part{
        genai.NewPartFromText("A studio portrait of this man against white, in profile looking right"),
        &genai.Part{
          InlineData: &genai.Blob{
            MIMEType: "image/jpeg",
            Data:     imgData,
          },
        },
      }
    
      contents := []*genai.Content{
        genai.NewContentFromParts(parts, genai.RoleUser),
      }
    
      result, _ := client.Models.GenerateContent(
          ctx,
          "gemini-3.1-flash-image-preview",
          contents,
      )
    
      for _, part := range result.Candidates[0].Content.Parts {
          if part.Text != "" {
              fmt.Println(part.Text)
          } else if part.InlineData != nil {
              imageBytes := part.InlineData.Data
              outputFilename := "man_right_profile.png"
              _ = os.WriteFile(outputFilename, imageBytes, 0644)
          }
      }
    }
    

    Java

    import com.google.genai.Client;
    import com.google.genai.types.Content;
    import com.google.genai.types.GenerateContentConfig;
    import com.google.genai.types.GenerateContentResponse;
    import com.google.genai.types.Part;
    
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.nio.file.Paths;
    
    public class CharacterConsistency {
      public static void main(String[] args) throws IOException {
        try (Client client = new Client()) {
          GenerateContentConfig config = GenerateContentConfig.builder()
              .responseModalities("TEXT", "IMAGE")
              .build();
    
          GenerateContentResponse response = client.models.generateContent(
              "gemini-3.1-flash-image-preview",
              Content.fromParts(
                  Part.fromText("""
                      A studio portrait of this man against white, in profile looking right
                      """),
                  Part.fromBytes(
                      Files.readAllBytes(
                          Path.of("/path/to/your/man_in_white_glasses.jpg")),
                      "image/jpeg")),
              config);
    
          for (Part part : response.parts()) {
            if (part.text().isPresent()) {
              System.out.println(part.text().get());
            } else if (part.inlineData().isPresent()) {
              var blob = part.inlineData().get();
              if (blob.data().isPresent()) {
                Files.write(Paths.get("man_right_profile.png"), blob.data().get());
              }
            }
          }
        }
      }
    }
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
        -H "x-goog-api-key: $GEMINI_API_KEY" \
        -H 'Content-Type: application/json' \
        -d "{
          \"contents\": [{
            \"parts\":[
                {\"text\": \"A studio portrait of this man against white, in profile looking right\"},
                {
                  \"inline_data\": {
                    \"mime_type\":\"image/jpeg\",
                    \"data\": \"<BASE64_IMAGE_DATA>\"
                  }
                }
            ]
          }]
        }"
    

    Hyrje

    Dalja 1

    Dalja 2

    Informacion origjinal i një burri me syze të bardha
    Imazh origjinal
    Prodhimi i një burri me syze të bardha që duket mirë
    Burrë me syze të bardha që shikon drejt
    Prodhimi i një burri me syze të bardha që shikon përpara
    Burrë me syze të bardha duke parë përpara

    Praktikat më të Mira

    Për t'i përmirësuar rezultatet tuaja nga të mira në të shkëlqyera, përfshini këto strategji profesionale në rrjedhën tuaj të punës.

    • Ji hiper-specifik: Sa më shumë detaje të japësh, aq më shumë kontroll ke. Në vend të "armaturës fantazi", përshkruaje atë: "armaturë e zbukuruar me pllaka elfësh, e gdhendur me modele gjethesh argjendi, me një jakë të lartë dhe pauldronë në formën e krahëve të skifterit".
    • Jepni kontekstin dhe qëllimin: Shpjegoni qëllimin e imazhit. Kuptimi i kontekstit nga modeli do të ndikojë në rezultatin përfundimtar. Për shembull, "Krijo një logo për një markë të nivelit të lartë dhe minimaliste të kujdesit për lëkurën" do të japë rezultate më të mira sesa thjesht "Krijo një logo".
    • Përsëriteni dhe përsosni: Mos prisni një imazh perfekt që në provën e parë. Përdorni natyrën bisedore të modelit për të bërë ndryshime të vogla. Ndiqni me pyetje të tilla si: "Kjo është shumë mirë, por a mund ta bëni ndriçimin pak më të ngrohtë?" ose "Mbajeni gjithçka të njëjtë, por ndryshoni shprehjen e personazhit që të jetë më serioz".
    • Përdorni udhëzime hap pas hapi: Për skena komplekse me shumë elementë, ndajeni kërkesën tuaj në hapa. "Së pari, krijoni një sfond të një pylli të qetë dhe me mjegull në agim. Pastaj, në plan të parë, shtoni një altar të lashtë prej guri të mbuluar me myshk. Së fundmi, vendosni një shpatë të vetme që ndriçon sipër altarit."
    • Përdorni "Shtylla Semantike Negative": Në vend që të thoni "nuk ka makina", përshkruani skenën e dëshiruar pozitivisht: "një rrugë e zbrazët, e shkretë pa shenja trafiku".
    • Kontrolloni Kamerën: Përdorni gjuhë fotografike dhe kinematografike për të kontrolluar kompozimin. Terma si wide-angle shot , macro shot , low-angle perspective .

    Kufizime

    • Për performancën më të mirë, përdorni gjuhët e mëposhtme: EN, ar-EG, de-DE, es-MX, fr-FR, hi-IN, id-ID, it-IT, ja-JP, ko-KR, pt-BR, ru-RU, ua-UA, vi-VN, zh-CN.
    • Gjenerimi i imazheve nuk mbështet hyrjet audio ose video.
    • Modeli nuk do të ndjekë gjithmonë numrin e saktë të rezultateve të imazheve që përdoruesi kërkon në mënyrë të qartë.
    • gemini-2.5-flash-image funksionon më së miri me deri në 3 imazhe si të dhëna hyrëse, ndërsa gemini-3-pro-image-preview mbështet 5 imazhe me besueshmëri të lartë dhe deri në 14 imazhe në total. gemini-3.1-flash-image-preview mbështet ngjashmërinë e personazheve deri në 4 personazhe dhe besnikërinë e deri në 10 objekteve në një rrjedhë të vetme pune.
    • Kur gjeneroni tekst për një imazh, Gemini funksionon më mirë nëse së pari gjeneroni tekstin dhe më pas kërkoni një imazh me tekstin.
    • Të gjitha imazhet e gjeneruara përfshijnë një filigran SynthID .

    Konfigurime opsionale

    Mund të konfiguroni opsionalisht modalitetet e përgjigjes dhe raportin e aspektit të daljes së modelit në fushën e config të thirrjeve generate_content .

    Llojet e daljeve

    Modeli, si parazgjedhje, kthen përgjigje me tekst dhe imazh (p.sh., response_modalities=['Text', 'Image'] ). Mund ta konfiguroni përgjigjen për të kthyer vetëm imazhe pa tekst duke përdorur response_modalities=['Image'] .

    Python

    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[prompt],
        config=types.GenerateContentConfig(
            response_modalities=['Image']
        )
    )
    

    JavaScript

    const response = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
        config: {
            responseModalities: ['Image']
        }
      });
    

    Shko

    result, _ := client.Models.GenerateContent(
        ctx,
        "gemini-3.1-flash-image-preview",
        genai.Text("Create a picture of a nano banana dish in a " +
                    " fancy restaurant with a Gemini theme"),
        &genai.GenerateContentConfig{
            ResponseModalities: "Image",
        },
      )
    

    Java

    response = client.models.generateContent(
        "gemini-3.1-flash-image-preview",
        prompt,
        GenerateContentConfig.builder()
            .responseModalities("IMAGE")
            .build());
    

    PUSHTIM

    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [{
          "parts": [
            {"text": "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"}
          ]
        }],
        "generationConfig": {
          "responseModalities": ["Image"]
        }
      }'
    

    Raportet e aspektit dhe madhësia e imazhit

    Modeli vendoset si parazgjedhje për të përputhur madhësinë e imazhit të daljes me atë të imazhit tuaj hyrës, ose përndryshe gjeneron katrorë 1:1. Ju mund të kontrolloni raportin e aspektit të imazhit të daljes duke përdorur fushën aspect_ratio nën image_config në kërkesën e përgjigjes, të treguar këtu:

    Python

    # For gemini-2.5-flash-image
    response = client.models.generate_content(
        model="gemini-2.5-flash-image",
        contents=[prompt],
        config=types.GenerateContentConfig(
            image_config=types.ImageConfig(
                aspect_ratio="16:9",
            )
        )
    )
    
    # For gemini-3.1-flash-image-preview and gemini-3-pro-image-preview
    response = client.models.generate_content(
        model="gemini-3.1-flash-image-preview",
        contents=[prompt],
        config=types.GenerateContentConfig(
            image_config=types.ImageConfig(
                aspect_ratio="16:9",
                image_size="2K",
            )
        )
    )
    

    JavaScript

    // For gemini-2.5-flash-image
    const response = await ai.models.generateContent({
        model: "gemini-2.5-flash-image",
        contents: prompt,
        config: {
          imageConfig: {
            aspectRatio: "16:9",
          },
        }
      });
    
    // For gemini-3.1-flash-image-preview and gemini-3-pro-image-preview
    const response_gemini3 = await ai.models.generateContent({
        model: "gemini-3.1-flash-image-preview",
        contents: prompt,
        config: {
          imageConfig: {
            aspectRatio: "16:9",
            imageSize: "2K",
          },
        }
      });
    

    Shko

    // For gemini-2.5-flash-image
    result, _ := client.Models.GenerateContent(
        ctx,
        "gemini-2.5-flash-image",
        genai.Text("Create a picture of a nano banana dish in a " +
                    " fancy restaurant with a Gemini theme"),
        &genai.GenerateContentConfig{
            ImageConfig: &genai.ImageConfig{
              AspectRatio: "16:9",
            },
        }
      )
    
    // For gemini-3.1-flash-image-preview and gemini-3-pro-image-preview
    result_gemini3, _ := client.Models.GenerateContent(
        ctx,
        "gemini-3.1-flash-image-preview",
        genai.Text("Create a picture of a nano banana dish in a " +
                    " fancy restaurant with a Gemini theme"),
        &genai.GenerateContentConfig{
            ImageConfig: &genai.ImageConfig{
              AspectRatio: "16:9",
              ImageSize: "2K",
            },
        }
      )
    

    Java

    // For gemini-2.5-flash-image
    response = client.models.generateContent(
        "gemini-2.5-flash-image",
        prompt,
        GenerateContentConfig.builder()
            .imageConfig(ImageConfig.builder()
                .aspectRatio("16:9")
                .build())
            .build());
    
    // For gemini-3.1-flash-image-preview and gemini-3-pro-image-preview
    response_gemini3 = client.models.generateContent(
        "gemini-3.1-flash-image-preview",
        prompt,
        GenerateContentConfig.builder()
            .imageConfig(ImageConfig.builder()
                .aspectRatio("16:9")
                .imageSize("2K")
                .build())
            .build());
    

    PUSHTIM

    # For gemini-2.5-flash-image
    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H 'Content-Type: application/json' \
      -d '{
        "contents": [{
          "parts": [
            {"text": "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"}
          ]
        }],
        "generationConfig": {
          "imageConfig": {
            "aspectRatio": "16:9"
          }
        }
      }'
    
    # For gemini-3-pro-image-preview
    curl -s -X POST \
      "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
      -H "x-goog-api-key: $GEMINI_API_KEY" \
      -H 'Content-Type: application/json' \
      -d '{
        "contents": [{
          "parts": [
            {"text": "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"}
          ]
        }],
        "generationConfig": {
          "imageConfig": {
            "aspectRatio": "16:9",
            "imageSize": "2K"
          }
        }
      }'
    

    Raportet e ndryshme të disponueshme dhe madhësia e imazhit të gjeneruar janë renditur në tabelat e mëposhtme:

    3.1 Pamje paraprake e imazhit me blic

    Raporti i aspektit Rezolucioni 512px 0.5 mijë tokenë Rezolucion 1K 1 mijë tokena Rezolucion 2K 2 mijë tokena Rezolucion 4K 4K tokena
    1:1 512x512 747 1024x1024 1120 2048x2048 1120 4096x4096 2000
    1:4 256x1024 747 512x2048 1120 1024x4096 1120 2048x8192 2000
    1:8 192x1536 747 384x3072 1120 768x6144 1120 1536x12288 2000
    2:3 424x632 747 848x1264 1120 1696x2528 1120 3392x5056 2000
    3:2 632x424 747 1264x848 1120 2528x1696 1120 5056x3392 2000
    3:4 448x600 747 896x1200 1120 1792x2400 1120 3584x4800 2000
    4:1 1024x256 747 2048x512 1120 4096x1024 1120 8192x2048 2000
    4:3 600x448 747 1200x896 1120 2400x1792 1120 4800x3584 2000
    4:5 464x576 747 928x1152 1120 1856x2304 1120 3712x4608 2000
    5:4 576x464 747 1152x928 1120 2304x1856 1120 4608x3712 2000
    8:1 1536x192 747 3072x384 1120 6144x768 1120 12288x1536 2000
    9:16 384x688 747 768x1376 1120 1536x2752 1120 3072x5504 2000
    16:9 688x384 747 1376x768 1120 2752x1536 1120 5504x3072 2000
    21:9 792x168 747 1584x672 1120 3168x1344 1120 6336x2688 2000

    Pamje paraprake e imazhit 3 Pro

    Raporti i aspektit Rezolucion 1K 1 mijë tokena Rezolucion 2K 2 mijë tokena Rezolucion 4K 4K tokena
    1:1 1024x1024 1120 2048x2048 1120 4096x4096 2000
    2:3 848x1264 1120 1696x2528 1120 3392x5056 2000
    3:2 1264x848 1120 2528x1696 1120 5056x3392 2000
    3:4 896x1200 1120 1792x2400 1120 3584x4800 2000
    4:3 1200x896 1120 2400x1792 1120 4800x3584 2000
    4:5 928x1152 1120 1856x2304 1120 3712x4608 2000
    5:4 1152x928 1120 2304x1856 1120 4608x3712 2000
    9:16 768x1376 1120 1536x2752 1120 3072x5504 2000
    16:9 1376x768 1120 2752x1536 1120 5504x3072 2000
    21:9 1584x672 1120 3168x1344 1120 6336x2688 2000

    Imazh Flash i Gemini 2.5

    Raporti i aspektit Rezolucioni Tokenat
    1:1 1024x1024 1290
    2:3 832x1248 1290
    3:2 1248x832 1290
    3:4 864x1184 1290
    4:3 1184x864 1290
    4:5 896x1152 1290
    5:4 1152x896 1290
    9:16 768x1344 1290
    16:9 1344x768 1290
    21:9 1536x672 1290

    Përzgjedhja e modelit

    Zgjidhni modelin që i përshtatet më së miri rastit tuaj specifik të përdorimit.

    • Preview-i i Imazhit Flash Gemini 3.1 (Nano Banana 2 Preview) duhet të jetë modeli juaj i preferuar për gjenerimin e imazheve, si performanca dhe inteligjenca më e mirë në të gjitha aspektet, si dhe balanca më e mirë e kostos dhe vonesës. Shikoni faqen e çmimeve dhe aftësive të modelit për më shumë detaje.

    • Pamja paraprake e imazhit Gemini 3 Pro (Nano Banana Pro Preview) është projektuar për prodhimin profesional të aseteve dhe udhëzimeve komplekse. Ky model përmban tokëzim në botën reale duke përdorur Kërkimin në Google, një proces të parazgjedhur "Thinking" që rafinon kompozimin para gjenerimit dhe mund të gjenerojë imazhe me rezolucion deri në 4K. Kontrolloni faqen e çmimeve dhe aftësive të modelit për më shumë detaje.

    • Imazh Flash Gemini 2.5 (Nano Banana) është projektuar për shpejtësi dhe efikasitet. Ky model është i optimizuar për detyra me volum të lartë dhe me vonesë të ulët dhe gjeneron imazhe me rezolucion 1024px. Kontrolloni faqen e çmimeve dhe aftësive të modelit për më shumë detaje.

    Kur të përdoret Imagen

    Përveç përdorimit të aftësive të integruara të gjenerimit të imazheve të Gemini, ju gjithashtu mund të hyni në Imagen , modelin tonë të specializuar të gjenerimit të imazheve, përmes API-t Gemini.

    Imagen 4 duhet të jetë modeli juaj i preferuar kur filloni të gjeneroni imazhe me Imagen. Zgjidhni Imagen 4 Ultra për raste përdorimi të avancuara ose kur keni nevojë për cilësinë më të mirë të imazhit (vini re se mund të gjeneroni vetëm një imazh në të njëjtën kohë).

    Çfarë vjen më pas