import os import re import httpx import base64 # Extract API key from the proxy logs api_key = None log_path = "/Users/keira/Library/Logs/qwen_proxy.err.log" if os.path.exists(log_path): with open(log_path, "r") as f: content = f.read() # Find something like "Bearer sk-..." match = re.search(r"Bearer\s+(sk-[a-zA-Z0-9_-]+)", content) if match: api_key = match.group(1) if not api_key: # Try the standard log log_path = "/Users/keira/Library/Logs/qwen_proxy.log" if os.path.exists(log_path): with open(log_path, "r") as f: content = f.read() match = re.search(r"Bearer\s+(sk-[a-zA-Z0-9_-]+)", content) if match: api_key = match.group(1) if not api_key: print("Could not find API key in logs.") exit(1) print(f"Found API key starting with: {api_key[:8]}...") url = "https://ws-fnt3psiwu1morhou.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions" headers = { "Content-Type": "application/json", "Authorization": f"Bearer {api_key}" } # Create a tiny 1-second silent WAV bytes wav_data = b"RIFF&\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00@\x1f\x00\x00@\x1f\x00\x00\x01\x00\x08\x00data\x02\x00\x00\x00\x80\x80" base64_audio = base64.b64encode(wav_data).decode("utf-8") payload = { "model": "qwen3.5-omni-flash-realtime", "messages": [ { "role": "user", "content": [ { "type": "input_audio", "input_audio": { "data": f"data:audio/wav;base64,{base64_audio}", "format": "wav" } }, { "type": "text", "text": "Transcribe this audio." } ] } ] } resp = httpx.post(url, json=payload, headers=headers, timeout=20.0) print(f"Status Code: {resp.status_code}") print(f"Response: {resp.text}")