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 년 안에 — '모델이 prose 안에 JSON 적으려 하는 대신 구조화된 tool-call object 반환' 이라는 같은 idea 가 — 프로덕션 ready 한 구현 셋이 생겼어.

좋은 소식은 concept 이 셋 다 동일하다는 거. Tool 정의 → tool 함께 모델 호출 → tool-call object 받기 → 실행하고 결과 넣기. 한 provider 로 loop 짤 줄 알면 다른 둘은 envelope 변환 몇 시간이면 돼.

나쁜 소식은 envelope 에 있어. OpenAI 는 toolstype: "function"parameters; Anthropic 은 toolsinput_schema; Gemini 는 Tool 안의 FunctionDeclaration. Flow 같고, 이름 다름.

이 track 은 그 세 envelope 의 투어야. 목표는 암기 아니야 — 모든 SDK 에 docs 있고 너는 lookup 할 거니까 — 다른 옷 입은 같은 idea 와 port 못 하는 진짜 provider-specific feature 의 차이를 인식하는 거야. 그 차이를 알면 잘못된 abstraction 으로 copy-paste 안 하게 돼.

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 validator 에 (또는 no-op call 로) 통과시켜. 어떤 필드가 같고 어떤 게 번역 필요한지 알게 돼. 이 파일을 provider rosetta stone 으로 pin.

Progress

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

댓글 0

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

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