diff --git a/stagehand/agent/anthropic_cua.py b/stagehand/agent/anthropic_cua.py index df6c7a2..f69ce8f 100644 --- a/stagehand/agent/anthropic_cua.py +++ b/stagehand/agent/anthropic_cua.py @@ -58,9 +58,12 @@ def __init__( ): super().__init__(model, instructions, config, logger, handler) self.experimental = experimental - self.anthropic_sdk_client = Anthropic( - api_key=config.options.get("apiKey") or os.getenv("ANTHROPIC_API_KEY") - ) + api_key = None + if config and hasattr(config, 'options') and config.options: + api_key = config.options.get('api_key') or config.options.get('apiKey') + if not api_key: + api_key = os.getenv('ANTHROPIC_API_KEY') + self.anthropic_sdk_client = Anthropic(api_key=api_key) dimensions = ( (viewport["width"], viewport["height"]) if viewport else (1288, 711) diff --git a/stagehand/agent/google_cua.py b/stagehand/agent/google_cua.py index fc46196..ae5b9b7 100644 --- a/stagehand/agent/google_cua.py +++ b/stagehand/agent/google_cua.py @@ -46,7 +46,7 @@ def __init__( # Match OpenAI pattern for API key handling api_key = None if config and hasattr(config, "options") and config.options: - api_key = config.options.get("apiKey") + api_key = config.options.get("api_key") or config.options.get("apiKey") if not api_key: api_key = os.getenv("GEMINI_API_KEY") if not api_key: diff --git a/stagehand/agent/openai_cua.py b/stagehand/agent/openai_cua.py index 16506f5..49d1962 100644 --- a/stagehand/agent/openai_cua.py +++ b/stagehand/agent/openai_cua.py @@ -40,9 +40,12 @@ def __init__( ): super().__init__(model, instructions, config, logger, handler) # TODO pass api key - self.openai_sdk_client = OpenAISDK( - api_key=config.options.get("apiKey") or os.getenv("OPENAI_API_KEY") - ) + api_key = None + if config and hasattr(config, 'options') and config.options: + api_key = config.options.get('api_key') or config.options.get('apiKey') + if not api_key: + api_key = os.getenv('OPENAI_API_KEY') + self.openai_sdk_client = OpenAISDK(api_key=api_key) dimensions = ( (viewport["width"], viewport["height"]) if viewport else (1288, 711)