#!/usr/bin/env bash
# Discover available models from an OpenAI-compatible endpoint

API_KEY="${1:-${API_KEY}}"
URL="${2:-https://ai.noris.de/v1}"

if [ -z "$API_KEY" ]; then
    echo "Usage: $0 <api_key> [endpoint_url]"
    echo "   or: API_KEY=sk-... $0 [endpoint_url]"
    exit 1
fi

curl -sf -H "Authorization: Bearer $API_KEY" "${URL%/}/models" | \
    python3 -c "import sys,json; d=json.load(sys.stdin); [print(m['id']) for m in d.get('data',[])]"
