← 전체 가이드
Claude API

Anthropic API 첫 요청 보내기

Anthropic API 키를 받고, 첫 Messages 요청을 Python과 TypeScript 양쪽으로 보내는 최소 예제.

읽는 데 6분 · STEP 4개 · 2026. 11. 14.

1단계: API 키 발급

console.anthropic.com에 로그인하고 API Keys 메뉴에서 발급.

2단계: 환경 변수에 저장

export ANTHROPIC_API_KEY="sk-ant-..."

3단계: Python으로 첫 요청

from anthropic import Anthropic

client = Anthropic()
message = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "안녕"}],
)
print(message.content[0].text)

4단계: TypeScript로 첫 요청

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();
const msg = await client.messages.create({
  model: "claude-sonnet-5-5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "안녕" }],
});
console.log(msg.content[0]);