#!/usr/bin/env bash set -euo pipefail script_dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" python_cmd="${CODEX_IMAGEGEN_PYTHON:-}" if [[ -z "$python_cmd" ]]; then embedded_python="$HOME/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/python.exe" if [[ -x "$embedded_python" ]]; then python_cmd="$embedded_python" else python_cmd="$(command -v python3 || command -v python || true)" fi fi if [[ -z "$python_cmd" ]]; then printf '%s\n' "Python 3 not found; install Python or set CODEX_IMAGEGEN_PYTHON." >&2 exit 1 fi runtime="$($python_cmd "$script_dir/runtime.py" --keyring)" read -r -p "OpenAI-compatible API base URL: " base_url if [[ -z "${base_url// }" ]]; then printf '%s\n' "API base URL cannot be empty." >&2 exit 1 fi "$runtime" "$script_dir/configure_key.py" --base-url "$base_url" printf '%s\n' "Now enter the API key." "$runtime" "$script_dir/configure_key.py"