Gemini 2.5 Pro Experimental और Gemini 2.0 Flash Thinking Experimental, ऐसे मॉडल हैं जो जवाब जनरेट करने के दौरान, किसी "थिंकिंग प्रोसेस" का इस्तेमाल करते हैं. इस प्रोसेस से, एआई की तर्क करने की क्षमता बेहतर होती है. साथ ही, इससे एआई मुश्किल टास्क को हल कर पाता है. इस गाइड में, Gemini मॉडल का इस्तेमाल करने का तरीका बताया गया है.
थिंकिंग मॉडल का इस्तेमाल करना
सोचने की क्षमता वाले मॉडल, Google AI Studio और Gemini API के ज़रिए उपलब्ध हैं. ध्यान दें कि सोचने की प्रोसेस, Google AI Studio में दिखती है, लेकिन एपीआई आउटपुट के हिस्से के तौर पर नहीं दी जाती.
बुनियादी अनुरोध भेजना
Python
from google import genai
client = genai.Client(api_key="GEMINI_API_KEY")
prompt = "Explain the concept of Occam's Razor and provide a simple, everyday example."
response = client.models.generate_content(
model="gemini-2.5-pro-exp-03-25", # or gemini-2.0-flash-thinking-exp
contents=prompt
)
print(response.text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: "GEMINI_API_KEY" });
async function main() {
const prompt = "Explain the concept of Occam's Razor and provide a simple, everyday example.";
const response = await ai.models.generateContent({
model: "gemini-2.5-pro-exp-03-25", // or gemini-2.0-flash-thinking-exp
contents: prompt,
});
console.log(response.text);
}
main();
शुरू करें
// import packages here
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("GEMINI_API_KEY")))
if err != nil {
log.Fatal(err)
}
defer client.Close()
model := client.GenerativeModel("gemini-2.5-pro-exp-03-25") // or gemini-2.0-flash-thinking-exp
resp, err := model.GenerateContent(ctx, genai.Text("Explain the concept of Occam's Razor and provide a simple, everyday example."))
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Text())
}
REST
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro-exp-03-25:generateContent?key=$YOUR_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [
{
"parts": [
{
"text": "Explain the concept of Occam\''s Razor and provide a simple, everyday example."
}
]
}
]
}'
```
एक से ज़्यादा बार की गई बातचीत
चैट के पिछले इतिहास को ध्यान में रखने के लिए, एक से ज़्यादा बार की गई बातचीत का इस्तेमाल किया जा सकता है.
SDK की मदद से, बातचीत की स्थिति को मैनेज करने के लिए चैट सेशन बनाया जा सकता है.
Python
from google import genai
client = genai.Client(api_key='GEMINI_API_KEY')
chat = client.aio.chats.create(
model='gemini-2.5-pro-exp-03-25', # or gemini-2.0-flash-thinking-exp
)
response = await chat.send_message('What is your name?')
print(response.text)
response = await chat.send_message('What did you just say before this?')
print(response.text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: "GEMINI_API_KEY" });
async function main() {
const chat = ai.chats.create({
model: 'gemini-2.5-pro-exp-03-25' // or gemini-2.0-flash-thinking-exp
});
const response = await chat.sendMessage({
message: 'What is your name?'
});
console.log(response.text);
response = await chat.sendMessage({
message: 'What did you just say before this?'
});
console.log(response.text);
}
main();
आगे क्या करना है?
- Google AI Studio में, Gemini 2.5 Pro Experimental को आज़माएं.
- थिंकिंग मॉडल के लिए प्रॉम्प्ट करने के बारे में ज़्यादा जानें.
- Gemini 2.5 Pro Experimental और Gemini Flash 2.0 Thinking के बारे में ज़्यादा जानकारी के लिए, मॉडल पेज देखें.
- Thinking cookbook में और उदाहरण देखें.