본문 바로가기
C.W.K.
Stream
Lesson 01 of 05 · published

세 집안, 한 idea

~22 min · openai, anthropic, gemini, compatibility

Level 0호기심 많은 독자
0 XP0/48 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

OpenAI 가 2023 년 중반에 tool calling 을 내놨고, 몇 달 뒤 Anthropic 이 자기 버전을 붙였고, Google 도 곧 Gemini 에 function declaration 을 얹었어. 1 년도 안 돼서 같은 생각 하나가 — 모델이 문장 속에 JSON 을 적어넣는 대신, 구조화된 tool-call object 를 돌려준다는 생각 — production 에 올릴 수 있는 구현 셋으로 갈라져 나온 거야.

좋은 소식은 생각 자체가 셋 다 똑같다는 거야. Tool 을 정의하고, tool 과 함께 모델을 부르고, tool-call object 를 받고, 실행해서 결과를 넣어줘. 한 provider 로 loop 를 짤 줄 알면 나머지 둘은 봉투만 바꿔 끼우는 몇 시간짜리 일이야.

나쁜 소식은 그 봉투 에 있어. OpenAI 는 tools 안에 type: "function"parameters 를 놓고, Anthropic 은 tools 안에 input_schema 를 놓고, Gemini 는 Tool 안에 FunctionDeclaration 을 담아. 흐름은 같고 이름만 달라.

이 track 은 그 봉투 셋을 차례로 열어보는 여정이야. 목표는 외우는 게 아니야 — SDK 마다 문서가 있고 어차피 찾아보게 되니까. 목표는 옷만 갈아입은 같은 생각 과, 옮겨 심을 수 없는 진짜 provider 고유 기능을 구별하는 눈이야. 그 눈이 생기면 엉뚱한 자리에 잘못된 추상을 복사해 붙이는 일이 없어져.

Code

나란히 놓고 보기 — tool 하나를 정의하는 세 가지 방법·python
# OpenAI (Responses API)
openai_tools = [{
    "type": "function",
    "name": "get_weather",
    "description": "Get current weather for a city.",
    "parameters": {
        "type": "object",
        "properties": {"location": {"type": "string"}},
        "required": ["location"],
    },
}]

# Anthropic
anthropic_tools = [{
    "name": "get_weather",
    "description": "Get current weather for a city.",
    "input_schema": {
        "type": "object",
        "properties": {"location": {"type": "string"}},
        "required": ["location"],
    },
}]

# Gemini (google-genai)
from google.genai import types
gemini_tools = [types.Tool(function_declarations=[types.FunctionDeclaration(
    name="get_weather",
    description="Get current weather for a city.",
    parameters=types.Schema(
        type=types.Type.OBJECT,
        properties={"location": types.Schema(type=types.Type.STRING)},
        required=["location"],
    ),
)])]

External links

Exercise

Tool 하나를 골라서 세 provider 의 정의를 한 파일에 나란히 적어. 각각을 provider SDK 의 검사기에 (또는 아무것도 안 하는 호출로) 통과시켜봐. 어떤 필드가 그대로고 어떤 게 번역이 필요한지 몸으로 알게 돼. 그 파일을 provider 로제타석으로 삼아 붙여둬.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.