# debug_network.py import os, socket, requests def debug_connectivity(): print("DEBUG: OPENAI_API_KEY present:", bool(os.getenv("OPENAI_API_KEY"))) print("DEBUG: ANTHROPIC_API_KEY present:", bool(os.getenv("ANTHROPIC_API_KEY"))) for host in ["api.openai.com", "api.anthropic.com"]: try: ip = socket.gethostbyname(host) print(f"DEBUG: DNS for {host} -> {ip}") except Exception as e: print(f"DEBUG: DNS FAILED for {host}: {e}") try: r = requests.get("https://api.openai.com/v1/models", timeout=5) print("DEBUG: OpenAI /v1/models status:", r.status_code) except Exception as e: print("DEBUG: OpenAI GET failed:", repr(e)) try: r = requests.get("https://api.anthropic.com/health", timeout=5) print("DEBUG: Anthropic /health status:", r.status_code) except Exception as e: print("DEBUG: Anthropic GET failed:", repr(e))