[Gemini] Gemini API for Python and C#
AI, ML, DL 2025. 11. 28. 21:32 |반응형
Gemini API를 사용해 보자.
Python

from google import genai
client = genai.Client(api_key="your_api_key")
response = client.models.generate_content(
model="gemini-2.5-flash",
contents="Gemini에 대해 짧게 설명해 줘."
)
print(response.text)
API Key는 Google AI Studio에서 발급 받는다.

C#

콘솔창 작업 디렉토리에서 아래 명령을 실행해도 된다.
dotnet add package Google.GenAI
using Google.GenAI;
Client client = new Client(apiKey: "your_api_key");
Google.GenAI.Types.GenerateContentResponse response = await client.Models.GenerateContentAsync(
model: "gemini-2.5-flash",
contents: "Tell me a joke about computers."
);
Console.WriteLine(response.Candidates[0].Content.Parts[0].Text);

※ 참고
반응형
'AI, ML, DL' 카테고리의 다른 글
| [AI] 한국어 형태소 분석기 Kiwipiepy & 워드 클라우드 Word Cloud (0) | 2025.11.13 |
|---|---|
| [MediaPipe] Async Pose Landmark Detection 비동기 자세 특징 감지 (0) | 2025.02.12 |
| [MediaPipe] Face Landmark Detection 얼굴 특징 감지 (1) | 2025.02.11 |
| [MediaPipe] Pose Landmark Detection 자세 특징 감지 (0) | 2025.02.11 |
| [MediaPipe] Face Detection 얼굴 감지 (0) | 2025.02.11 |
