untitled

Pasted Oct 8, 2026, 5:01 PM1 file44 lines

Scan to open on your phone

Point a camera at the QR code - it opens this exact paste, no app needed.

https://codepastes.com/zzgt0yf46m2d21m8
untitled
import os
from google import genai

# 1. Apna Gemini API Key yahan dalein
# Aap free API key is website se le sakte hain: https://google.com
API_KEY = "YAHAN_APNA_API_KEY_DALEIN"

def start_ai():
    # Client ko initialize karein
    client = genai.Client(api_key=API_KEY)
    
    print("=============================================")
    print("๐Ÿค– Aapka AI Assistant Tyar Hai! (Type 'exit' to quit)")
    print("=============================================\n")
    
    # Chat session shuru karein taaki AI purani baatein yaad rakhe
    chat = client.chats.create(model="gemini-2.5-flash")
    
    while True:
        try:
            # User se sawal lein
            user_input = input("๐Ÿ‘ค Aap: ")
            
            # Agar user 'exit' likhe toh program band ho jaye
            if user_input.lower() == 'exit':
                print("๐Ÿค– AI: Khuda Hafiz! Phir milenge.")
                break
                
            if not user_input.strip():
                continue
            
            # AI se jawab lein
            response = chat.send_message(user_input)
            
            # Jawab screen par dikhayein
            print(f"๐Ÿค– AI: {response.text}\n")
            
        except Exception as e:
            print(f"โŒ Error: {e}")
            print("๐Ÿ’ก Tip: Check karein aapka API Key sahi hai ya internet chal raha hai.\n")

if __name__ == "__main__":
    start_ai()

1,400 chars ยท codepastes.com