import asyncio, httpx, os, json

async def test():
    print("HTTPS_PROXY:", os.environ.get("HTTPS_PROXY", "NOT SET"))
    cfg = json.load(open("/root/.nanobot/config.json"))
    api_key = cfg["providers"]["openai"]["apiKey"]
    
    # Test 1: without explicit proxy (relies on env var)
    async with httpx.AsyncClient(timeout=30) as client:
        try:
            r = await client.post(
                "https://codeproxy.dev/v1/responses",
                headers={"Authorization": f"Bearer {api_key}", "Content-Type": "application/json", "OpenAI-Beta": "responses-2024-12-01"},
                json={"model": "gpt-5.4", "input": [{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "hi"}]}]}
            )
            print("Without explicit proxy:", r.status_code, r.text[:100])
        except Exception as e:
            print("Without explicit proxy ERROR:", e)

asyncio.run(test())
