Gemini API पासकोड पाएं और कुछ ही मिनटों में अपना पहला एपीआई अनुरोध करें.

Python

from google import genai

client = genai.Client()

response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="Explain how AI works in a few words",
)

print(response.text)

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {
  const response = await ai.models.generateContent({
    model: "gemini-2.5-flash",
    contents: "Explain how AI works in a few words",
  });
  console.log(response.text);
}

await main();

ऐप पर जाएं

package main

import (
    "context"
    "fmt"
    "log"
    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    result, err := client.Models.GenerateContent(
        ctx,
        "gemini-2.5-flash",
        genai.Text("Explain how AI works in a few words"),
        nil,
    )
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(result.Text())
}

Java

package com.example;

import com.google.genai.Client;
import com.google.genai.types.GenerateContentResponse;

public class GenerateTextFromTextInput {
  public static void main(String[] args) {
    Client client = new Client();

    GenerateContentResponse response =
        client.models.generateContent(
            "gemini-2.5-flash",
            "Explain how AI works in a few words",
            null);

    System.out.println(response.text());
  }
}

C#

using System.Threading.Tasks;
using Google.GenAI;
using Google.GenAI.Types;

public class GenerateContentSimpleText {
  public static async Task main() {
    var client = new Client();
    var response = await client.Models.GenerateContentAsync(
      model: "gemini-2.0-flash", contents: "Explain how AI works in a few words"
    );
    Console.WriteLine(response.Candidates[0].Content.Parts[0].Text);
  }
}

REST

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [
      {
        "parts": [
          {
            "text": "Explain how AI works in a few words"
          }
        ]
      }
    ]
  }'

मॉडल के बारे में जानकारी

Gemini की मदद से बनाना शुरू करें

एपीआई के बारे में जानें

इमेज जनरेट करने की सुविधा (इसे Nano Banana भी कहा जाता है)

Gemini 2.5 Flash Image की मदद से, इमेज जनरेट करें और उनमें बदलाव करें.

लंबा कॉन्टेक्स्ट एक्सप्लोर करना

Gemini मॉडल में लाखों टोकन इनपुट करें. साथ ही, बिना किसी स्ट्रक्चर वाली इमेज, वीडियो, और दस्तावेज़ों को समझें.

स्ट्रक्चर्ड आउटपुट जनरेट करना

Gemini को सिर्फ़ JSON फ़ॉर्मैट में जवाब देने के लिए कहें. यह स्ट्रक्चर्ड डेटा फ़ॉर्मैट, अपने-आप प्रोसेस होने के लिए सही होता है.

Gemini API का इस्तेमाल करके, ऐप्लिकेशन बनाना शुरू करना

शुरू करें