Skip to main content
To use AI features in Uplink, you need to create an AI agent and configure it with your preferred provider.

Installation

First, install the AI package:

Creating an Agent

Use the ai.createAgent() factory function to create an agent:

Provider Configuration

Anthropic (Claude)

Anthropic’s Claude models are fully supported and recommended for browser automation.
Get an API key: Sign up at console.anthropic.com and create an API key. Available models:
  • claude-sonnet-4-5-20250929 (default) - Best balance of speed and intelligence
  • claude-opus-4-5-20251101 - Most capable, slower and more expensive
  • claude-haiku-4-20241024 - Fastest and cheapest, less capable

OpenAI (GPT)

OpenAI support is coming soon and not yet available.

Using the Agent

You can set the agent at two levels: Set the agent when connecting to apply it to all browsers and pages:

Page-Level Agent

Override the agent for a specific page:

Environment Variables

Store API keys in environment variables for security:
Access them in your code:
Never commit API keys to version control. Use environment variables or a secrets manager.

Complete Setup Example

Here’s a complete example with environment variables and error handling:

Cost Considerations

AI automation makes API calls to your chosen provider, which incurs costs:
  • Anthropic Claude: ~$3-15 per 1M input tokens depending on model
  • OpenAI GPT: ~$2.50-30 per 1M input tokens depending on model
Each act() or extract() call sends page context (usually 1-5K tokens) plus your instruction. Tips to reduce costs:
  • Use Haiku model for simple tasks
  • Use act() sparingly for complex interactions only
  • Combine multiple actions into one instruction when possible
  • Cache results when extracting the same data repeatedly

Next Steps

Natural Language Actions

Use page.act() to perform actions with AI

Data Extraction

Extract structured data with page.extract()