Quick wins
Start with these simple optimizations that can reduce costs:Use the right model for the job
Browserbase doesn’t recommend using larger, more premium models for simple tasks. See the evaluation results for model performance and cost comparisons across different task types. Reach for a stronger model only on the calls that need it, with a per-call model override:- TypeScript
- Python
- Go
Model selection guide
Choose the right LLM for your budget and accuracy requirements
Evaluation results
See how different models perform on different tasks
Implement caching
Enable server-side caching to eliminate redundant LLM calls. Turn on thecache option when initializing Stagehand:
- TypeScript
- Python
- Go
Caching guide
Learn how the cache key is built and how to tune the hit-count threshold
Optimize browser sessions
Reuse sessions when possible and set appropriate timeouts. See Browser Configuration for details:- TypeScript
- Python
- Go
Browserbase cost optimization
Optimize Browserbase infrastructure costs and session management
Advanced strategies
Intelligent model switching
Automatically fall back to cheaper models for simple tasks. Escalate onobserve() rather than act(): observe() only plans and never touches the page, so a retry cannot repeat a click, submit, or purchase that already landed before the error surfaced. The winning plan is then handed to act() exactly once.
- TypeScript
- Python
- Go
Session pooling
Reuse browser sessions across multiple tasks:- TypeScript
- Python
- Go
Cost monitoring
Track your spending to identify optimization opportunities. See the observability guide for detailed metrics. Stagehand reports token counts, not dollars. Keep prompt and completion tokens separate: providers bill them at different rates, so a single blended rate over the total is wrong for every model. Multiply each count by the input and output rates on your provider’s pricing page to turn these into currency.- TypeScript
- Python
- Go
Observability & metrics
Monitor usage patterns and track costs in real-time
Budget controls
Set spending limits to prevent unexpected costs:- TypeScript
- Python
- Go
Related resources
Model selection guide
Choose the right LLM for your budget and accuracy requirements
Caching strategies
Reduce costs with smart action caching and observe patterns
Observability & metrics
Monitor usage patterns and track costs in real-time
Browser configuration
Optimize Browserbase infrastructure costs and session management

