Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions stagehand/agent/anthropic_cua.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion stagehand/agent/google_cua.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 6 additions & 3 deletions stagehand/agent/openai_cua.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down