Files
Saurav Panda be76e6ccee fix(orcarouter): resolve the API key explicitly instead of inheriting OPENAI_API_KEY
AsyncOpenAI falls back to OPENAI_API_KEY when api_key is unset, so
ChatOrcaRouter(model=...) with no key authenticated its requests to
api.orcarouter.ai with the user's OpenAI credentials. The shipped example
hit this path whenever ORCAROUTER_API_KEY was unset, and .env.example
documented a variable that nothing read.

Resolve api_key from the constructor then ORCAROUTER_API_KEY, and raise
ModelProviderError(401) when neither is set, matching ChatMistral.
2026-08-31 16:02:22 -07:00

29 lines
547 B
Python

"""
Simple try of the agent with OrcaRouter.
@dev You need to add ORCAROUTER_API_KEY to your environment variables.
"""
import asyncio
from dotenv import load_dotenv
from browser_use import Agent, ChatOrcaRouter
load_dotenv()
# OrcaRouter is an OpenAI-compatible model gateway routing to 190+ models via one endpoint.
llm = ChatOrcaRouter(model='orcarouter/auto')
agent = Agent(
task='Find the number of stars of the browser-use repo',
llm=llm,
use_vision=False,
)
async def main():
await agent.run(max_steps=10)
asyncio.run(main())