Skip to content

Getting Started with the API: Auth, First Request, SDK Setup

Grab your API key from Anthropic console, install the SDK, run your first call. Python and TypeScript step by step.

Şükrü Yusuf KAYA
11 min read
Intermediate
API başlangıç adımları: hesap → key → SDK → ilk çağrı
Bu derste
Console'da hesap aç, API key oluştur, SDK kur, ilk başarılı çağrını yap. 10 dakika.

Başlamadan Önce

  1. Anthropic Console hesabı.
  2. API Keys sayfasından bir key oluştur ve kasanda sakla (1Password, AWS Secrets Manager, vs).
  3. Kullanım planına göre tier seç (geliştirme için free tier yeterli olabilir).
bash
$ pip install anthropic
Successfully installed anthropic-x.y.z
 
$ npm install @anthropic-ai/sdk
+ @anthropic-ai/sdk
added 1 package
 
$ echo 'ANTHROPIC_API_KEY=sk-ant-...' >> .env.local
import os from anthropic import Anthropic client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"]) resp = client.messages.create( model="claude-sonnet-4-6", max_tokens=512, messages=[ {"role": "user", "content": "Tek cümleyle: prompt mühendisliği nedir?"}, ], ) print(resp.content[0].text)
python
# Sağlam HTTP wrapper iskeleti
import os, time
from anthropic import Anthropic, APIError, APIStatusError, RateLimitError
 
client = Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"], timeout=60)
 
def safe_create(**kwargs):
for attempt in range(5):
try:
return client.messages.create(**kwargs)
except RateLimitError:
time.sleep(2 ** attempt)
except APIStatusError as e:
if 500 <= e.status_code < 600 and attempt < 4:
time.sleep(2 ** attempt)
continue
raise
İlk gün exponential backoff — basit ama %90 sorunu çözer.
Boşluk doldur · text
API key _____ koymamalı, _____ proxy üzerinden çağrı yapılmalıdır. 401 hatası genelde _____ kaynaklıdır. 429 hatası _____ aşıldığını ifade eder.

Frequently Asked Questions

Community SDKs exist for Go, Ruby, Rust. Official SDKs are Python and TypeScript; the raw HTTP API works for any language.

Yorumlar & Soru-Cevap

(0)
Yorum yazmak için giriş yap.
Yorumlar yükleniyor...

Related Content