'전체 글'에 해당되는 글 586건

  1. 2025.11.28 [Gemini] Gemini API for Python and C#
반응형

Gemini API를 사용해 보자.

 

Python

google-genai 라이브러리를 설치한다.

 

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#

Google.GenAI를 설치한다.

콘솔창 작업 디렉토리에서 아래 명령을 실행해도 된다.

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);

 

 

※ 참고

Gemini API

Gemini API SDK Python

Gemini API SDK C#

FastMCP Gemini SDK

 

반응형
Posted by J-sean
: