Realtime with tools — 함수 도구와 MCP 구성

Realtime with tools — 함수 도구와 MCP 구성

음성 에이전트가 실제 일을 하려면 도구가 필요해요. Realtime 세션에 함수 도구(function calling), MCP(Model Context Protocol) 도구, 커넥터를 구성하는 방법을 볼게요.

출처: https://developers.openai.com/api/docs/guides/realtime-mcp

세션 이벤트의 tools 필드에 도구 정의를 넣어 구성해요. 예:

{
  "type": "session.update",
  "session": {
    "tools": [
      {
        "type": "function",
        "name": "get_weather",
        "description": "Get current weather for a city",
        "parameters": {
          "type": "object",
          "properties": {
            "city": { "type": "string" }
          }
        }
      }
    ]
  }
}

모델이 도구 호출을 결정하면 function_call 이벤트가 오고, 결과를 function_call_output 이벤트로 돌려주면 대화가 이어져요. MCP 도구와 커넥터도 같은 session.update에서 등록할 수 있어 음성 에이전트가 외부 서비스를 직접 호출하게 만들 수 있어요.

더 알아보기