📚 مکمل گائیڈ: AI ٹولز کیسے بنائیں

بغیر ویب سائٹ کے AI ماڈل کیسے ٹیسٹ کریں - قدم بہ قدم سبق

3️⃣ مکمل HTML کوڈ کاپی کریں

نیچے دیا گیا کوڈ پوری طرح کاپی کریں،بغیر کسی تبدیلی کے، اپنی HTML فائل میں پیسٹ کریں۔

Complete HTML File
<!DOCTYPE html>
<html lang="ur">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>اردو AI ٹول</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: system-ui, sans-serif; background: #f8fafc; padding: 20px; }
        .container { max-width: 800px; margin: 0 auto; background: white; padding: 30px; border-radius: 16px; }
        input, textarea { width: 100%; padding: 12px; margin: 10px 0; border: 1px solid #e2e8f0; border-radius: 8px; }
        button { background: #6366f1; color: white; padding: 12px 24px; border: none; border-radius: 8px; cursor: pointer; }
        #output { margin-top: 20px; padding: 20px; background: #f1f5f9; border-radius: 8px; }
    </style>
</head>
<body>
    <div class="container">
        <h1>AI ٹیسٹ</h1>
        <input type="password" id="apiKey" placeholder="API Key">
        <textarea id="question" placeholder="مصنوعی ذہانت کیا ہے">    </textarea>
        <button onclick="callAI()">AI کو کال کریں</button>
        <div id="output"></div>
    </div>
    <script>
        async function callAI() {
            const key = document.getElementById('apiKey').value;
            const q = document.getElementById('question').value;
            const output = document.getElementById('output');
            output.textContent = "جارہا ہے...";
            try {
                const res = await fetch("https://api.openai.com/v1/chat/completions", {
                    method: "POST",
                    headers: {
                        "Content-Type": "application/json",
                        "Authorization": 'Bearer ' + key
                    },
                    body: JSON.stringify({
                        model: "gpt-4.1-mini",
                        messages: [{ role: "user", content: q }]
                    })
                });
                const data = await res.json();
                output.textContent = data.choices[0].message.content;
            } catch (e) {
                output.textContent = "خرابی: " + e.message;
            }
        }
    </script>
</body>
</html>

💡 نوٹ: یہ سادہ ورژن ہے۔ اصل HTML فائل میں زیادہ سٹائلنگ ہے، لیکن یہ بھی کام کرے گا۔