SPB Git

Repository Public

generate-content.md 6.5 KB 155 lines markdown

1The Gemini API is the fastest path from prompt to production with Gemini, Veo,2Nano Banana, and more. It lets you integrate these generative models into your3applications to generate text and images, analyze multimodal inputs, and build4conversational agents.56### Python78    from google import genai910    client = genai.Client()1112    response = client.models.generate_content(13        model="gemini-3.8-flash",14        contents="Explain how AI works in a few words",15    )1617    print(response.text)1819### JavaScript2021    import { GoogleGenAI } from "@google/genai";2223    const ai = new GoogleGenAI({});2425    async function main() {26      const response = await ai.models.generateContent({27        model: "gemini-3.8-flash",28        contents: "Explain how AI works in a few words",29      });30      console.log(response.text);31    }3233    await main();3435### Go3637    package main3839    import (40        "context"41        "fmt"42        "log"43        "google.golang.org/genai"44    )4546    func main() {47        ctx := context.Background()48        client, err := genai.NewClient(ctx, nil)49        if err != nil {50            log.Fatal(err)51        }5253        result, err := client.Models.GenerateContent(54            ctx,55            "gemini-3.8-flash",56            genai.Text("Explain how AI works in a few words"),57            nil,58        )59        if err != nil {60            log.Fatal(err)61        }62        fmt.Println(result.Text())63    }6465### Java6667    package com.example;6869    import com.google.genai.Client;70    import com.google.genai.types.GenerateContentResponse;7172    public class GenerateTextFromTextInput {73      public static void main(String[] args) {74        Client client = new Client();7576        GenerateContentResponse response =77            client.models.generateContent(78                "gemini-3.8-flash",79                "Explain how AI works in a few words",80                null);8182        System.out.println(response.text());83      }84    }8586### C#8788    using System.Threading.Tasks;89    using Google.GenAI;90    using Google.GenAI.Types;9192    public class GenerateContentSimpleText {93      public static async Task main() {94        var client = new Client();95        var response = await client.Models.GenerateContentAsync(96          model: "gemini-3.8-flash", contents: "Explain how AI works in a few words"97        );98        Console.WriteLine(response.Candidates[0].Content.Parts[0].Text);99      }100    }101102### REST103104    curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent" \105      -H "x-goog-api-key: $GEMINI_API_KEY" \106      -H 'Content-Type: application/json' \107      -X POST \108      -d '{109        "contents": [110          {111            "parts": [112              {113                "text": "Explain how AI works in a few words"114              }115            ]116          }117        ]118      }'119120[Start building](https://ai.google.dev/gemini-api/docs/generate-content/get-started)121122*** ** * ** ***123124## Meet the models125126[View all](https://ai.google.dev/gemini-api/docs/models) [Gemini 3.1 Pro127New128Our most intelligent model, the best in the world for multimodal understanding, all built on state-of-the-art reasoning.](https://ai.google.dev/gemini-api/docs/models/gemini-3.1-pro-preview) [Gemini 3.6 Flash129New130Our latest model that balances speed with intelligence to deliver strong performance in agentic and multimodal tasks.](https://ai.google.dev/gemini-api/docs/models/gemini-3.6-flash) [Gemini 3.5 Flash131Frontier-class performance rivaling larger models at a fraction of the cost.](https://ai.google.dev/gemini-api/docs/models/gemini-3.5-flash) [Gemini 3.5 Flash-Lite132New133High-volume, cost-sensitive model optimized for low-latency high throughput subagent tasks.](https://ai.google.dev/gemini-api/docs/models/gemini-3.5-flash-lite) [Gemini 3.1 Flash-Lite134High-volume, cost-sensitive model with the performance and quality of the Gemini 3 series.](https://ai.google.dev/gemini-api/docs/models/gemini-3.1-flash-lite) [Gemini 3 Flash135Frontier-class performance rivaling larger models at a fraction of the cost.](https://ai.google.dev/gemini-api/docs/models/gemini-3-flash-preview) [Nano Banana 2 and Nano Banana Pro136State-of-the-art image generation and editing models.](https://ai.google.dev/gemini-api/docs/image-generation) [Veo 3.1137Our state-of-the-art video generation model, with native audio.](https://ai.google.dev/gemini-api/docs/video) [Gemini Robotics138A vision-language model (VLM) that brings Gemini's agentic capabilities to robotics and enables advanced reasoning in the physical world.](https://ai.google.dev/gemini-api/docs/robotics-overview)139140## Explore Capabilities141142[Native Image Generation (Nano Banana)143Generate and edit highly contextual images natively with Gemini 2.5 Flash Image.](https://ai.google.dev/gemini-api/docs/image-generation) [Long Context144Input millions of tokens to Gemini models and derive understanding from unstructured images, videos, and documents.](https://ai.google.dev/gemini-api/docs/long-context) [Structured Outputs145Constrain Gemini to respond with JSON, a structured data format suitable for automated processing.](https://ai.google.dev/gemini-api/docs/structured-output) [Function Calling146Build agentic workflows by connecting Gemini to external APIs and tools.](https://ai.google.dev/gemini-api/docs/function-calling) [Video Generation with Veo 3.1147Create high-quality video content from text or image prompts with our state-of-the-art model.](https://ai.google.dev/gemini-api/docs/video) [Voice Agents with Live API148Build real-time voice applications and agents with the Live API.](https://ai.google.dev/gemini-api/docs/live-api) [Tools149Connect Gemini to the world through built-in tools like Google Search, URL Context, Google Maps, Code Execution and Computer Use.](https://ai.google.dev/gemini-api/docs/tools) [Document Understanding150Process up to 1000 pages of PDF files with full multimodal understanding or other text-based file types.](https://ai.google.dev/gemini-api/docs/document-processing) [Thinking151Explore how thinking capabilities improve reasoning for complex tasks and agents.](https://ai.google.dev/gemini-api/docs/thinking) [Google AI Studio152Test prompts, manage your API keys, monitor usage, and build prototypes.](https://aistudio.google.com) [Developer Community153Ask questions and find solutions from other developers and Google engineers.](https://discuss.ai.google.dev/c/gemini-api/4) [API Reference154Find detailed information about the Gemini API in the official reference documentation.](https://ai.google.dev/api) [Status155Check the status of Gemini API, Google AI Studio, and our model services.](https://aistudio.google.com/status)
Files main
Menu

Theme