INNER CODE UNIT · Python

debug_openai_connection

zillionare/zillionare · scripts/debug_crawler.py:66

def debug_openai_connection():
    """调试OpenAI连接"""
    print("\n=== 调试OpenAI连接 ===")

    api_key = os.getenv("OPENAI_API_KEY")
    if not api_key:
        print("❌ OPENAI_API_KEY 环境变量未设置")
        return False

    print(f"✓ API Key已设置 (长度: {len(api_key)})")

    try:
        from openai import OpenAI

        client = OpenAI(api_key=api_key)

        # 测试简单请求
        response = client.chat.completions.create(

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…