'Method not allowed']); exit; } // Gelen body'yi oku $input = file_get_contents('php://input'); $body = json_decode($input, true); if (!$body || !isset($body['prompt'])) { http_response_code(400); echo json_encode(['error' => 'Missing prompt']); exit; } $prompt = substr(strip_tags($body['prompt']), 0, 3000); // güvenlik limiti $langName = substr(strip_tags($body['langName'] ?? 'French'), 0, 30); // Anthropic API isteği $payload = json_encode([ 'model' => 'claude-sonnet-4-6', 'max_tokens' => 1200, 'messages' => [[ 'role' => 'user', 'content' => $prompt, ]], ]); $ch = curl_init('https://api.anthropic.com/v1/messages'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $payload, CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'x-api-key: ' . ANTHROPIC_API_KEY, 'anthropic-version: 2023-06-01', ], CURLOPT_TIMEOUT => 30, ]); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curlErr = curl_error($ch); curl_close($ch); if ($curlErr) { http_response_code(502); echo json_encode(['error' => 'Curl error: ' . $curlErr]); exit; } http_response_code($httpCode); echo $response;