Skip to content

feat: add OrcaRouter as LLM provider for workflow generation - #172

Open
zsanig22-dotcom wants to merge 1 commit into
browser-use:mainfrom
zsanig22-dotcom:feat/orcarouter-llm-provider
Open

feat: add OrcaRouter as LLM provider for workflow generation#172
zsanig22-dotcom wants to merge 1 commit into
browser-use:mainfrom
zsanig22-dotcom:feat/orcarouter-llm-provider

Conversation

@zsanig22-dotcom

@zsanig22-dotcom zsanig22-dotcom commented Aug 28, 2026

Copy link
Copy Markdown

Summary

Workflow Use's generate-workflow command already accepts --agent-model/--extraction-model options, but those models were never wired up — the agent and extraction LLMs were always built as ChatBrowserUse(model='bu-latest'). This PR makes those options effective and adds --llm-provider, with orcarouter as a first-class provider backed by OrcaRouter.

OrcaRouter is an OpenAI-compatible AI gateway built for both models and agents. Like OpenRouter, it exposes a provider/model namespace across many models — but it also combines adaptive routing, automatic failover, zero-markup inference, observability, guardrails, and agent-tool governance behind the same endpoint. Adding orcarouter as a first-class provider means this project's users can use that stack directly, without treating OrcaRouter as an anonymous custom base URL. It also runs gateway-level, zero-trust security for AI agents on the same endpoint — screening every prompt/response and governing every tool call on a default-deny basis, with no application code changes.

The implementation mirrors how browser_use.llm.openai.ChatOpenAI is already used by the ecosystem: an OpenAI-compatible client pointed at OrcaRouter's https://api.orcarouter.ai/v1 endpoint with ORCAROUTER_API_KEY. The default (browser-use) path is unchanged.

Verification

  • ruff check and ruff format --check pass on workflows/ (matches CI).
  • Live-tested the new orcarouter code path against https://api.orcarouter.ai/v1 with model=orcarouter/auto → HTTP 200, completion returned (routed to gemini-3.1-flash-lite).

Discord: discord.gg/YEubt8enRA · X: https://x.com/OrcaRouter

I'm an engineer on the OrcaRouter team.


Summary by cubic

Makes the --agent-model and --extraction-model options in generate-workflow actually take effect, and adds a new --llm-provider option with orcarouter as a first-class provider backed by OrcaRouter's OpenAI-compatible gateway.

Previously these model options were ignored; the agent and extraction LLMs were always built with ChatBrowserUse(model='bu-latest'). The default browser-use path is unchanged.

  • The orcarouter provider routes workflow generation through OrcaRouter's gateway for adaptive routing and failover.
  • Users need to set ORCAROUTER_API_KEY in the environment to use the orcarouter provider.
  • --agent-model and --extraction-model now apply to the selected provider.

Written for commit 7bd43ba. Summary will update on new commits.

Review in cubic

Add an --llm-provider option to the generate-workflow command so users can
route workflow generation through OrcaRouter's OpenAI-compatible gateway.
Honor the existing --agent-model/--extraction-model options when building
the agent and extraction LLMs.

Co-Authored-By: Claude <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="workflows/cli.py">

<violation number="1" location="workflows/cli.py:2311">
P2: When `--llm-provider` contains a typo or unsupported value, this fallback silently uses Browser-Use instead of rejecting the provider. Validate `browser-use` explicitly and raise a CLI parameter error for every other value.</violation>

<violation number="2" location="workflows/cli.py:2315">
P2: When `ORCAROUTER_API_KEY` is unset, `os.getenv` returns None, which ChatOpenAI drops from its client params and AsyncOpenAI then fills by falling back to `OPENAI_API_KEY`. The result is your OpenAI key being sent to OrcaRouter's endpoint, or a confusing client error if no key is set. Validate the key is non-empty before building the orcarouter LLM.</violation>

<violation number="3" location="workflows/cli.py:2317">
P2: When the default `browser-use` provider is selected, `--agent-model` and `--extraction-model` are ignored because this branch always creates `bu-latest`. Pass `model` to `ChatBrowserUse` so the documented custom-model options work for the default provider.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread workflows/cli.py
base_url='https://api.orcarouter.ai/v1',
api_key=os.getenv('ORCAROUTER_API_KEY'),
)
return ChatBrowserUse(model='bu-latest')

