AI2025년 5월 8일2분 읽기

Claude 4 API 활용 가이드 — 도구 사용과 에이전트

YS
YoungSam
조회 640

도구 사용 (Tool Use)

import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();

const response = await client.messages.create({
  model: "claude-sonnet-4-20250514",
  tools: [{
    name: "get_weather",
    description: "현재 날씨를 조회합니다",
    input_schema: {
      type: "object",
      properties: {
        city: { type: "string", description: "도시 이름" }
      },
      required: ["city"]
    }
  }],
  messages: [{ role: "user", content: "서울 날씨 알려줘" }]
});

에이전트 루프

도구 호출 결과를 다시 전달하여 자율적 작업 수행이 가능합니다.

ClaudeAnthropicAPI

댓글 0

아직 댓글이 없습니다.