Vertex AI Agent Engine

Vertex AI Agent Engine

Vertex AI Agent Engine(Reasoning Engines)을 OpenAI Request/Response 포맷으로 호출하는 방법을 알아봐요.

출처: 문서

본문

Vertex AI Agent Engine은 파운데이션 모델, 도구, 사용자 정의 로직으로 에이전트 워크플로를 실행할 수 있는 호스팅 에이전트 런타임을 제공해요.

속성 내용
설명 파운데이션 모델·도구·사용자 정의 로직으로 에이전트 워크플로를 실행하는 호스팅 에이전트 런타임
LiteLLM 라우트 vertex_ai/agent_engine/{RESOURCE_NAME}
지원 엔드포인트 /chat/completions, /v1/messages, /v1/responses, /v1/a2a/message/send
공식 문서 Vertex AI Agent Engine ↗

빠른 시작

모델 포맷

vertex_ai/agent_engine/{RESOURCE_NAME}

예시:

  • vertex_ai/agent_engine/projects/1060139831167/locations/us-central1/reasoningEngines/8263861224643493888

LiteLLM Python SDK

기본 에이전트 완성:

import litellm

response = litellm.completion(
    model="vertex_ai/agent_engine/projects/1060139831167/locations/us-central1/reasoningEngines/8263861224643493888",
    messages=[
        {"role": "user", "content": "Explain machine learning in simple terms"}
    ],
)

print(response.choices[0].message.content)

에이전트 응답 스트리밍:

import litellm

response = await litellm.acompletion(
    model="vertex_ai/agent_engine/projects/1060139831167/locations/us-central1/reasoningEngines/8263861224643493888",
    messages=[
        {"role": "user", "content": "What are the key principles of software architecture?"}
    ],
    stream=True,
)

async for chunk in response:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

LiteLLM Proxy

1. config.yaml에서 모델 구성

model_list:
  - model_name: vertex-agent-1
    litellm_params:
      model: vertex_ai/agent_engine/projects/1060139831167/locations/us-central1/reasoningEngines/8263861224643493888
      vertex_project: your-project-id
      vertex_location: us-central1

2. LiteLLM Proxy 시작

litellm --config config.yaml

3. Vertex AI Agent Engine에 요청 보내기

curl http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ***" \
  -d '{
    "model": "vertex-agent-1",
    "messages": [
      {"role": "user", "content": "Summarize the main benefits of cloud computing"}
    ]
  }'

OpenAI SDK 사용:

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:4000",
    api_key="your-litellm-api-key"
)

response = client.chat.completions.create(
    model="vertex-agent-1",
    messages=[
      {"role": "user", "content": "What are best practices for API design?"}
    ]
)

print(response.choices[0].message.content)

LiteLLM A2A 게이트웨이

LiteLLM의 A2A(Agent-to-Agent) 게이트웨이 UI를 통해서도 Vertex AI Agent Engine에 연결할 수 있어요. 이 방식은 코드를 작성하지 않고 에이전트를 등록하고 테스트할 수 있는 시각적 방법을 제공해요.

1. Agents 메뉴로 이동

사이드바에서 "Agents"를 클릭해 에이전트 관리 페이지를 열고, "+ Add New Agent"를 클릭해요.

2. Vertex AI Agent Engine 타입 선택

"A2A Standard"를 클릭해 사용 가능한 에이전트 타입을 확인한 뒤 "Vertex AI Agent Engine"을 선택해요.

3. 에이전트 구성

다음 필드를 채워요:

  • Agent Name - 에이전트의 친숙한 이름 (예: my-vertex-agent)
  • Reasoning Engine Resource ID - Google Cloud Console의 전체 리소스 경로 (예: projects/1060139831167/locations/us-central1/reasoningEngines/8263861224643493888)
  • Vertex Project - Google Cloud 프로젝트 ID
  • Vertex Location - 에이전트가 배포된 리전 (예: us-central1)

Resource ID는 Google Cloud Console의 Vertex AI > Agent Engine에서 찾을 수 있어요. Project ID는 Google Cloud Console에서 찾을 수 있어요.

4. 에이전트 생성

"Create Agent"를 클릭해 구성을 저장해요.

5. Playground에서 테스트

사이드바의 "Playground"로 가서 에이전트를 테스트해요.

6. A2A 엔드포인트 선택

엔드포인트 드롭다운을 클릭하고 /v1/a2a/message/send를 선택해요.

7. 에이전트 선택 후 메시지 전송

드롭다운에서 Vertex AI Agent Engine을 고르고 테스트 메시지를 보내 보세요.

환경 변수

변수 설명
GOOGLE_APPLICATION_CREDENTIALS 서비스 계정 JSON 키 파일 경로
VERTEXAI_PROJECT Google Cloud 프로젝트 ID
VERTEXAI_LOCATION Google Cloud 리전 (기본값: us-central1)
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"
export VERTEXAI_PROJECT="your-project-id"
export VERTEXAI_LOCATION="us-central1"

더 알아보기 (Learn more)

  • Vertex AI Agent Engine 문서
  • Reasoning Engine 만들기
  • A2A 에이전트 게이트웨이
  • Vertex AI 프로바이더