# shellcheck shell=dash

xrc:mod:lib     codex      other/ds    other/kimi \
    other/zhipu    other/sili    other/doubao other/hub

___x_cmd_codex_other___use(){
    local provider="$1"
    local url="$2"
    local apikey="$3"
    local model="$4"
    local provider_name="$5"
    local wire_api="$6"
    shift 6

    codex:warn --discussions "https://github.com/openai/codex/discussions/7782" "Codex v0.80.0+ will deprecate chat/completions API, only responses API is supported."
    codex:warn "To continue using models without responses API, run: x env use codex=v0.80.0"

    CODEX_API_KEY="${CODEX_API_KEY:-"$apikey"}" \
    ___x_cmd_codex___runcmd --config profile="$provider" \
        --config "profiles.${provider}.model=$model" \
        --config "profiles.${provider}.model_provider=${provider}" \
        --config "model_provider=${provider}" \
        --config "model_providers.${provider}.name=${provider_name}" \
        --config "model_providers.${provider}.base_url=${url}" \
        --config "model_providers.${provider}.env_key=CODEX_API_KEY" \
        --config "model_providers.${provider}.wire_api=${wire_api}" \
        "$@"
}
