#!/usr/bin/env python3
"""Probe — list Gemini models accessible to this API key.

Run on the Jetson under the gemini_sdk env:

    /home/unitree/miniconda3/envs/gemini_sdk/bin/python \
        /home/unitree/Marcus/Voice/_probe_models.py

Prints every model the key can see plus whether it supports
`bidiGenerateContent` (= the Live API). Pick one with that capability
and put its name in Config/config_Voice.json::stt.gemini_model.
"""
import os
import sys

API_KEY = (
    os.environ.get("MARCUS_GEMINI_API_KEY")
    or os.environ.get("SANAD_GEMINI_API_KEY")
    or "AIzaSyDt9Xi83MDZuuPpfwfHyMD92X7ZKdGkqf8"
)

try:
    from google import genai
except ImportError:
    print("google-genai not installed in this env", file=sys.stderr)
    sys.exit(2)

client = genai.Client(api_key=API_KEY)

print(f"{'NAME':<60} {'METHODS'}")
print("-" * 100)
live_models = []
for m in client.models.list():
    name = getattr(m, "name", "?")
    methods = (
        getattr(m, "supported_actions", None)
        or getattr(m, "supported_generation_methods", None)
        or []
    )
    methods_str = ", ".join(methods) if methods else "-"
    print(f"{name:<60} {methods_str}")
    if "bidiGenerateContent" in methods:
        live_models.append(name)

print()
print("=" * 100)
print(f"Live API capable models (supports bidiGenerateContent):")
for name in live_models:
    print(f"  - {name}")
if not live_models:
    print("  (none — your key may need Gemini Live access enabled)")
