Allow Vertex models in CLI without requiring LLM API key#538
Allow Vertex models in CLI without requiring LLM API key#538aking13 wants to merge 1 commit intoOpenHands:mainfrom
Conversation
25c8083 to
9760b95
Compare
enyst
left a comment
There was a problem hiding this comment.
Thank you for looking into this, @aking13 ! Just for information, interestingly we just merged a PR fixing the same thing for Bedrock:
OpenHands/software-agent-sdk#2195
WDYT, could that work for Vertex without API key?
I'm not sure I follow. That fix correctly doesn't forward an api_key, but it does not prevent the CLI from hard requiring an API in settings and for headless flows for Vertex, when in reality no API Key is needed at all for everything to work with Vertex. Essentially today Vertex users have to type in some random non-null gibberish key to get Vertex LLMs to work in CLI and this PR removes that experience. |
Summary
vertex_ai/vertex_ai_betamodels to be configured in CLI settings without forcing an API key--override-with-envs/ headless agent creation for Vertex models withoutLLM_API_KEYWhy
Vertex authentication is handled via GCP credentials (for example
GOOGLE_APPLICATION_CREDENTIALS,VERTEXAI_PROJECT,VERTEXAI_LOCATION), so requiring a fake API key in CLI was incorrect and confusing.Changes
openhands_cli/tui/modals/settings/utils.pyopenhands_cli/stores/agent_store.pymodel_requires_api_key()helperapi_key=Nonefor Vertex modelsLLM_API_KEYValidation
uv run ruff check openhands_cli/tui/modals/settings/utils.py openhands_cli/stores/agent_store.py tests/tui/modals/settings/test_settings_utils.py tests/stores/test_env_llm_overrides.pyuv run pytest -q tests/tui/modals/settings/test_settings_utils.py tests/stores/test_env_llm_overrides.py59 passedNotes
This PR addresses CLI-side validation/agent creation behavior. Runtime import errors for Vertex still require the environment to include
google-cloud-aiplatform(LiteLLM dependency).