Workshop Setup: Python, uv, API Keys, Your First LLM Call, and Langfuse Trace in 20 Minutes
Full workshop setup for course labs: Python 3.12, uv, virtual env, OpenAI/Anthropic/Gemini/DeepSeek/Groq API keys (all with free credit), Langfuse cloud account, first LLM call, and first telemetry trace.
Şükrü Yusuf KAYA
22 min read
Beginner⏱ 20 dakikan var mı?
Bu dersin sonunda: (1) Python 3.12 + uv kurulu, (2) 5 sağlayıcının ücretsiz API key'i alınmış, (3) Langfuse hesabı açık, (4) İlk 'Hello World' LLM çağrısı yapılmış ve Langfuse dashboard'da görülüyor olacak. Tek bir dosyayı kopyala-yapıştır ile değil — adım adım açıklayarak.
Adım 0 — İşletim Sistemi#
Kurs üç OS'i de destekler:
- macOS — Sıfır ek konfigürasyon gerekir. ⭐ En kolay.
- Linux (Ubuntu 22.04+) — Aynı. ⭐ En kolay.
- Windows 11 — WSL2 (Windows Subsystem for Linux) üzerinden Ubuntu kullanacağız. Saf Windows'ta da çalışabilir ama vLLM (Modül 11) için WSL2 zorunlu.
Windows için WSL2 kurulumu (zaten kuruluysa atla)#
PowerShell'i administrator olarak aç:
wsl --install -d Ubuntu-22.04
Bilgisayarı yeniden başlat, Ubuntu'yu aç, username + password oluştur. Bu noktada Linux terminal'in var.
Adım 1 — uv (Python Paket Yöneticisi) Kurulumu#
uv hem Python'ı kendisi kurar, hem virtual env'i yönetir, hem paketleri 100× hızlı indirir. üçünü tek araçla replace eder.
pip + venv + pyenvmacOS / Linux / WSL2#
curl -LsSf https://astral.sh/uv/install.sh | sh
Windows native (PowerShell)#
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Doğrulama#
uv --version # uv 0.4.x ✅
Adım 2 — Kurs Klasörü ve Sanal Ortam#
mkdir token-ekonomisi-lab && cd token-ekonomisi-lab # Python 3.12 ile yeni proje uv init --python 3.12 uv venv # Aktivasyon source .venv/bin/activate # macOS/Linux/WSL # Windows native: # .venv\Scripts\activate # Bağımlılıkları ekle uv add tiktoken anthropic openai google-genai groq litellm langfuse \ python-dotenv pandas tabulate
15-30 saniye içinde tüm bağımlılıklar kurulu. ( ile bu yaklaşık 3-5 dakika sürer.)
pip💡 uv pattern: 'ekosistem mağazası'
uv her komutunu kendi sandbox'ında çalıştırabilir. Örneğin: derken venv'i otomatik aktive eder. "Yanlış environment'ta çalıştırdım" sorununa son.
uv run python script.pyAdım 3 — API Key'leri Alalım (Ücretsiz Kredilerle)#
Şu beş sağlayıcının key'lerini alacağız. Hepsinin ücretsiz başlangıç kredisi veya kalıcı ücretsiz tier'ı var.
| Sağlayıcı | Ücretsiz Kredi | Ücretsiz Tier | Kayıt Linki |
|---|---|---|---|
| OpenAI | İlk hesap için (kart isteyebilir) | Yok | platform.openai.com |
| Anthropic | $5 yeni hesap | Yok | console.anthropic.com |
| Google Gemini | — | 1.5M token/dk, ücretsiz | aistudio.google.com |
| Groq | — | Ücretsiz tier (Llama 3.3 70B dahil) | console.groq.com |
| DeepSeek | $1 yeni hesap | Çok ucuz | platform.deepseek.com |
Toplam ücretsiz değer: ~$20+
Hepsini sırayla açacağız.
3.1 — OpenAI API Key#
- https://platform.openai.com adresine git
- Sign up → email doğrula
- Sol menü → API keys → Create new secret key
- İsim ver:
token-ekonomisi-kurs - Key'i kopyala — bu key bir daha gösterilmeyecek, güvenli yere koy
⚠️ OpenAI artık yeni hesaplar için kart bilgisi isteyebiliyor — biraz $5 kredi yüklemen gerekebilir. Kart eklemek istemiyorsan, OpenAI key'ini atlayıp DeepSeek ve Groq ile devam edebilirsin (alternatif sağlayıcılar).
3.2 — Anthropic (Claude) API Key#
- https://console.anthropic.com adresine git
- Sign up → telefon doğrula
- Sol menü → API Keys → Create Key
- İsim:
token-ekonomisi-kurs - Yeni hesaba $5 kredi otomatik geliyor — Sonnet 4.6 ile yaklaşık 1.6M input token
🎯 Kursta en çok kullanacağımız sağlayıcı bu — Claude'un prompt caching'i benzersiz.
3.3 — Google Gemini API Key#
- https://aistudio.google.com adresine git
- Google hesabınla giriş yap
- Üst sağ köşe → Get API key → Create API key in new project
- Key kopyala
✨ Bu kursun en çok beğeneceğin sağlayıcısı olabilir: Gemini 2.5 Flash ücretsiz tier'ında dakikada 1.5 milyon token + 1500 istek limiti. Lab'ların çoğunu burada ücretsiz yapabilirsin.
3.4 — Groq API Key#
- https://console.groq.com adresine git
- Sign up → email
- API Keys → Create API Key
- Key kopyala
🚀 Groq özelliği: dünyanın en hızlı inference servisleri. Llama 3.3 70B'yi saniyede 500 token üretir. Ücretsiz tier'ı çok cömert.
3.5 — DeepSeek API Key#
- https://platform.deepseek.com adresine git
- Sign up
- API Keys → Create new API key
- Yeni hesaba ~$1 deneme kredisi
💰 Önemi: en ucuz frontier-grade model (1.10/M output). Lab 9'da kalite/cost karşılaştırması için referans noktamız.
Adım 4 — .env Dosyası#
Proje klasöründe dosyası oluştur:
.env# .env (gitignore'a EKLE — repository'e gönderme) OPENAI_API_KEY=sk-proj-... ANTHROPIC_API_KEY=sk-ant-... GOOGLE_API_KEY=AIza... GROQ_API_KEY=gsk_... DEEPSEEK_API_KEY=sk-... LANGFUSE_PUBLIC_KEY=pk-lf-... # bir sonraki adımda dolduracağız LANGFUSE_SECRET_KEY=sk-lf-... LANGFUSE_HOST=https://cloud.langfuse.com
.gitignore.env .venv/ __pycache__/ *.pyc
🔐 GÜVENLİK — Çok Önemli
API key'leri asla koda hard-code etme. Asla GitHub'a push etme. Asla Slack/Discord'da paylaşma. Bir kez sızdırdığın key'i hemen revoke et (her sağlayıcının console'unda "Delete key" butonu var). OpenAI key sızıntısı = saatler içinde $1000+ fatura.
Adım 5 — Langfuse Hesabı#
- https://cloud.langfuse.com adresine git
- Sign up → organizasyon oluştur (isim: kendi adın)
- Project oluştur:
token-ekonomisi-kurs - Sol menü → Settings → API Keys → Create API Key
- Public key ve Secret key'i kopyala
- dosyasındaki ilgili satırları doldur
.env
Hesabın hazır. Dashboard'ı görmek için: https://cloud.langfuse.com → projeni seç.
Adım 6 — İlk "Hello World" LLM Çağrısı#
hello.pypython
# hello.pyimport osfrom dotenv import load_dotenvload_dotenv() # Langfuse otomatik tracing — sadece import et!from langfuse.openai import openai # langfuse'un drop-in replace'i response = openai.chat.completions.create( model="gpt-4o-mini", messages=[ {"role": "system", "content": "Sen Türkçe konuşan bir asistansın."}, {"role": "user", "content": "Merhaba, kendini 2 cümlede tanıt."}, ], metadata={"user_id": "test_user_1", "feature": "hello_world"},) print("Cevap:", response.choices[0].message.content)print("Input tokens:", response.usage.prompt_tokens)print("Output tokens:", response.usage.completion_tokens)print("Total tokens:", response.usage.total_tokens)İlk Langfuse-tracked LLM çağrımız. Tek import değişikliği ile full telemetry.
Çalıştır#
uv run python hello.py
Beklenen çıktı:
Cevap: Merhaba! Ben bir yapay zekâ asistanıyım. Sorularını cevaplamak ve yardımcı olmak için buradayım. Input tokens: 28 Output tokens: 24 Total tokens: 52
Adım 7 — İlk Langfuse Trace'ini Gör#
https://cloud.langfuse.com → projen → Tracing sekmesine git.
15-30 saniye içinde yeni trace'ini görmelisin:
- 📛 Name: openai.chat.completions
- ⏱ Latency: ~600ms
- 🔢 Tokens: 52 (28 in, 24 out)
- 💰 Cost: $0.0000186 (GPT-4o-mini'nin gerçek fiyatı)
- 🏷 Metadata:
{user_id: "test_user_1", feature: "hello_world"}
Bunu görüyorsan, atölyen hazır. 🎉
🎯 Tebrikler — Atölye Kuruldu
Bu noktada sahip olduğun şey: Tam çalışan Python ortamı + 5 sağlayıcının API key'i (~$20 ücretsiz kredi) + production-grade telemetry. Bu altyapı kurs boyunca her lab'da kullanılacak. Bir sonraki dersten itibaren gerçek konuya giriyoruz: token anatomisi.
Sorun Giderme#
uv: command not found hatası#
uv: command not foundPATH~/.cargo/bin~/.local/binsource $HOME/.local/bin/env
Authentication error (OpenAI)#
Authentication error.envload_dotenv()Langfuse trace görünmüyor#
langfuse.openaiopenailangfuse.flush()from langfuse import get_client get_client().flush()
Windows: SSL/cert hatası#
certifiuv add certifipip install --upgrade certifiLab 0 — Müfredat İçin Hatırlatma#
Modül 0'ın hedefiydi: Atölye kurulu olsun, ilk telemetry çalışsın.
Tamamladıysan:
- ✅ uv ile Python 3.12 ortamı
- ✅ 5 sağlayıcının ücretsiz API key'i
- ✅ Langfuse cloud hesabı + ilk trace
- ✅ İlk LLM çağrısı ()
hello.py
Bir sonraki modülde token anatomisine dalıyoruz. Bu hazırlığın olmadan ilerleyemezsin — şimdi durdur, kurulumu tamamla, sonra Modül 1 ile devam et.
🚀 Modül 1'e geçiyoruz
Modül 1: Token Anatomisi. Bir token nedir, neden Türkçe metnin %70 daha pahalı, GPT/Claude/Gemini/Llama tokenizer'ları arasındaki şok edici farklar, ve input/output token ekonomisi. Atölyen kurulduysa devam et.
Frequently Asked Questions
Yes. With Gemini free tier + Groq free tier you can complete 80% of the course. If you skip OpenAI and Anthropic, you can apply lab patterns through DeepSeek ($1 free credit is enough) and Llama (free on Groq).
Yorumlar & Soru-Cevap
(0)Yorum yazmak için giriş yap.
Yorumlar yükleniyor...
Related Content
Module 0: Why Cost, Why Now?
The AI Cost Explosion: Why Token Prices Fell 96% from 2022 to 2026 — Yet Bills Grew 40×
Start LearningModule 0: Why Cost, Why Now?
Unit Economics Vocabulary: COGS, Gross Margin, $/User, Contribution Margin — 9 Financial Concepts Every AI Engineer Must Know
Start LearningModule 0: Why Cost, Why Now?