Google जेन एआई एसडीके

Google का नया जनरेटिव एआई एसडीके, Gemini 2.0 के लिए एक यूनिफ़ाइड इंटरफ़ेस उपलब्ध कराता है. यह इंटरफ़ेस, Gemini Developer API और Vertex AI (Gemini Enterprise API) दोनों के ज़रिए मिलता है. कुछ अपवादों को छोड़कर, एक प्लैटफ़ॉर्म पर चलने वाला कोड, दोनों प्लैटफ़ॉर्म पर चलेगा. Gen AI SDK, Gemini 1.5 मॉडल के साथ भी काम करता है.

Python

Python के लिए Google Gen AI SDK, PyPI और GitHub पर उपलब्ध है.

ज़्यादा जानने के लिए, Python SDK टूल का रेफ़रंस देखें.

क्विकस्टार्ट

1. SDK टूल इंस्टॉल करना

pip install google-genai

2. लाइब्रेरी इंपोर्ट करना

from google import genai

3. क्लाइंट बनाना

client = genai.Client(api_key='GEMINI_API_KEY')

4. कॉन्टेंट जनरेट करना

response = client.models.generate_content(
    model='gemini-2.0-flash', contents='How does RLHF work?'
)
print(response.text)

शुरू करें

Go के लिए Google Gen AI SDK, go.dev और GitHub पर उपलब्ध है.

क्विकस्टार्ट

1. लाइब्रेरी इंपोर्ट करना

import "google.golang.org/genai"

2. क्लाइंट बनाना

client, err := genai.NewClient(ctx, &genai.ClientConfig{
    APIKey:   apiKey,
    Backend:  genai.BackendGeminiAPI,
})

3. कॉन्टेंट जनरेट करना

// Call the GenerateContent method
  result, err := client.Models.GenerateContent(ctx, "gemini-2.0-flash", genai.Text("How does RLHF work?"), nil)

Java

Java के लिए Google Gen AI SDK टूल, Maven और GitHub के ज़रिए उपलब्ध है.

क्विकस्टार्ट

1. लाइब्रेरी इंपोर्ट करना

अगर Maven का इस्तेमाल किया जा रहा है, तो अपनी डिपेंडेंसी में ये जोड़ें:

<dependencies>
  <dependency>
    <groupId>com.google.genai</groupId>
    <artifactId>google-genai</artifactId>
    <version>0.1.0</version>
  </dependency>
</dependencies>

2. क्लाइंट बनाना

import com.google.genai.Client;

// The client gets the API key from the environment variable `GOOGLE_API_KEY`
Client client = new Client();

// Use the builder class for instantiation.
Client client = Client.builder().apiKey("your-api-key").build();

3. कॉन्टेंट जनरेट करना

package <your.pack.name>;

import com.google.genai.Client;
import com.google.genai.types.GenerateContentResponse;
import java.io.IOException;
import org.apache.http.HttpException;

public class GenerateContentWithTextInput {
  public static void main(String[] args) throws IOException, HttpException {
    Client client = new Client();

    GenerateContentResponse response =
        client.models.generateContent("gemini-2.0-flash-001", "How does RLHF work?", null);
    System.out.println("Unary response: " + response.text());
  }
}