문서/API 활용/Anthropic API 가이드

Anthropic API 가이드

Claude API 활용 완벽 가이드

Anthropic API

설치

pip install anthropic

기본 사용법

from anthropic import Anthropic
client = Anthropic()

message = client.messages.create(
    model="claude-3-5-sonnet-20241022",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Hello, Claude!"}
    ]
)
print(message.content[0].text)

Tool Use

tools = [{
    "name": "get_weather",
    "description": "Get weather info",
    "input_schema": {...}
}]
response = client.messages.create(
    model="claude-3-5-sonnet-20241022",
    tools=tools,
    messages=[...]
)
Anthropic API 가이드 - 문서 - SpacebarCorp AI Academy | SpacebarCorp