Gemini Developer API
Gemini API पासकोड पाएं और कुछ ही मिनटों में अपना पहला एपीआई अनुरोध करें.
अगर आपने अपना एपीआई पासकोड, एनवायरमेंट वैरिएबल GEMINI_API_KEY
के तौर पर सेट किया है, तो Gemini API लाइब्रेरी का इस्तेमाल करते समय, क्लाइंट इसे अपने-आप चुन लेगा.
ऐसा न करने पर, आपको क्लाइंट को शुरू करते समय, अपनी एपीआई पासकोड को आर्ग्युमेंट के तौर पर पास करना होगा.
Python
from google import genai
# The client gets the API key from the environment variable `GEMINI_API_KEY`.
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";
// The client gets the API key from the environment variable `GEMINI_API_KEY`.
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()
// The client gets the API key from the environment variable `GEMINI_API_KEY`.
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) {
// The client gets the API key from the environment variable `GEMINI_API_KEY`.
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());
}
}
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"
}
]
}
]
}'
मॉडल के बारे में जानकारी
2.5 Pro
हमारा सबसे बेहतर थिंकिंग मॉडल, जिसमें मुश्किल से मुश्किल समस्याओं को हल करने के साथ-साथ कई अन्य सुविधाएं भी हैं
एपीआई के बारे में जानकारी
नेटिव इमेज जनरेशन
Gemini 2.0 Flash की मदद से, कॉन्टेक्स्ट के हिसाब से इमेज जनरेट करें और उनमें बदलाव करें.
ज़्यादा कॉन्टेक्स्ट वाली विंडो एक्सप्लोर करना
Gemini मॉडल में लाखों टोकन डालें और बिना स्ट्रक्चर वाली इमेज, वीडियो, और दस्तावेज़ों से जानकारी पाएं.
स्ट्रक्चर्ड आउटपुट जनरेट करना
Gemini को JSON फ़ॉर्मैट में जवाब देने के लिए कहें. यह स्ट्रक्चर्ड डेटा का एक ऐसा फ़ॉर्मैट है जो अपने-आप प्रोसेस होने के लिए सही है.