@cubic-dev-ai cubic-dev-ai Bot Aug 28, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When the default browser-use provider is selected, --agent-model and --extraction-model are ignored because this branch always creates bu-latest. Pass model to ChatBrowserUse so the documented custom-model options work for the default provider.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At workflows/cli.py, line 2317:

<comment>When the default `browser-use` provider is selected, `--agent-model` and `--extraction-model` are ignored because this branch always creates `bu-latest`. Pass `model` to `ChatBrowserUse` so the documented custom-model options work for the default provider.</comment>

<file context>
@@ -2300,6 +2300,23 @@ def generate_csv_template_command(
+			base_url='https://api.orcarouter.ai/v1',
+			api_key=os.getenv('ORCAROUTER_API_KEY'),
+		)
+	return ChatBrowserUse(model='bu-latest')
+
+
</file context>
Suggested change
return ChatBrowserUse(model='bu-latest')
return ChatBrowserUse(model=model)
Fix with cubic

Comment thread workflows/cli.py
Comment on lines +2311 to +2317
if llm_provider == 'orcarouter':
return ChatOpenAI(
model=model,
base_url='https://api.orcarouter.ai/v1',
api_key=os.getenv('ORCAROUTER_API_KEY'),
)
return ChatBrowserUse(model='bu-latest')

@cubic-dev-ai cubic-dev-ai Bot Aug 28, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When --llm-provider contains a typo or unsupported value, this fallback silently uses Browser-Use instead of rejecting the provider. Validate browser-use explicitly and raise a CLI parameter error for every other value.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At workflows/cli.py, line 2311:

<comment>When `--llm-provider` contains a typo or unsupported value, this fallback silently uses Browser-Use instead of rejecting the provider. Validate `browser-use` explicitly and raise a CLI parameter error for every other value.</comment>

<file context>
@@ -2300,6 +2300,23 @@ def generate_csv_template_command(
+	the existing browser-use cloud behavior (the ``bu-latest`` alias is resolved
+	by the gateway to the current premium model).
+	"""
+	if llm_provider == 'orcarouter':
+		return ChatOpenAI(
+			model=model,
</file context>
Suggested change
if llm_provider == 'orcarouter':
return ChatOpenAI(
model=model,
base_url='https://api.orcarouter.ai/v1',
api_key=os.getenv('ORCAROUTER_API_KEY'),
)
return ChatBrowserUse(model='bu-latest')
if llm_provider == 'orcarouter':
return ChatOpenAI(
model=model,
base_url='https://api.orcarouter.ai/v1',
api_key=os.getenv('ORCAROUTER_API_KEY'),
)
elif llm_provider == 'browser-use':
return ChatBrowserUse(model='bu-latest')
raise typer.BadParameter(f'Unsupported LLM provider: {llm_provider}')
Fix with cubic

Comment thread workflows/cli.py
return ChatOpenAI(
model=model,
base_url='https://api.orcarouter.ai/v1',
api_key=os.getenv('ORCAROUTER_API_KEY'),

@cubic-dev-ai cubic-dev-ai Bot Aug 28, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When ORCAROUTER_API_KEY is unset, os.getenv returns None, which ChatOpenAI drops from its client params and AsyncOpenAI then fills by falling back to OPENAI_API_KEY. The result is your OpenAI key being sent to OrcaRouter's endpoint, or a confusing client error if no key is set. Validate the key is non-empty before building the orcarouter LLM.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At workflows/cli.py, line 2315:

<comment>When `ORCAROUTER_API_KEY` is unset, `os.getenv` returns None, which ChatOpenAI drops from its client params and AsyncOpenAI then fills by falling back to `OPENAI_API_KEY`. The result is your OpenAI key being sent to OrcaRouter's endpoint, or a confusing client error if no key is set. Validate the key is non-empty before building the orcarouter LLM.</comment>

<file context>
@@ -2300,6 +2300,23 @@ def generate_csv_template_command(
+		return ChatOpenAI(
+			model=model,
+			base_url='https://api.orcarouter.ai/v1',
+			api_key=os.getenv('ORCAROUTER_API_KEY'),
+		)
+	return ChatBrowserUse(model='bu-latest')
</file context>
Fix with cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant