Gemini 2.5 Pro Experimental 및 Gemini 2.0 Flash Thinking Experimental은 대답을 생성하는 동안 내부 '사고 과정'을 사용하는 모델입니다. 이 과정을 통해 추론 능력이 향상되고 복잡한 작업을 해결할 수 있습니다. 이 가이드에서는 사고 기능이 있는 Gemini 모델을 사용하는 방법을 보여줍니다.
사고 모델 사용
사고 기능이 있는 모델은 Google AI Studio 및 Gemini API를 통해 사용할 수 있습니다. 사고 과정은 Google AI Studio 내에서 볼 수 있지만 API 출력의 일부로 제공되지는 않습니다.
기본 요청 보내기
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)
자바스크립트
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();
Go
// 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)
자바스크립트
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 실험 버전을 사용해 보세요.
- 사고 모델 프롬프트에 대해 자세히 알아보세요.
- Gemini 2.5 Pro 실험 버전 및 Gemini Flash 2.0 Thinking에 관한 자세한 내용은 모델 페이지를 참고하세요.
- 사고방식 설명서에서 더 많은 예시를 사용해 보세요.