5분 안에, 처음부터 AI 에이전트를 만드는 방법을 보여드릴게요

발행: (2025년 12월 7일 오후 11:46 GMT+9)
6 min read
원문: Dev.to

Source: Dev.to

AI 에이전트란? (간단 설명)

일반적인 AI 모델(예: ChatGPT 또는 Gemini)은 텍스트 답변만 제공합니다.

AI 에이전트는 다음을 할 수 있습니다:

  • 작업 수행 – 질문에 답하는 것에 그치지 않음
  • 도구 사용 – Google 검색, 계산기, API, 데이터베이스 등
  • 결정 및 계획 – 단계별로 작업을 설계함
  • 최소한의 인간 개입으로 자율 작동

AI 에이전트를 여러분을 위해 작업을 수행하는 작은 “AI 직원”이라고 생각하면 됩니다.

시작하기 전에 준비할 것

  • Python이 컴퓨터에 설치되어 있어야 함
  • 코드 편집기(예: VS Code 또는 Google Antigravity IDE)
  • Google ADK – 설치할 오픈소스 프레임워크 (자세한 내용은 Google ADK 개요 참고)
  • Gemini API 키(무료 발급)

AI 에이전트를 처음부터 만들기

1단계: 프로젝트 폴더와 가상 환경 만들기

mkdir my_first_agent
cd my_first_agent

가상 환경 생성:

python -m venv .venv

활성화:

# macOS / Linux
source .venv/bin/activate  

# Windows
.\venv\Scripts\activate

가상 환경은 프로젝트를 깔끔하게 유지하고 버전 충돌을 방지합니다.

2단계: Google ADK 설치

pip install google-adk

3단계: 에이전트 프로젝트 만들기

adk create my_agent

모델을 선택합니다(예: Gemini 2.5 또는 Gemini Flash).

생성 후 다음과 같은 폴더 구조가 나타납니다:

my_agent/
 ├── agent.py
 ├── .env
 └── __init__.py
  • agent.py – 코드가 들어가는 메인 파일
  • .env – API 키를 저장하는 파일

IDE에서 폴더를 엽니다.

Create Your Agent Project

4단계: 무료 Gemini API 키 받기

  1. 로 이동하여 Google 계정으로 로그인합니다.
  2. 좌측 하단 사이드바에서 Get API key를 클릭합니다.
  3. Create API Key를 클릭하고 이름을 지정한 뒤 프로젝트를 선택(또는 새로 생성)하고 키를 복사합니다.

Get Your Free Gemini API Key

.env에 키 추가:

GOOGLE_API_KEY="your-key-here"

5단계: 기본 에이전트 테스트하기

agent.py를 열면 기본 코드가 보입니다.
플레이스홀더 모델 이름을 Gemini 모델의 내부 이름(예: gemini-2.0-flash 또는 gemini-3-pro-preview)으로 교체합니다.

에이전트를 실행:

adk run my_agent

간단한 질문을 입력합니다. 정상적으로 동작하면 답변이 반환됩니다. 모델의 무료 한도에 도달하면 가벼운 무료 티어 모델로 전환합니다.

6단계: 여러 에이전트 만들기 (연구 + 요약 + 조정)

다음 코드를 agent.py(또는 새 모듈)에 추가하여 다중 에이전트 파이프라인을 구축합니다:

from google.adk.agents.llm_agent import Agent
from google.adk.tools import google_search, AgentTool

# Research Agent – searches the web
research_agent = Agent(
    name="Researcher",
    model="gemini-2.5-flash-lite",
    instruction="""
You are a specialized research agent. Your only job is to use the
google_search tool to find the top 5 AI news items for a given topic.
Do not answer any user questions directly.
""",
    tools=[google_search],
    output_key="research_result",
)

print("Research Agent created successfully.")

# Summarizer Agent – creates summaries
summarizert = Agent(
    name="Summarizert",
    model="gemini-2.5-flash-lite",
    instruction="""
Read the research findings {research_result} and create a summary for each topic,
including a link to read more.
""",
    output_key="summary_result",
)

print("Summarizert Agent created successfully.")

# Root Coordinator – orchestrates the workflow
root_agent = Agent(
    model="gemini-2.5-flash-lite",
    name="root_agent",
    description="A helpful assistant for user questions.",
    instruction="""
You are the coordinator. First, delegate user questions to the 'research_agent' to gather information.
Second, pass the findings to the 'summarizert' agent to create a summary.
Finally, compile the summaries into a final response for the user.
""",
    tools=[
        AgentTool(research_agent),
        AgentTool(summarizert),
    ],
)

이 코드는 연구 → 요약 → 조정의 3단계 파이프라인을 정의합니다.

7단계: 다중 에이전트 시스템 실행하기

adk run my_agent

프롬프트가 나타나면 조사하고 싶은 주제를 입력합니다. 다음과 같은 흐름을 확인할 수 있습니다:

  • Research Agent가 정보를 수집
  • Summarizer Agent가 요약 생성
  • Coordinator가 최종 응답을 조합

모든 에이전트가 협력하여 결과를 제공합니다.

8단계: 웹 인터페이스 사용하기 (훨씬 쉬움)

Google ADK에는 내장된 웹 UI가 포함되어 있어 브라우저를 통해 에이전트와 상호작용할 수 있습니다. 같은 adk run 명령을 실행하면 로컬 URL이 제공되니 이를 열어 테스트와 반복 작업을 더욱 간편하게 진행하세요.

Back to Blog

관련 글

더 보기 »