feat: add OrcaRouter as LLM provider for workflow generation - #172
feat: add OrcaRouter as LLM provider for workflow generation#172zsanig22-dotcom wants to merge 1 commit into
Conversation
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>
There was a problem hiding this comment.
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
| base_url='https://api.orcarouter.ai/v1', | ||
| api_key=os.getenv('ORCAROUTER_API_KEY'), | ||
| ) | ||
| return ChatBrowserUse(model='bu-latest') |
There was a problem hiding this comment.
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>
| return ChatBrowserUse(model='bu-latest') | |
| return ChatBrowserUse(model=model) |
| 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') |
There was a problem hiding this comment.
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>
| 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}') |
| return ChatOpenAI( | ||
| model=model, | ||
| base_url='https://api.orcarouter.ai/v1', | ||
| api_key=os.getenv('ORCAROUTER_API_KEY'), |
There was a problem hiding this comment.
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>
Summary
Workflow Use's
generate-workflowcommand already accepts--agent-model/--extraction-modeloptions, but those models were never wired up — the agent and extraction LLMs were always built asChatBrowserUse(model='bu-latest'). This PR makes those options effective and adds--llm-provider, withorcarouteras 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.ChatOpenAIis already used by the ecosystem: an OpenAI-compatible client pointed at OrcaRouter'shttps://api.orcarouter.ai/v1endpoint withORCAROUTER_API_KEY. The default (browser-use) path is unchanged.Verification
ruff checkandruff format --checkpass onworkflows/(matches CI).orcaroutercode path againsthttps://api.orcarouter.ai/v1withmodel=orcarouter/auto→ HTTP 200, completion returned (routed togemini-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-modeland--extraction-modeloptions ingenerate-workflowactually take effect, and adds a new--llm-provideroption withorcarouteras 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 defaultbrowser-usepath is unchanged.orcarouterprovider routes workflow generation through OrcaRouter's gateway for adaptive routing and failover.ORCAROUTER_API_KEYin the environment to use theorcarouterprovider.--agent-modeland--extraction-modelnow apply to the selected provider.Written for commit 7bd43ba. Summary will update on new commits.