Icindekiler
OpenAI Codex Nedir?
OpenAI Codex, OpenAI tarafindan gelistirilen ve dogal dili koda ceviren yapay zeka modelidir. GitHub Copilot'in arkasindaki teknolojidir. Python, JavaScript, TypeScript, Go ve daha bircok dilde kod uretebilir. GPT modellerinin kod odakli versiyonu olarak dusunulebilir.
Dogal Dil → Kod
Ingilizce veya Turkce aciklama yazin, calisir kod alin.
Kod Ceviri
Bir programlama dilinden digerine kod cevirisi yapin.
Hata Ayiklama
Kodunuzdaki hatalari bulun ve duzeltme onerileri alin.
Kurulum ve Baslangic
Adim 1: OpenAI API Anahtari Alin
platform.openai.com adresinde bir hesap olusturun ve API anahtari uretim.
Adim 2: openai Paketini Kurun
# Python
pip install openai
# Node.js
npm install openai
# API anahtarini ayarlayin / Set your API key
export OPENAI_API_KEY="sk-your-api-key-here"
Adim 3: Ilk API Cagrisi
import OpenAI from 'openai';
const openai = new OpenAI();
const response = await openai.responses.create({
model: "o3-mini",
instructions: "You are a coding assistant. Generate clean, working code.",
input: "Write a JavaScript function that reverses a string"
});
console.log(response.output_text);
Playground ile Deneyin
Kod yazmadan once platform.openai.com/playground adresinde Codex modellerini test edebilirsiniz. Farkli parametreleri deneyin.
Temel Kullanim
Kod Tamamlama
const response = await openai.responses.create({
model: "o3-mini",
instructions: "Complete the following code. Only return the code.",
input: `// Function to calculate fibonacci sequence
function fibonacci(n) {`
});
// Output: complete fibonacci function implementation
Fonksiyon Uretimi
const response = await openai.responses.create({
model: "o3-mini",
instructions: "Generate a production-ready function with error handling.",
input: "Create a function that validates an email address and returns { valid: boolean, reason?: string }"
});
Diller Arasi Ceviri
const response = await openai.responses.create({
model: "o3-mini",
instructions: "Translate the given Python code to TypeScript. Keep the same logic.",
input: `def merge_sort(arr):
if len(arr) <= 1:
return arr
mid = len(arr) // 2
left = merge_sort(arr[:mid])
right = merge_sort(arr[mid:])
return merge(left, right)`
});
Hata Ayiklama
const response = await openai.responses.create({
model: "o3-mini",
instructions: "Find the bug in this code and fix it. Explain the issue.",
input: `function removeDuplicates(arr) {
for (let i = 0; i < arr.length; i++) {
if (arr[i] === arr[i + 1]) {
arr.splice(i, 1);
}
}
return arr;
}`
});
Web Sitesi Olusturma
Codex API kullanarak adim adim bir Express.js REST API olusturalim.
Adim 1: Proje Iskeleti
// Codex'e proje yapisi olusturtma
const prompt = `Create an Express.js REST API project structure with:
- TypeScript configuration
- Routes for users CRUD
- Middleware for auth and error handling
- Database connection with Prisma
Give me the full folder structure and package.json`;
const response = await openai.responses.create({
model: "o3-mini",
instructions: "You are a senior backend developer. Generate production-ready code.",
input: prompt
});
Adim 2: Route'lari Olusturma
const routePrompt = `Generate Express.js routes for a User resource:
- GET /api/users - list all users with pagination
- GET /api/users/:id - get single user
- POST /api/users - create user with validation
- PUT /api/users/:id - update user
- DELETE /api/users/:id - soft delete user
Use TypeScript, proper error handling, and Prisma ORM.`;
Adim 3: Frontend Entegrasyonu
const frontendPrompt = `Create a React component that:
- Fetches users from GET /api/users
- Displays them in a responsive table
- Has search and pagination
- Uses TanStack Query for data fetching
- Handles loading, error, and empty states`;
Mobil Uygulama Gelistirme
Codex ile React Native mobil uygulama gelistirme adimlari.
Adim 1: Uygulama Iskeleti
const mobilePrompt = `Create a React Native Expo app with:
- Bottom tab navigation (Home, Search, Profile)
- A home screen with a FlatList of cards
- Pull-to-refresh functionality
- TypeScript and NativeWind for styling
Generate the App.tsx and navigation setup.`;
Adim 2: Ekran Tasarimi
const screenPrompt = `Generate a React Native profile screen with:
- User avatar with edit button
- Stats row (posts, followers, following)
- Settings list with icons
- Logout button
Use NativeWind classes for styling.`;
Adim 3: API Baglantisi
const apiPrompt = `Create a React Native API service layer with:
- Axios instance with base URL and auth interceptor
- Token refresh logic
- Request/response error handling
- TypeScript interfaces for all endpoints`;
Ileri Seviye Ipuclari
Temperature Ayari
Kod uretimi icin temperature: 0 veya 0.2 kullanin. Dusuk temperature daha tutarli ve dogru kod uretir. Yaratici cozumler icin 0.7'ye kadar cikin.
Stop Sequence Kullanimi
Modelin nerede durmasini istediginizi belirleyin. Ornegin stop: ["\n\n"] ile tek fonksiyon uretimini sinirlandirabiliirsiniz.
max_tokens Optimizasyonu
Gereksiz token harcamamak icin max_tokens parametresini ayarlayin. Kisa fonksiyonlar icin 256, dosyalar icin 2048 iyi bir baslangictir.
System Prompt ile Yonlendirme
Iyi bir system prompt kod kalitesini arttirir. "You are a senior TypeScript developer. Use strict types, handle errors, add JSDoc comments." gibi talimatlar verin.
Fiyatlandirma
OpenAI Codex, API tabanli fiyatlandirma kullanir. Kullandiginiz token basina ucret odersiniz.
GPT-4o mini
- Hizli ve ucuz
- Basit kod gorevleri icin
- 128K context window
GPT-4o
- En iyi genel performans
- Karmasik kod gorevleri
- 128K context window
o3-mini
- Reasoning odakli
- Kod analizi ve debug
- 200K context window
Pratik Alistirmalar
Alistirma 1: REST API Olusturma
Codex API kullanarak bir "Todo List" REST API'i olusturun. CRUD islemleri, validasyon ve hata yonetimi icermelidir. Express.js ve TypeScript kullanin.
Alistirma 2: Kod Cevirici
Python'dan JavaScript'e kod ceviren bir web arayuzu olusturun. Kullanici Python kodu girer, Codex API ile cevrilmis JavaScript kodunu gosterir.
Alistirma 3: Otomatik Test Uretici
Verilen bir JavaScript fonksiyonu icin otomatik Jest testleri ureten bir script yazin. Codex API'yi kullanarak edge case'leri de kapsayan testler uretmesini isteyin.