تولید تصویر نانو موز

قبل از نوشتن حتی یک خط کد، از شما خواسته می‌شود تا نمونه‌های اولیه برنامه‌های کاملاً کاربردی و با رابط کاربری کامل را بسازید و ببینید که Nano Banana 2 چگونه با ابزارها، داده‌ها و اکوسیستم Gemini در دنیای واقعی ادغام شده است.
  • اپلیکیشن نانو موز ۲ را امتحان کنید
  • یا از روی دستورالعمل‌ها، خودتان بسازید:
    • مجلهلندنبازیابیموزکافهمقالهسگایزومتریک
    • مجله
      تولید شده توسط نانو موز ۲
      نکته: «عکسی از جلد یک مجله براق، روی جلد آبی مینیمال، کلمات بزرگ و پررنگ Nano Banana نوشته شده است. متن با فونت serif نوشته شده و تمام صفحه را پر کرده است. هیچ متن دیگری وجود ندارد. جلوی متن، پرتره‌ای از شخصی با لباسی شیک و مینیمال وجود دارد. او با حالتی بازیگوشانه عدد ۲ را که نقطه کانونی است، در دست گرفته است.
      شماره شماره و تاریخ «فوریه ۲۰۲۶» را به همراه یک بارکد در گوشه قرار دهید. مجله روی قفسه‌ای روبروی دیوار گچ‌کاری شده نارنجی، در یک فروشگاه طراحان مد است.
    • لندن
      تولید شده توسط نانو موز پرو
      پیشنهاد: «یک صحنه کارتونی سه بعدی مینیاتوری ایزومتریک با زاویه دید ۴۵ درجه از بالا به پایین از لندن ارائه دهید که نمادین‌ترین بناهای تاریخی و عناصر معماری آن را به نمایش می‌گذارد. از بافت‌های نرم و اصلاح‌شده با مواد PBR واقع‌گرایانه و نورپردازی و سایه‌های ملایم و زنده استفاده کنید. شرایط آب و هوایی فعلی را مستقیماً در محیط شهر ادغام کنید تا حال و هوای فراگیری ایجاد شود. از یک ترکیب‌بندی تمیز و مینیمالیستی با پس‌زمینه‌ای نرم و تک‌رنگ استفاده کنید. در مرکز بالا، عنوان «لندن» را با متن بزرگ و پررنگ، یک نماد آب و هوای برجسته در زیر آن، سپس تاریخ (متن کوچک) و دما (متن متوسط) قرار دهید. تمام متن باید با فاصله ثابت در مرکز قرار گیرد و می‌تواند به طور نامحسوسی با بالای ساختمان‌ها همپوشانی داشته باشد.»
      درباره search grounding بیشتر بدانید و آن را در AI Studio امتحان کنید
    • کتزال
      تولید شده توسط نانو موز ۲
      پیشنهاد: «از جستجوی تصویر برای یافتن تصاویر دقیق از یک پرنده‌ی باشکوه quetzal استفاده کنید. یک تصویر زمینه‌ی زیبا با نسبت تصویر ۳:۲ از این پرنده، با یک گرادیان طبیعی از بالا به پایین و ترکیب‌بندی مینیمال، ایجاد کنید.»
      از جستجوی تصویر گوگل با Nano Banana 2 استفاده کنید. آن را در AI Studio امتحان کنید
    • موز
      تولید شده توسط نانو موز پرو
      پیشنهاد: «این لوگو را روی یک تبلیغ گران‌قیمت برای یک عطر با رایحه موز قرار دهید. لوگو کاملاً با بطری ادغام شده است.»
      حفظ جزئیات با کیفیت بالا در Nano Banana را در AI Studio امتحان کنید
    • کافه
      تولید شده توسط نانو موز پرو
      پیشنهاد: «عکسی از یک صحنه روزمره در یک کافه شلوغ که صبحانه سرو می‌کند. در پیش‌زمینه یک مرد انیمه‌ای با موهای آبی دیده می‌شود، یکی از افراد یک طرح مدادی است و دیگری یک هنرمند خمیربازی است.»
      با نانو موز در استودیوی هوش مصنوعی، سبک‌های هنری مختلف را تجربه کنید
    • مقاله
      تولید شده توسط نانو موز پرو
      درخواست: «از جستجو برای یافتن بازخوردهای مربوط به عرضه Gemini 3 Flash استفاده کنید. از این اطلاعات برای نوشتن یک مقاله کوتاه در مورد آن (همراه با سرتیترها) استفاده کنید. عکسی از مقاله را همانطور که در یک مجله براق با محوریت طراحی منتشر شده است، برگردانید. این عکسی از یک صفحه تا شده است که مقاله مربوط به Gemini 3 Flash را نشان می‌دهد. یک عکس اصلی. تیتر با حروف سریف.
      متن دقیقی از جستجو تولید کنید. نانو موز را در استودیوی هوش مصنوعی امتحان کنید.
    • سگ
      تولید شده توسط نانو موز پرو
      پیشنهاد: «آیکونی که نمایانگر یک سگ بامزه است. پس‌زمینه سفید است. آیکن‌ها را به سبک سه‌بعدی رنگارنگ و لمسی طراحی کنید. بدون متن.»
      با Nano Banana در AI Studio آیکون، استیکر و موارد دیگر بسازید
    • ایزومتریک
      تولید شده توسط نانو موز ۲
      سوال: «عکسی بگیرید که کاملاً ایزومتریک باشد. این یک عکس مینیاتوری نیست، بلکه عکسی است که اتفاقاً کاملاً ایزومتریک گرفته شده است. این عکسی از یک باغ مدرن زیبا است. یک استخر بزرگ دو شکل وجود دارد و روی آن نوشته شده است: نانو موز ۲.»

    نانو موز نام قابلیت‌های تولید تصویر بومی Gemini است. Gemini می‌تواند تصاویر را به صورت محاوره‌ای با متن، تصاویر یا ترکیبی از هر دو تولید و پردازش کند. این به شما امکان می‌دهد تا با کنترل بی‌سابقه‌ای، تصاویر را ایجاد، ویرایش و تکرار کنید.

    نانو موز به دو مدل مجزای موجود در Gemini API اشاره دارد:

    • نانو موز ۲ : مدل پیش‌نمایش تصویر فلش Gemini 3.1 ( gemini-3.1-flash-image-preview ). این مدل به عنوان همتای پربازده Gemini 3 Pro Image عمل می‌کند و برای سرعت و موارد استفاده توسعه‌دهندگان با حجم بالا بهینه شده است.
    • نانو موز پرو : مدل پیش‌نمایش تصویر Gemini 3 Pro ( gemini-3-pro-image-preview ). این مدل برای تولید حرفه‌ای دارایی طراحی شده است و از استدلال پیشرفته ("تفکر") برای دنبال کردن دستورالعمل‌های پیچیده و ارائه متن با وضوح بالا استفاده می‌کند.
    • نانو موز : مدل Gemini 2.5 Flash Image ( gemini-2.5-flash-image ). این مدل برای سرعت و کارایی طراحی شده و برای کارهای با حجم بالا و تأخیر کم بهینه شده است.

    تمام تصاویر تولید شده شامل واترمارک SynthID هستند.

    تولید تصویر (تبدیل متن به تصویر)

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
          }
      }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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"}
          ]
        }]
      }'
    

    ویرایش تصویر (تبدیل متن و تصویر به تصویر)

    یادآوری : مطمئن شوید که از حقوق لازم برای هر تصویری که آپلود می‌کنید، برخوردار هستید. محتوایی تولید نکنید که حقوق دیگران را نقض کند، از جمله ویدیوها یا تصاویری که فریب، آزار یا آسیب می‌رسانند. استفاده شما از این سرویس هوش مصنوعی مولد، تابع سیاست استفاده ممنوعه ما است.

    یک تصویر ارائه دهید و از متن‌های راهنما برای اضافه کردن، حذف کردن یا تغییر عناصر، تغییر سبک یا تنظیم درجه‌بندی رنگ استفاده کنید.

    مثال زیر آپلود تصاویر کدگذاری شده با base64 را نشان می‌دهد. برای تصاویر متعدد، بارهای داده بزرگتر و انواع MIME پشتیبانی شده، صفحه درک تصویر را بررسی کنید.

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
         }
     }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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>\"
                  }
                }
            ]
          }]
        }"
    

    ویرایش تصویر چند مرحله‌ای

    به تولید و ویرایش تصاویر به صورت محاوره‌ای ادامه دهید. چت یا گفتگوی چند مرحله‌ای روش پیشنهادی برای تکرار روی تصاویر است. مثال زیر فراخوانی برای تولید یک اینفوگرافیک در مورد فتوسنتز را نشان می‌دهد.

    پایتون

    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")
    

    جاوا اسکریپت

    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");
        }
    }
    

    برو

    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)
                }
            }
        }
    }
    

    جاوا

    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());
              }
            }
          }
          // ...
        }
      }
    }
    

    استراحت

    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"]
        }
      }'
    
    اینفوگرافیک تولید شده توسط هوش مصنوعی در مورد فتوسنتز
    اینفوگرافیک تولید شده توسط هوش مصنوعی در مورد فتوسنتز

    سپس می‌توانید از همان چت برای تغییر زبان روی تصویر به اسپانیایی استفاده کنید.

    پایتون

    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" # "512", "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")
    

    جاوا اسکریپت

    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");
        }
    }
    

    برو

    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"     // "512", "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)
            }
        }
    }
    

    جاوا

    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"; // "512", "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());
        }
      }
    }
    

    استراحت

    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"
          }
        }
      }'
    
    اینفوگرافیک تولید شده توسط هوش مصنوعی از فتوسنتز به زبان اسپانیایی
    اینفوگرافیک تولید شده توسط هوش مصنوعی از فتوسنتز به زبان اسپانیایی

    جدید با مدل‌های Gemini 3 Image

    Gemini 3 مدل‌های پیشرفته تولید و ویرایش تصویر را ارائه می‌دهد. Gemini 3.1 Flash Image برای سرعت و موارد استفاده با حجم بالا بهینه شده است و Gemini 3 Pro Image برای تولید دارایی‌های حرفه‌ای بهینه شده است. این نرم‌افزارها که برای مقابله با چالش‌برانگیزترین گردش‌های کاری از طریق استدلال پیشرفته طراحی شده‌اند، در کارهای پیچیده و چند مرحله‌ای ایجاد و اصلاح، برتری دارند.

    • خروجی با وضوح بالا : قابلیت‌های تولید داخلی برای تصاویر 1K، 2K و 4K.
      • تصویر فلش Gemini 3.1 وضوح کوچکتر 512 (0.5K) را اضافه می‌کند.
    • رندر متن پیشرفته : قادر به تولید متن خوانا و استایل‌دار برای اینفوگرافیک‌ها، منوها، نمودارها و محتوای بازاریابی است.
    • پایه‌گذاری با جستجوی گوگل : این مدل می‌تواند از جستجوی گوگل به عنوان ابزاری برای تأیید حقایق و تولید تصاویر بر اساس داده‌های بلادرنگ (مثلاً نقشه‌های آب و هوای فعلی، نمودارهای سهام، رویدادهای اخیر) استفاده کند.
      • Gemini 3.1 Flash Image در کنار جستجوی وب، قابلیت Grounding را با جستجوی تصاویر گوگل ادغام می‌کند.
    • حالت تفکر : این مدل از یک فرآیند «تفکر» برای استدلال از طریق دستورالعمل‌های پیچیده استفاده می‌کند. این مدل «تصاویر فکری» موقت (که در پشت صحنه قابل مشاهده هستند اما شارژ نمی‌شوند) تولید می‌کند تا ترکیب را قبل از تولید خروجی نهایی با کیفیت بالا اصلاح کند.
    • حداکثر ۱۴ تصویر مرجع : اکنون می‌توانید حداکثر ۱۴ تصویر مرجع را برای تولید تصویر نهایی با هم ترکیب کنید.
    • نسبت‌های ابعاد جدید : پیش‌نمایش تصویر فلش Gemini 3.1 نسبت‌های ابعاد ۱:۴، ۴:۱، ۱:۸ و ۸:۱ را اضافه می‌کند.

    استفاده از حداکثر ۱۴ تصویر مرجع

    مدل‌های تصویر Gemini 3 به شما امکان می‌دهند تا ۱۴ تصویر مرجع را با هم ترکیب کنید. این ۱۴ تصویر می‌توانند شامل موارد زیر باشند:

    پیش‌نمایش تصویر فلش Gemini 3.1 پیش‌نمایش تصویر Gemini 3 Pro
    حداکثر ۱۰ تصویر از اشیاء با وضوح بالا برای گنجاندن در تصویر نهایی حداکثر ۶ تصویر از اشیاء با وضوح بالا برای گنجاندن در تصویر نهایی
    حداکثر ۴ تصویر از شخصیت‌ها برای حفظ انسجام شخصیت حداکثر ۵ تصویر از شخصیت‌ها برای حفظ انسجام شخصیت

    پایتون

    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" # "512", "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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
                }
            }
        }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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\"
            }
          }
        }"
    
    عکس گروهی اداری تولید شده توسط هوش مصنوعی
    عکس گروهی اداری تولید شده توسط هوش مصنوعی

    اتصال به زمین با جستجوی گوگل

    از ابزار جستجوی گوگل برای تولید تصاویر بر اساس اطلاعات لحظه‌ای، مانند پیش‌بینی آب و هوا، نمودار سهام یا رویدادهای اخیر، استفاده کنید.

    توجه داشته باشید که هنگام استفاده از Grounding with Google Search به همراه تولید تصویر، نتایج جستجوی مبتنی بر تصویر به مدل تولید ارسال نمی‌شوند و از پاسخ حذف می‌شوند ( برای تصاویر به Grounding with Google Search مراجعه کنید)

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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"}
        }
      }'
    
    نمودار آب و هوای پنج روزه سانفرانسیسکو که توسط هوش مصنوعی تولید شده است
    نمودار آب و هوای پنج روزه سانفرانسیسکو که توسط هوش مصنوعی تولید شده است

    پاسخ شامل groundingMetadata است که شامل فیلدهای مورد نیاز زیر است:

    • searchEntryPoint : شامل HTML و CSS برای ارائه پیشنهادات جستجوی مورد نیاز است.
    • groundingChunks : سه منبع وب برتر استفاده شده برای ground کردن تصویر تولید شده را برمی‌گرداند.

    اتصال به زمین با جستجوی تصویر گوگل به مدل‌ها اجازه می‌دهد تا از تصاویر وب بازیابی شده از طریق جستجوی تصویر گوگل به عنوان زمینه بصری برای تولید تصویر استفاده کنند. جستجوی تصویر یک نوع جستجوی جدید در ابزار موجود اتصال به زمین با جستجوی گوگل است که در کنار جستجوی وب استاندارد عمل می‌کند.

    برای فعال کردن جستجوی تصویر، ابزار googleSearch را در درخواست API خود پیکربندی کنید و imageSearch در شیء searchTypes مشخص کنید. جستجوی تصویر می‌تواند به طور مستقل یا همراه با جستجوی وب استفاده شود.

    پایتون

    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))
    

    جاوا اسکریپت

    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();
    

    برو

    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)
      }
    }
    

    استراحت

    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"]
        }
      }'
    

    الزامات نمایش

    هنگام استفاده از جستجوی تصویر در Grounding با جستجوی گوگل، باید شرایط زیر را رعایت کنید:

    • انتساب منبع : شما باید پیوندی به صفحه وب حاوی تصویر منبع ("صفحه حاوی"، نه خود فایل تصویر) ارائه دهید به گونه‌ای که کاربر آن را به عنوان یک پیوند تشخیص دهد.
    • پیمایش مستقیم : اگر تصمیم دارید تصاویر منبع را نیز نمایش دهید، باید یک مسیر مستقیم و تک کلیکی از تصاویر منبع به صفحه وب منبع حاوی آن ارائه دهید. هرگونه پیاده‌سازی دیگری که دسترسی کاربر نهایی به صفحه وب منبع را به تأخیر بیندازد یا محدود کند، از جمله اما نه محدود به هرگونه مسیر چند کلیکی یا استفاده از یک نمایشگر تصویر واسطه، مجاز نیست.

    پاسخ

    برای پاسخ‌های مبتنی بر جستجو با استفاده از تصویر، API منبع و فراداده‌ی واضحی را برای پیوند دادن خروجی خود به منابع تأیید شده ارائه می‌دهد. فیلدهای کلیدی در شیء groundingMetadata عبارتند از:

    • imageSearchQueries : کوئری‌های خاصی که توسط مدل برای زمینه بصری (جستجوی تصویر) استفاده می‌شوند.
    • groundingChunks : شامل اطلاعات منبع برای نتایج بازیابی شده است. برای منابع تصویر، این اطلاعات به صورت URL های تغییر مسیر با استفاده از یک نوع قطعه تصویر جدید بازگردانده می‌شوند. این قطعه شامل موارد زیر است:

      • uri : آدرس صفحه وب برای ارجاع (صفحه فرود).
      • image_uri : آدرس مستقیم تصویر.
    • groundingSupports : نگاشت‌های خاصی را ارائه می‌دهد که محتوای تولید شده را به منبع استناد مربوطه در بخش‌ها پیوند می‌دهد.

    • searchEntryPoint : شامل تراشه "جستجوی گوگل" است که حاوی HTML و CSS سازگار برای ارائه پیشنهادات جستجو است.

    تولید تصاویر تا وضوح 4K

    مدل‌های تصویر Gemini 3 به طور پیش‌فرض تصاویر ۱K تولید می‌کنند، اما می‌توانند تصاویر ۲K، ۴K و ۵۱۲ (۰.۵K) (فقط تصاویر فلش Gemini 3.1) را نیز خروجی دهند. برای تولید تصاویر با وضوح بالاتر، image_size در generation_config مشخص کنید.

    شما باید از حرف بزرگ 'K' استفاده کنید (مثلاً 1K، 2K، 4K). مقدار 512 از پسوند 'K' استفاده نمی‌کند. پارامترهای حروف کوچک (مثلاً 1k) رد خواهند شد.

    پایتون

    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" # "512", "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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
                }
            }
        }
    }
    

    جاوا

    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());
                }
              }
            }
          }
        }
    }
    

    استراحت

    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"}
        }
      }'
    

    تصویر زیر نمونه‌ای از تصویری است که از این دستور تولید شده است:

    طرح آناتومیک تشریح شده یک پروانه مونارک به سبک داوینچی که توسط هوش مصنوعی تولید شده است.
    طرح آناتومیک تشریح شده یک پروانه مونارک به سبک داوینچی که توسط هوش مصنوعی تولید شده است.

    فرآیند تفکر

    مدل‌های تصویر Gemini 3، مدل‌های تفکری هستند که از یک فرآیند استدلال ("تفکر") برای دستورات پیچیده استفاده می‌کنند. این ویژگی به طور پیش‌فرض فعال است و نمی‌توان آن را در API غیرفعال کرد. برای کسب اطلاعات بیشتر در مورد فرآیند تفکر، به راهنمای تفکر Gemini مراجعه کنید.

    این مدل تا دو تصویر موقت برای آزمایش ترکیب‌بندی و منطق تولید می‌کند. آخرین تصویر درون Thinking، تصویر رندر شده نهایی نیز هست.

    می‌توانید افکاری را که منجر به تولید تصویر نهایی می‌شوند، بررسی کنید.

    پایتون

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

    جاوا اسکریپت

    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');
        }
      }
    }
    

    کنترل سطوح تفکر

    با استفاده از Gemini 3.1 Flash Image، می‌توانید میزان تفکری که مدل استفاده می‌کند را کنترل کنید تا کیفیت و تأخیر را متعادل کنید. thinkingLevel پیش‌فرض minimal است و سطوح پشتیبانی شده minimal و high هستند.

    شما می‌توانید مقدار بولی includeThoughts اضافه کنید تا مشخص شود که آیا افکار تولید شده توسط مدل در پاسخ بازگردانده می‌شوند یا پنهان می‌مانند.

    پایتون

    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()
    

    جاوا اسکریپت

    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();
    

    برو

    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)
                }
            }
        }
    }
    

    استراحت

    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
          }
        }
      }'
    

    توجه داشته باشید که توکن‌های تفکر صرف نظر از اینکه includeThoughts روی true یا false تنظیم شده باشد، محاسبه می‌شوند، زیرا فرآیند تفکر همیشه به طور پیش‌فرض اتفاق می‌افتد، چه شما این فرآیند را مشاهده کنید و چه نکنید.

    امضاهای فکری

    امضاهای فکری، بازنمایی‌های رمزگذاری‌شده از فرآیند فکری داخلی مدل هستند و برای حفظ زمینه استدلال در تعاملات چند نوبتی استفاده می‌شوند. همه پاسخ‌ها شامل یک فیلد thought_signature هستند. به عنوان یک قاعده کلی، اگر در پاسخ مدل، امضای فکری دریافت کردید، باید هنگام ارسال تاریخچه مکالمه در نوبت بعدی، آن را دقیقاً همانطور که دریافت کرده‌اید، برگردانید. عدم گردش امضاهای فکری ممکن است باعث عدم موفقیت پاسخ شود. برای توضیحات بیشتر در مورد امضاها به طور کلی، مستندات امضای فکری را بررسی کنید.

    نحوه‌ی عملکرد امضاهای فکری به این صورت است:

    • تمام بخش‌های inline_data با mimetype تصویر که بخشی از پاسخ هستند باید دارای امضا باشند.
    • اگر درست بعد از افکار، بخش‌هایی از متن در ابتدا (قبل از هر تصویری) وجود دارد، اولین بخش متن نیز باید امضا داشته باشد.
    • اگر بخش‌های inline_data با mimetype تصویر بخشی از افکار باشند، امضا نخواهند داشت.

    کد زیر مثالی از محل قرارگیری امضاهای فکری را نشان می‌دهد:

    [
      {
        "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
      }
    ]
    

    سایر حالت‌های تولید تصویر

    Gemini از حالت‌های تعامل تصویر دیگر بر اساس ساختار و زمینه سریع پشتیبانی می‌کند، از جمله:

    • متن به تصویر(ها) و متن (به صورت لایه لایه): تصاویر را با متن مرتبط خروجی می‌دهد.
      • نمونه سوال: «یک دستور پخت مصور برای پائلا تهیه کنید.»
    • تصویر(ها) و متن به تصویر(ها) و متن (در هم تنیده) : از تصاویر و متن ورودی برای ایجاد تصاویر و متن مرتبط جدید استفاده می‌کند.
      • نمونه سوال: (با تصویری از یک اتاق مبله) "چه رنگ مبل دیگری در فضای من مناسب است؟ می‌توانید تصویر را به‌روزرسانی کنید؟"

    تولید تصاویر به صورت دسته‌ای

    اگر نیاز به تولید تصاویر زیادی دارید، می‌توانید از Batch API استفاده کنید. در ازای تحویل تا ۲۴ ساعت، محدودیت‌های نرخ بالاتری دریافت می‌کنید.

    برای مثال‌ها و کدهای مربوط به تصاویر Batch API، مستندات تولید تصویر Batch API و کتاب آشپزی را بررسی کنید.

    راهنمای تشویق و استراتژی‌ها

    تسلط بر تولید تصویر با یک اصل اساسی آغاز می‌شود:

    صحنه را توصیف کنید، فقط کلمات کلیدی را فهرست نکنید. نقطه قوت اصلی مدل، درک عمیق آن از زبان است. یک پاراگراف روایی و توصیفی تقریباً همیشه تصویری بهتر و منسجم‌تر از فهرستی از کلمات نامرتبط ایجاد می‌کند.

    دستورالعمل‌های تولید تصاویر

    استراتژی‌های زیر به شما کمک می‌کنند تا پیام‌های مؤثری ایجاد کنید تا دقیقاً همان تصاویری را که به دنبالش هستید، تولید کنید.

    ۱. صحنه‌های واقع‌گرایانه

    برای تصاویر واقع‌گرایانه، از اصطلاحات عکاسی استفاده کنید. زوایای دوربین، انواع لنز، نورپردازی و جزئیات دقیق را ذکر کنید تا مدل را به سمت نتیجه‌ای واقع‌گرایانه هدایت کنید.

    الگو

    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.
    

    سریع

    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.
    

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
            }
        }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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."}
          ]
        }]
      }'
    
    یک پرتره کلوزآپ واقع‌گرایانه از یک سرامیک‌کار مسن ژاپنی...
    یک پرتره کلوزآپ واقع‌گرایانه از یک سرامیک‌کار مسن ژاپنی...

    ۲. تصاویر و برچسب‌های سبک‌دار

    برای ایجاد استیکر، آیکون یا موارد دیگر، در مورد سبک صریح باشید و درخواست پس‌زمینه شفاف کنید.

    الگو

    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.
    

    سریع

    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.
    

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
            }
        }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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."}
          ]
        }]
      }'
    
    یک استیکر به سبک کاوایی از یک قرمز شاد...
    یک استیکر به سبک کاوایی از یک پاندای قرمز خوشحال...

    ۳. متن دقیق در تصاویر

    Gemini در رندر کردن متن عالی عمل می‌کند. در مورد متن، سبک فونت (به صورت توصیفی) و طراحی کلی، شفاف باشید. برای تولید حرفه‌ای از پیش‌نمایش تصویر Gemini 3 Pro استفاده کنید.

    الگو

    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].
    

    سریع

    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.
    

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
            }
        }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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"
          }
        }
      }'
    
    یک لوگوی مدرن و مینیمالیستی برای یک کافی‌شاپ به نام «The Daily Grind» طراحی کنید...
    یک لوگوی مدرن و مینیمالیستی برای یک کافی‌شاپ به نام «The Daily Grind» طراحی کنید...

    ۴. ماکت‌های محصول و عکاسی تجاری

    ایده‌آل برای ایجاد عکس‌های تمیز و حرفه‌ای از محصولات برای تجارت الکترونیک، تبلیغات یا برندسازی.

    الگو

    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].
    

    سریع

    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.
    

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
            }
        }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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."}
          ]
        }]
      }'
    
    یک عکس محصول با وضوح بالا و نورپردازی استودیویی از یک لیوان قهوه سرامیکی مینیمالیستی...
    یک عکس محصول با وضوح بالا و نورپردازی استودیویی از یک لیوان قهوه سرامیکی مینیمالیستی...

    ۵. طراحی مینیمالیستی و فضای منفی

    عالی برای ایجاد پس‌زمینه برای وب‌سایت‌ها، ارائه‌ها یا مطالب بازاریابی که در آن‌ها متن روی چیزی قرار می‌گیرد.

    الگو

    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].
    

    سریع

    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.
    

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
            }
        }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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."}
          ]
        }]
      }'
    
    یک ترکیب مینیمالیستی با یک برگ افرای قرمز ظریف و تک...
    یک ترکیب مینیمالیستی با یک برگ افرای قرمز ظریف و تک...

    ۶. هنر ترتیبی (پنل کمیک / استوری‌بورد)

    بر اساس ثبات شخصیت و توصیف صحنه، پنل‌هایی برای داستان‌سرایی بصری ایجاد می‌کند. برای دقت در متن و توانایی داستان‌سرایی، این دستورالعمل‌ها با پیش‌نمایش تصویر فلش Gemini 3 Pro و Gemini 3.1 بهترین عملکرد را دارند.

    الگو

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

    سریع

    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.
    

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
            }
        }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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>"}}
          ]
        }]
      }'
    

    ورودی

    خروجی

    مرد با عینک سفید
    تصویر ورودی
    یک کمیک سه قسمتی به سبک هنری خشن و نوآر بسازید...
    یک کمیک سه قسمتی به سبک هنری خشن و نوآر بسازید...

    از جستجوی گوگل برای تولید تصاویر بر اساس اطلاعات اخیر یا اطلاعات لحظه‌ای استفاده کنید. این قابلیت برای اخبار، آب و هوا و سایر موضوعات حساس به زمان مفید است.

    سریع

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

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    
    

    برو

    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)
                }
            }
        }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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"}
        }
      }'
    
    گرافیک تولید شده توسط هوش مصنوعی از نتیجه بازی فوتبال آرسنال
    گرافیک تولید شده توسط هوش مصنوعی از نتیجه بازی فوتبال آرسنال

    دستورالعمل‌های ویرایش تصاویر

    این مثال‌ها نشان می‌دهند که چگونه می‌توانید در کنار متن‌های خود، تصاویر را برای ویرایش، ترکیب‌بندی و انتقال سبک ارائه دهید.

    ۱. اضافه کردن و حذف کردن عناصر

    یک تصویر ارائه دهید و تغییر خود را شرح دهید. مدل با سبک، نورپردازی و پرسپکتیو تصویر اصلی مطابقت خواهد داشت.

    الگو

    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].
    

    سریع

    "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."
    

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
          }
      }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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>\"
                  }
                }
            ]
          }]
        }"
    

    ورودی

    خروجی

    تصویری واقع‌گرایانه از یک گربه مو قرمز پشمالو..
    تصویری واقع‌گرایانه از یک گربه مو قرمز پشمالو...
    با استفاده از تصویر گربه من که در اختیارتان قرار داده شده، لطفاً یک کلاه جادوگری کوچک و بافتنی اضافه کنید...
    با استفاده از تصویر گربه من که در اختیارتان قرار داده شده، لطفاً یک کلاه جادوگری کوچک و بافتنی اضافه کنید...

    ۲. رنگ‌آمیزی (پوشش معنایی)

    به صورت محاوره‌ای یک «ماسک» تعریف کنید تا بخش خاصی از تصویر را ویرایش کنید و بقیه را دست‌نخورده باقی بگذارید.

    الگو

    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.
    

    سریع

    "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."
    

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
          }
      }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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.\"}
            ]
          }]
        }"
    

    ورودی

    خروجی

    نمایی باز از یک اتاق نشیمن مدرن و روشن...
    نمایی باز از یک اتاق نشیمن مدرن و روشن...
    با استفاده از تصویر ارائه شده از یک اتاق نشیمن، فقط مبل آبی را به یک مبل چسترفیلد چرمی قهوه‌ای قدیمی تبدیل کنید...
    با استفاده از تصویر ارائه شده از یک اتاق نشیمن، فقط مبل آبی را به یک مبل چسترفیلد چرمی قهوه‌ای قدیمی تبدیل کنید...

    ۳. انتقال سبک

    تصویری ارائه دهید و از مدل بخواهید محتوای آن را با سبک هنری متفاوتی بازآفرینی کند.

    الگو

    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].
    

    سریع

    "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."
    

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
          }
      }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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.\"}
            ]
          }]
        }"
    

    ورودی

    خروجی

    یک عکس واقع‌گرایانه و با وضوح بالا از یک خیابان شلوغ شهری...
    یک عکس واقع‌گرایانه و با وضوح بالا از یک خیابان شلوغ شهری...
    عکس ارائه شده از یک خیابان شهری مدرن در شب را تغییر دهید...
    عکس ارائه شده از یک خیابان شهری مدرن در شب را تغییر دهید...

    ۴. ترکیب پیشرفته: ترکیب چندین تصویر

    چندین تصویر را به عنوان زمینه برای ایجاد یک صحنه جدید و ترکیبی ارائه دهید. این برای ماکت‌های محصول یا کلاژهای خلاقانه عالی است.

    الگو

    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].
    

    سریع

    "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."
    

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
          }
      }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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.\"}
            ]
          }]
        }"
    

    ورودی ۱

    ورودی ۲

    خروجی

    عکسی حرفه‌ای از یک لباس تابستانی آبی گلدار...
    عکسی حرفه‌ای از یک لباس تابستانی آبی گلدار...
    عکس تمام قد از زنی که موهایش را جمع کرده...
    عکس تمام قد از زنی که موهایش را جمع کرده...
    یک عکس مد تجارت الکترونیک حرفه ای ایجاد کنید ...
    یک عکس مد تجارت الکترونیک حرفه ای ایجاد کنید ...

    ۵. حفظ جزئیات با دقت بالا

    برای اطمینان از حفظ جزئیات مهم (مانند چهره یا لوگو) در طول ویرایش، آنها را با جزئیات کامل همراه با درخواست ویرایش خود شرح دهید.

    الگو

    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].
    

    سریع

    "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."
    

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
          }
      }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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.\"}
            ]
          }]
        }"
    

    ورودی ۱

    ورودی ۲

    خروجی

    یک عکس حرفه‌ای از یک زن با موهای قهوه‌ای و چشمان آبی...
    یک عکس حرفه‌ای از یک زن با موهای قهوه‌ای و چشمان آبی...
    یک لوگوی ساده و مدرن با حروف «G» و «A»...
    یک لوگوی ساده و مدرن با حروف «G» و «A»...
    اولین تصویر از زن را با موهای قهوه‌ای، چشمان آبی و حالتی خنثی بگیرید...
    اولین تصویر از زن را با موهای قهوه‌ای، چشمان آبی و حالتی خنثی بگیرید...

    ۶. چیزی را به زندگی بیاورید

    یک طرح یا نقاشی اولیه را آپلود کنید و از مدل بخواهید آن را اصلاح کند تا به یک تصویر نهایی تبدیل شود.

    الگو

    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].
    

    سریع

    "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."
    

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
          }
      }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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.\"}
            ]
          }]
        }"
    

    ورودی

    خروجی

    طرح اولیه یک ماشین
    طرح اولیه یک ماشین
    خروجی که ماشین مفهومی نهایی را نشان می‌دهد
    عکس ماشین براق و صیقل داده شده

    ۷. ثبات شخصیت: نمای ۳۶۰ درجه

    شما می‌توانید با تکرار درخواست برای زوایای مختلف، نماهای ۳۶۰ درجه از یک شخصیت ایجاد کنید. برای بهترین نتیجه، تصاویر تولید شده قبلی را در درخواست‌های بعدی بگنجانید تا ثبات حفظ شود. برای حالت‌های پیچیده، یک تصویر مرجع از حالت مورد نظر را وارد کنید.

    الگو

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

    سریع

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

    پایتون

    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")
    

    جاوا اسکریپت

    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();
    

    برو

    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)
          }
      }
    }
    

    جاوا

    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());
              }
            }
          }
        }
      }
    }
    

    استراحت

    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>\"
                  }
                }
            ]
          }]
        }"
    

    ورودی

    خروجی ۱

    خروجی ۲

    ورودی اصلی مردی با عینک سفید
    تصویر اصلی
    خروجی مردی با عینک سفید که به سمت راست نگاه می‌کند
    مردی با عینک سفید که به سمت راست نگاه می‌کند
    خروجی مردی با عینک سفید که مشتاقانه منتظر است
    مردی با عینک سفید که به جلو نگاه می‌کند

    بهترین شیوه‌ها

    برای ارتقای نتایج خود از خوب به عالی، این استراتژی‌های حرفه‌ای را در جریان کاری خود بگنجانید.

    • بسیار خاص باشید: هرچه جزئیات بیشتری ارائه دهید، کنترل بیشتری خواهید داشت. به جای «زره فانتزی»، آن را اینگونه توصیف کنید: «زره صفحه‌ای الفی مزین، با طرح‌های برگ نقره‌ای، با یقه بلند و پالدرون‌هایی به شکل بال‌های شاهین».
    • ارائه زمینه و هدف: هدف تصویر را توضیح دهید. درک مدل از زمینه بر خروجی نهایی تأثیر خواهد گذاشت. برای مثال، «ایجاد یک لوگو برای یک برند مراقبت از پوست لوکس و مینیمالیستی» نتایج بهتری نسبت به صرفاً «ایجاد یک لوگو» خواهد داشت.
    • تکرار و اصلاح: انتظار نداشته باشید در اولین تلاش، تصویر بی‌نقصی به دست آورید. از ماهیت محاوره‌ای مدل برای ایجاد تغییرات کوچک استفاده کنید. در ادامه، از جملاتی مانند «عالی است، اما می‌توانید نور را کمی گرم‌تر کنید؟» یا «همه چیز را مثل قبل نگه دارید، اما حالت چهره شخصیت را تغییر دهید تا جدی‌تر شود» استفاده کنید.
    • از دستورالعمل‌های گام به گام استفاده کنید: برای صحنه‌های پیچیده با عناصر زیاد، طرح خود را به مراحل مختلف تقسیم کنید. «ابتدا، پس‌زمینه‌ای از یک جنگل آرام و مه‌آلود در سپیده‌دم ایجاد کنید. سپس، در پیش‌زمینه، یک محراب سنگی باستانی پوشیده از خزه اضافه کنید. در نهایت، یک شمشیر درخشان و واحد را روی محراب قرار دهید.»
    • از «تشویق‌های منفی معنایی» استفاده کنید: به جای گفتن «ماشین ممنوع»، صحنه‌ی مورد نظر را به صورت مثبت توصیف کنید: «خیابان خالی و خلوت بدون هیچ نشانه‌ای از ترافیک».
    • کنترل دوربین: از زبان عکاسی و سینمایی برای کنترل ترکیب‌بندی استفاده کنید. اصطلاحاتی مانند wide-angle shot ، macro shot ، low-angle perspective .

    محدودیت‌ها

    • برای بهترین عملکرد، از زبان‌های زیر استفاده کنید: 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.
    • تولید تصویر از ورودی‌های صدا یا تصویر پشتیبانی نمی‌کند.
    • این مدل همیشه تعداد دقیق خروجی‌های تصویری که کاربر صریحاً درخواست می‌کند را دنبال نمی‌کند.
    • gemini-2.5-flash-image با حداکثر ۳ تصویر به عنوان ورودی بهترین عملکرد را دارد، در حالی که gemini-3-pro-image-preview از ۵ تصویر با دقت بالا و در مجموع تا ۱۴ تصویر پشتیبانی می‌کند. gemini-3.1-flash-image-preview از شباهت کاراکتری تا ۴ کاراکتر و دقت تا ۱۰ شیء در یک گردش کار واحد پشتیبانی می‌کند.
    • هنگام تولید متن برای یک تصویر، اگر ابتدا متن را تولید کنید و سپس تصویری با متن درخواست کنید، Gemini بهترین عملکرد را دارد.
    • gemini-3.1-flash-image-preview اتصال زمینی با جستجوی گوگل در حال حاضر از تصاویر واقعی افراد از جستجوی وب پشتیبانی نمی‌کند.
    • تمام تصاویر تولید شده شامل واترمارک SynthID هستند.

    پیکربندی‌های اختیاری

    شما می‌توانید به صورت اختیاری، روش‌های پاسخ و نسبت ابعاد خروجی مدل را در فیلد config فراخوانی‌های generate_content پیکربندی کنید.

    انواع خروجی

    مدل به طور پیش‌فرض پاسخ‌های متنی و تصویری را برمی‌گرداند (یعنی response_modalities=['Text', 'Image'] ). می‌توانید با استفاده از response_modalities=['Image'] پاسخ را طوری پیکربندی کنید که فقط تصاویر بدون متن را برگرداند.

    پایتون

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

    جاوا اسکریپت

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

    برو

    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",
        },
      )
    

    جاوا

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

    استراحت

    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"]
        }
      }'
    

    نسبت ابعاد و اندازه تصویر

    مدل به طور پیش‌فرض اندازه تصویر خروجی را با اندازه تصویر ورودی شما مطابقت می‌دهد، یا در غیر این صورت مربع‌های ۱:۱ تولید می‌کند. می‌توانید نسبت ابعاد تصویر خروجی را با استفاده از فیلد aspect_ratio در زیر image_config در درخواست پاسخ، که در اینجا نشان داده شده است، کنترل کنید:

    پایتون

    # 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",
            )
        )
    )
    

    جاوا اسکریپت

    // 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",
          },
        }
      });
    

    برو

    // 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",
            },
        }
      )
    

    جاوا

    // 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());
    

    استراحت

    # 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"
          }
        }
      }'
    

    نسبت‌های مختلف موجود و اندازه تصویر تولید شده در جداول زیر فهرست شده‌اند:

    ۳.۱ پیش‌نمایش تصویر فلش

    نسبت ابعاد وضوح ۵۱۲ ۰.۵ هزار توکن وضوح ۱K ۱ هزار توکن وضوح تصویر 2K ۲ هزار توکن وضوح تصویر 4K ۴۰۰۰ توکن
    ۱:۱ ۵۱۲x۵۱۲ ۷۴۷ عدد ۱۰۲۴x۱۰۲۴ ۱۱۲۰ 2048x2048 ۱۱۲۰ ۴۰۹۶x۴۰۹۶ ۲۰۰۰
    ۱:۴ ۲۵۶x۱۰۲۴ ۷۴۷ عدد ۵۱۲x۲۰۴۸ ۱۱۲۰ ۱۰۲۴x۴۰۹۶ ۱۱۲۰ 2048x8192 ۲۰۰۰
    ۱:۸ ۱۹۲x۱۵۳۶ ۷۴۷ عدد ۳۸۴x۳۰۷۲ ۱۱۲۰ ۷۶۸x۶۱۴۴ ۱۱۲۰ ۱۵۳۶x۱۲۲۸۸ ۲۰۰۰
    ۲:۳ ۴۲۴x۶۳۲ ۷۴۷ عدد ۸۴۸x۱۲۶۴ ۱۱۲۰ ۱۶۹۶x۲۵۲۸ ۱۱۲۰ ۳۳۹۲x۵۰۵۶ ۲۰۰۰
    ۳:۲ 632x424 ۷۴۷ عدد ۱۲۶۴x۸۴۸ ۱۱۲۰ ۲۵۲۸x۱۶۹۶ ۱۱۲۰ ۵۰۵۶x۳۳۹۲ ۲۰۰۰
    ۳:۴ ۴۴۸x۶۰۰ ۷۴۷ عدد ۸۹۶x۱۲۰۰ ۱۱۲۰ ۱۷۹۲x۲۴۰۰ ۱۱۲۰ ۳۵۸۴x۴۸۰۰ ۲۰۰۰
    ۴:۱ ۱۰۲۴x۲۵۶ ۷۴۷ عدد 2048x512 ۱۱۲۰ ۴۰۹۶x۱۰۲۴ ۱۱۲۰ ۸۱۹۲x۲۰۴۸ ۲۰۰۰
    ۴:۳ ۶۰۰x۴۴۸ ۷۴۷ عدد ۱۲۰۰x۸۹۶ ۱۱۲۰ ۲۴۰۰x۱۷۹۲ ۱۱۲۰ ۴۸۰۰x۳۵۸۴ ۲۰۰۰
    ۴:۵ ۴۶۴x۵۷۶ ۷۴۷ عدد ۹۲۸x۱۱۵۲ ۱۱۲۰ ۱۸۵۶x۲۳۰۴ ۱۱۲۰ ۳۷۱۲x۴۶۰۸ ۲۰۰۰
    ۵:۴ ۵۷۶x۴۶۴ ۷۴۷ عدد ۱۱۵۲x۹۲۸ ۱۱۲۰ ۲۳۰۴x۱۸۵۶ ۱۱۲۰ ۴۶۰۸x۳۷۱۲ ۲۰۰۰
    ۸:۱ ۱۵۳۶x۱۹۲ ۷۴۷ عدد ۳۰۷۲x۳۸۴ ۱۱۲۰ ۶۱۴۴x۷۶۸ ۱۱۲۰ ۱۲۲۸۸x۱۵۳۶ ۲۰۰۰
    ۹:۱۶ ۳۸۴x۶۸۸ ۷۴۷ عدد ۷۶۸x۱۳۷۶ ۱۱۲۰ ۱۵۳۶x۲۷۵۲ ۱۱۲۰ 3072x5504 ۲۰۰۰
    ۱۶:۹ ۶۸۸x۳۸۴ ۷۴۷ عدد ۱۳۷۶x۷۶۸ ۱۱۲۰ ۲۷۵۲x۱۵۳۶ ۱۱۲۰ ۵۵۰۴x۳۰۷۲ ۲۰۰۰
    ۲۱:۹ ۷۹۲x۱۶۸ ۷۴۷ عدد ۱۵۸۴x۶۷۲ ۱۱۲۰ ۳۱۶۸x۱۳۴۴ ۱۱۲۰ ۶۳۳۶x۲۶۸۸ ۲۰۰۰

    پیش‌نمایش تصویر ۳ حرفه‌ای

    نسبت ابعاد وضوح ۱K ۱ هزار توکن وضوح تصویر 2K ۲ هزار توکن وضوح تصویر 4K ۴۰۰۰ توکن
    ۱:۱ ۱۰۲۴x۱۰۲۴ ۱۱۲۰ 2048x2048 ۱۱۲۰ ۴۰۹۶x۴۰۹۶ ۲۰۰۰
    ۲:۳ ۸۴۸x۱۲۶۴ ۱۱۲۰ ۱۶۹۶x۲۵۲۸ ۱۱۲۰ ۳۳۹۲x۵۰۵۶ ۲۰۰۰
    ۳:۲ ۱۲۶۴x۸۴۸ ۱۱۲۰ ۲۵۲۸x۱۶۹۶ ۱۱۲۰ ۵۰۵۶x۳۳۹۲ ۲۰۰۰
    ۳:۴ ۸۹۶x۱۲۰۰ ۱۱۲۰ ۱۷۹۲x۲۴۰۰ ۱۱۲۰ ۳۵۸۴x۴۸۰۰ ۲۰۰۰
    ۴:۳ ۱۲۰۰x۸۹۶ ۱۱۲۰ ۲۴۰۰x۱۷۹۲ ۱۱۲۰ ۴۸۰۰x۳۵۸۴ ۲۰۰۰
    ۴:۵ ۹۲۸x۱۱۵۲ ۱۱۲۰ ۱۸۵۶x۲۳۰۴ ۱۱۲۰ ۳۷۱۲x۴۶۰۸ ۲۰۰۰
    ۵:۴ ۱۱۵۲x۹۲۸ ۱۱۲۰ ۲۳۰۴x۱۸۵۶ ۱۱۲۰ ۴۶۰۸x۳۷۱۲ ۲۰۰۰
    ۹:۱۶ ۷۶۸x۱۳۷۶ ۱۱۲۰ ۱۵۳۶x۲۷۵۲ ۱۱۲۰ 3072x5504 ۲۰۰۰
    ۱۶:۹ ۱۳۷۶x۷۶۸ ۱۱۲۰ ۲۷۵۲x۱۵۳۶ ۱۱۲۰ ۵۵۰۴x۳۰۷۲ ۲۰۰۰
    ۲۱:۹ ۱۵۸۴x۶۷۲ ۱۱۲۰ ۳۱۶۸x۱۳۴۴ ۱۱۲۰ ۶۳۳۶x۲۶۸۸ ۲۰۰۰

    تصویر فلش Gemini 2.5

    نسبت ابعاد وضوح تصویر توکن‌ها
    ۱:۱ ۱۰۲۴x۱۰۲۴ ۱۲۹۰
    ۲:۳ ۸۳۲x۱۲۴۸ ۱۲۹۰
    ۳:۲ ۱۲۴۸x۸۳۲ ۱۲۹۰
    ۳:۴ ۸۶۴x۱۱۸۴ ۱۲۹۰
    ۴:۳ ۱۱۸۴x۸۶۴ ۱۲۹۰
    ۴:۵ ۸۹۶x۱۱۵۲ ۱۲۹۰
    ۵:۴ ۱۱۵۲x۸۹۶ ۱۲۹۰
    ۹:۱۶ ۷۶۸x۱۳۴۴ ۱۲۹۰
    ۱۶:۹ ۱۳۴۴x۷۶۸ ۱۲۹۰
    ۲۱:۹ ۱۵۳۶x۶۷۲ ۱۲۹۰

    انتخاب مدل

    مدلی را انتخاب کنید که برای مورد استفاده خاص شما مناسب‌ترین باشد.

    • پیش‌نمایش تصویر فلش Gemini 3.1 (پیش‌نمایش Nano Banana 2) باید مدل تولید تصویر مورد علاقه شما باشد، زیرا از نظر عملکرد و هوش، بهترین گزینه برای تعادل هزینه و تأخیر است. برای جزئیات بیشتر، صفحه قیمت‌گذاری و قابلیت‌های مدل را بررسی کنید.

    • پیش‌نمایش تصویر Gemini 3 Pro (پیش‌نمایش Nano Banana Pro) برای تولید حرفه‌ای دارایی‌ها و دستورالعمل‌های پیچیده طراحی شده است. این مدل با استفاده از جستجوی گوگل، یک فرآیند پیش‌فرض "فکر کردن" که ترکیب‌بندی را قبل از تولید اصلاح می‌کند، دارای زمینه‌سازی در دنیای واقعی است و می‌تواند تصاویری با وضوح حداکثر 4K تولید کند. برای جزئیات بیشتر، صفحه قیمت‌گذاری و قابلیت‌های مدل را بررسی کنید.

    • Gemini 2.5 Flash Image (Nano Banana) برای سرعت و کارایی طراحی شده است. این مدل برای کارهای با حجم بالا و تأخیر کم بهینه شده است و تصاویر را با وضوح 1024 پیکسل تولید می‌کند. برای جزئیات بیشتر، صفحه قیمت‌گذاری و قابلیت‌های مدل را بررسی کنید.

    چه زمانی از ایمجین استفاده کنیم

    علاوه بر استفاده از قابلیت‌های تولید تصویر داخلی Gemini، می‌توانید از طریق رابط برنامه‌نویسی نرم‌افزار Gemini به Imagen ، مدل تخصصی تولید تصویر ما، نیز دسترسی داشته باشید.

    Imagen 4 باید مدل انتخابی شما برای شروع تولید تصاویر با Imagen باشد. Imagen 4 Ultra را برای موارد استفاده پیشرفته یا زمانی که به بهترین کیفیت تصویر نیاز دارید انتخاب کنید (توجه داشته باشید که فقط می‌تواند یک تصویر را در یک زمان تولید کند).

    قدم بعدی چیست؟