### Complete Example Setup (TypeScript) Source: https://docs.steel.dev/integrations/agentkit/quickstart Provides the full index.ts file content for the Hacker News curator example. It includes all necessary imports, API key configuration, tool definition, agent and network setup, and the main function to run the network. This allows users to copy and run the complete example. ```typescript import { Steel } from "@inngest/steel"; import { chromium } from "playwright"; import { z } from "zod"; import { openai, createAgent, createNetwork, createTool, } from "@inngest/agent-kit"; dotenv.config(); // Replace with your own API keys const STEEL_API_KEY = process.env.STEEL_API_KEY || "your-steel-api-key-here"; const OPENAI_API_KEY = process.env.OPENAI_API_KEY || "your-openai-api-key-here"; const client = new Steel({ steelAPIKey: STEEL_API_KEY }); const browseHackerNews = createTool({ name: "browse_hacker_news", description: "Fetch Hacker News stories (top/best/new) and optionally filter by topics", parameters: z.object({ section: z.enum(["top", "best", "new"]).default("top"), topics: z.array(z.string()).optional(), limit: z.number().int().min(1).max(20).default(5), }), handler: async ({ section, topics, limit }, { step }) => { if (STEEL_API_KEY === "your-steel-api-key-here") { throw new Error("Set STEEL_API_KEY"); } return await step?.run("browse-hn", async () => { const session = await client.sessions.create({}); const browser = await chromium.connectOverCDP( `${session.websocketUrl}&apiKey=${STEEL_API_KEY}` ); try { const context = browser.contexts()[0]; const page = context.pages()[0]; const base = "https://news.ycombinator.com"; const url = section === "best" ? `${base}/best` : section === "new" ? `${base}/newest` : base; await page.goto(url, { waitUntil: "domcontentloaded", timeout: 30000 }); const items = await page.evaluate((maxItems: number) => { const rows = Array.from(document.querySelectorAll("tr.athing")); const take = Math.min(maxItems * 2, rows.length); const out = [] as Array<{ rank: number; title: string; url: string; site: string | null; points: number; comments: number; itemId }>; for (let i = 0; i < take; i++) { const row = rows[i]; const titleEl = row.querySelector("span.titleline > a"); const siteEl = row.querySelector("span.sitebit > a"); const metadataRow = rows[i + 1]; const pointsEl = metadataRow?.querySelector("span.score"); const commentsEl = metadataRow?.querySelector("a[href*=\"item?id=\"]"); if (titleEl) { const title = titleEl.textContent; const url = titleEl.getAttribute("href"); const site = siteEl?.textContent; const points = parseInt(pointsEl?.textContent || "0", 10); const commentsMatch = commentsEl?.textContent?.match(/(\d+) comments?/); const comments = commentsMatch ? parseInt(commentsMatch[1], 10) : 0; if (title && url) { out.push({ rank: i + 1, title, url, site, points, comments, itemId: url.match(/id=(\d+)/)?.[1] || "", }); } } } return out; }, limit); const filtered = topics ? items.filter((it) => { const t = it.title.toLowerCase(); return topics.some((kw) => t.includes(kw.toLowerCase())); }) : items; const deduped: typeof filtered = []; const seen = new Set(); for (const it of filtered) { const key = `${it.title}|${it.url}`; if (!seen.has(key)) { seen.add(key); deduped.push(it); } if (deduped.length >= limit) break; } return deduped.slice(0, limit); } finally { // Always clean up cloud resources try { await browser.close(); } finally { await client.sessions.release(session.id); } } }); }, }); const hnAgent = createAgent({ name: "hn_curator", description: "Curates interesting Hacker News stories by topic", system: "Surface novel, high-signal Hacker News stories. Favor technical depth, originality, and relevance to requested topics. Use the tool to browse and return concise picks.", tools: [browseHackerNews], }); const hnNetwork = createNetwork({ name: "hacker-news-network", description: "Network for curating Hacker News stories", agents: [hnAgent], maxIter: 2, defaultModel: openai({ model: "gpt-4o-mini", }), }); async function main() { console.log("🚀 Steel + Agent Kit Starter"); console.log("=".repeat(60)); if (STEEL_API_KEY === "your-steel-api-key-here") { console.warn("⚠️ WARNING: Please replace 'your-steel-api-key-here' with your actual Steel API key"); console.warn(" Get your API key at: https://app.steel.dev/settings/api-keys"); return; } if (OPENAI_API_KEY === "your-openai-api-key-here") { console.warn("⚠️ WARNING: Please replace 'your-openai-api-key-here' with your actual OpenAI API key"); console.warn(" Get your API key at: https://platform.openai.com/api-keys"); return; } try { console.log("\nRunning HN curation..."); const run = await hnNetwork.run( "Curate 5 interesting Hacker News stories about AI, TypeScript, and tooling. Prefer 'best' if relevant. Return title, url, points." ); const results = (run as any).state?.results ?? []; console.log("\nResults:\n" + JSON.stringify(results, null, 2)); } catch (err) { console.error("An error occurred:", err); } finally { console.log("Done!"); } } main(); ``` -------------------------------- ### Complete main.py Example (Python) Source: https://context7_llms Provides the full Python script for the Steel and Notte integration, including imports, setup, task execution, and error handling. This is the complete code to run the quickstart example. ```python """ AI-powered browser automation using notte-sdk with Steel browsers. https://github.com/steel-dev/steel-cookbook/tree/main/examples/steel-notte-starter """ import os import time import asyncio from dotenv import load_dotenv from steel import Steel import notte load_dotenv() # Replace with your own API keys STEEL_API_KEY = os.getenv("STEEL_API_KEY") or "your-steel-api-key-here" GEMINI_API_KEY = os.getenv("GEMINI_API_KEY") or "your-gemini-api-key-here" async def main(): print("🚀 Steel + Notte Assistant") print("=" * 60) if STEEL_API_KEY == "your-steel-api-key-here": print("⚠️ WARNING: Please replace 'your-steel-api-key-here' with your actual Steel API key") print(" Get your API key at: https://app.steel.dev/settings/api-keys") return if GEMINI_API_KEY == "your-gemini-api-key-here": print("⚠️ WARNING: Please replace 'your-gemini-api-key-here' with your actual Gemini API key") print(" Get your API key at: https://console.cloud.google.com/apis/credentials") return print("\nStarting Steel browser session...") client = Steel(steel_api_key=STEEL_API_KEY) try: session = client.sessions.create() print("✅ Steel browser session started!") print(f"View live session at: {session.session_viewer_url}") print( f"\033[1;93mSteel Session created!\033[0m\n" f"View session at \033[1;37m{session.session_viewer_url}\033[0m\n" ) cdp_url = f"{session.websocket_url}&apiKey={STEEL_API_KEY}" start_time = time.time() TASK = os.getenv("TASK") or "Go to Wikipedia and search for machine learning" print(f"🎯 Executing task: {TASK}") print("=" * 60) try: with notte.Session(cdp_url=cdp_url) as notte_session: agent = notte.Agent( session=notte_session, max_steps=5, reasoning_model="gemini/gemini-2.0-flash" ) response = agent.run(task=TASK) duration = f"{(time.time() - start_time):.1f}" print("\n" + "=" * 60) print("🎉 TASK EXECUTION COMPLETED") print("=" * 60) print(f"⏱️ Duration: {duration} seconds") print(f"🎯 Task: {TASK}") if response: print(f"📋 Result:\n{response.answer}") print("=" * 60) except Exception as e: print(f"❌ Task execution failed: {e}") finally: if session: print("Releasing Steel session...") client.sessions.release(session.id) print(f"Session completed. View replay at {session.session_viewer_url}") print("Done!") except Exception as e: print(f"❌ Failed to start Steel browser: {e}") print("Please check your STEEL_API_KEY and internet connection.") if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Project Setup with npm and TypeScript Source: https://docs.steel.dev/integrations/agentkit/quickstart This bash script initializes a new TypeScript project, installs necessary dependencies including Steel SDK, AgentKit, and Playwright, and configures the start script. It also sets up a .env file for API keys. ```bash mkdir steel-agentkit-hn && \ cd steel-agentkit-hn && \ npm init -y && \ npm install -D typescript @types/node ts-node && \ npx tsc --init && \ npm pkg set scripts.start="ts-node index.ts" && \ touch index.ts .env npm install steel-sdk @inngest/agent-kit zod playwright dotenv ``` -------------------------------- ### Python: Install Dependencies and Setup Environment Source: https://docs.steel.dev/integrations/gemini-computer-use/quickstart-py This snippet demonstrates how to set up a Python virtual environment and install necessary packages for Steel LLM integration. It also shows how to configure API keys using a .env file. ```bash python -m venv venv source venv/bin/activate pip install steel-llm google-generativeai python-dotenv ``` ```text # .env file STEEL_API_KEY=your_steel_api_key GEMINI_API_KEY=your_gemini_api_key ``` ```python # utils.py import os from dotenv import load_dotenv load_dotenv() STEEL_API_KEY = os.getenv("STEEL_API_KEY") GEMINI_API_KEY = os.getenv("GEMINI_API_KEY") if not STEEL_API_KEY: raise ValueError("STEEL_API_KEY not found in .env file") if not GEMINI_API_KEY: raise ValueError("GEMINI_API_KEY not found in .env file") def get_steel_api_key(): return STEEL_API_KEY def get_gemini_api_key(): return GEMINI_API_KEY ``` -------------------------------- ### Project Setup Commands (Shell) Source: https://docs.steel.dev/integrations/agentkit/quickstart These shell commands set up a new TypeScript project for using AgentKit with Steel. They create a directory, initialize an npm project, install necessary development and runtime dependencies, configure TypeScript, and set up a start script. ```shell mkdir steel-agentkit-hn && \ cd steel-agentkit-hn && \ npm init -y && \ npm install -D typescript @types/node ts-node && \ npx tsc --init && \ npm pkg set scripts.start="ts-node index.ts" && \ touch index.ts .env npm install steel-sdk @inngest/agent-kit zod playwright dotenv ``` -------------------------------- ### Install Packages with Pip Source: https://docs.steel.dev/integrations/browser-use/quickstart Installs necessary packages for the Steel LLM integration. Ensure you have a virtual environment set up before running this command. ```bash pip install steel-sdk ``` -------------------------------- ### Initialize and Install Steel AgentKit Dependencies (Shell) Source: https://docs.steel.dev/integrations/agentkit/quickstart This command sequence initializes a new project directory for the Steel AgentKit, sets up npm, installs necessary development tools like TypeScript and ts-node, configures TypeScript, defines a start script for running with ts-node, and installs the core Steel SDK and agent kit dependencies. ```shell mkdir steel-agentkit-hn && cd steel-agentkit-hn && npm init -y && npm install -D typescript @types/node ts-node && npx tsc --init && npm pkg set scripts.start="ts-node index.ts" && touch index.ts .env npm install steel-sdk @inngest/agent-kit zod playwright dotenv ``` -------------------------------- ### Run the Steel Playwright Starter Example Source: https://docs.steel.dev/cookbook/playwright After setting up your API key, navigate to the example's directory and run the command to start the script. This will execute the automation defined in the example. ```shell npm start ``` -------------------------------- ### Install Dependencies with Pip Source: https://docs.steel.dev/cookbook/selenium Installs the necessary Python packages for the Steel and Selenium starter project using pip. This command reads from the 'requirements.txt' file. ```shell pip install -r requirements.txt ``` -------------------------------- ### Setup Project and Install Dependencies (Bash) Source: https://context7_llms Initializes a new Node.js project and installs necessary packages for using Claude Computer Use with Steel. Requires Node.js 20+ and API keys for Steel and Anthropic. ```bash mkdir steel-claude-computer-use cd steel-claude-computer-use npm init -y ``` -------------------------------- ### Python Project Setup and Dependencies Source: https://docs.steel.dev/integrations/openai-computer-use/quickstart-py Instructions for setting up a Python virtual environment and installing necessary packages. This is a prerequisite for running the agent. ```bash python -m venv venv source venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Install Dependencies with npm Source: https://docs.steel.dev/cookbook/playwright This command installs the necessary Node.js dependencies for the Steel + Playwright starter project. It assumes you have Node.js and npm installed. ```shell git clone https://github.com/steel-dev/steel-cookbook cd steel-cookbook/examples/steel-playwright-starter npm install ``` -------------------------------- ### Setup and Install Dependencies (Shell) Source: https://docs.steel.dev/cookbook/playwright-python This snippet outlines the steps to set up a Python virtual environment and install project dependencies using pip. It's crucial for ensuring the project runs with the correct package versions. ```shell python -m venv venv source venv/bin/activate # On Windows use: venv\\Scripts\\activate pip install -r requirements.txt ``` -------------------------------- ### Install Dependencies Source: https://docs.steel.dev/integrations/browser-use/quickstart Installs the necessary Python packages for Steel SDK and browser-use functionality. Ensure Python 3.11 or higher is installed. ```bash steel-sdk browser-use python-dotenv ``` -------------------------------- ### Install Steel SDK and Dependencies Source: https://docs.steel.dev/integrations/agno/quickstart Installs the Steel SDK, Python dotenv, and Playwright using the 'agno' package manager. This command sets up the essential libraries for interacting with Steel and managing environment variables. ```bash agno steel-sdk python-dotenv playwright ``` -------------------------------- ### Project Setup and Package Installation (Terminal) Source: https://docs.steel.dev/integrations/openai-computer-use/quickstart-ts This snippet details the terminal commands to create a new project directory, initialize a package.json file, and install the steel-sdk, dotenv, and TypeScript development dependencies. ```bash # Create a project directory mkdir steel-openai-computer-use cd steel-openai-computer-use # Initialize package.json npm init -y # Install required packages npm install steel-sdk dotenv npm install -D @types/node typescript ts-node ``` -------------------------------- ### Install Steel SDK with bun Source: https://docs.steel.dev/overview/sessions-api/quickstart This snippet shows the command to install the steel-sdk and playwright using the bun package manager. It assumes you have bun installed and configured. ```bash bun add steel-sdk playwright ``` -------------------------------- ### Set up Python Environment with Steel SDK Source: https://docs.steel.dev/integrations/browser-use/quickstart This snippet demonstrates setting up a Python virtual environment and installing necessary packages like steel-sdk, browser-use, and python-dotenv. It ensures the project has the required dependencies for interacting with Steel and browser automation. ```bash uv venv source .venv/bin/activate uv add steel-sdk browser-use python-dotenv ``` -------------------------------- ### Install Steel SDK with pnpm Source: https://docs.steel.dev/overview/sessions-api/quickstart This snippet shows the command to install the steel-sdk and playwright using the pnpm package manager. It assumes you have pnpm installed and configured. ```bash pnpm add steel-sdk playwright ``` -------------------------------- ### Install Steel SDK and Playwright (npm) Source: https://docs.steel.dev/overview/sessions-api/quickstart Installs the necessary Steel SDK and Playwright libraries using npm. These are the core dependencies for interacting with Steel sessions programmatically. ```bash npm install steel-sdk playwright ``` -------------------------------- ### Python LLM Configuration and Agent Initialization Source: https://docs.steel.dev/integrations/browser-use/quickstart This Python snippet shows the configuration of LLM parameters, including the model to be used and the temperature. It also demonstrates how to set up an API key for the LLM service. This is a foundational step before agent execution. ```python model, temperature, api_key = "gpt-4o", 0.3, OPENAI_API_KEY agent = Agent( task=TASK, llm=llm, browser_session=BrowserSession(cdp_url) ) ``` -------------------------------- ### Python Quickstart for Anthropic Claude Computer Use Source: https://docs.steel.dev/integrations/claude-computer-use/quickstart-py A basic Python quickstart guide for integrating Anthropic's Claude models, focusing on computer use capabilities. This example likely involves setting up the environment and making initial API calls. ```python # Python quickstart for Anthropic Claude computer use # (Code not provided in the input, this is a placeholder based on description) ``` -------------------------------- ### Setup and Configuration for Steel and OpenAI Source: https://docs.steel.dev/integrations/agentkit/quickstart Initializes the Steel SDK and OpenAI client, loads environment variables, and sets up API keys. It includes checks to ensure API keys are replaced with actual values before proceeding. ```typescript import dotenv from "dotenv"; dotenv.config(); import { z } from "zod"; import { chromium } from "playwright"; import Steel from "steel-sdk"; import { openai, createAgent, createNetwork, createTool, } from "@inngest/agent-kit"; // Replace with your own API keys const STEEL_API_KEY = process.env.STEEL_API_KEY || "your-steel-api-key-here"; const OPENAI_API_KEY = process.env.OPENAI_API_KEY || "your-openai-api-key-here"; const client = new Steel({ steelAPIKey: STEEL_API_KEY }); ``` -------------------------------- ### Terminal Commands for Steel.dev LLM Setup Source: https://docs.steel.dev/integrations/gemini-computer-use/quickstart-py These terminal commands are used to set up a Python virtual environment, activate it, and install the required packages for Steel.dev LLM integration. This includes the steel-sdk, google-genai, and python-dotenv libraries. ```bash uv venv source .venv/bin/activate uv add steel-sdk google-genai python-dotenv ``` -------------------------------- ### TypeScript: Create and Manage Steel SDK Sessions Source: https://docs.steel.dev/overview/sessions-api/quickstart This TypeScript example demonstrates how to initialize the Steel SDK client, create a new session, log its details, and then release the session. It requires the 'steel-sdk' and 'dotenv' packages, and an environment variable `STEEL_API_KEY`. ```typescript import Steel from 'steel-sdk'; import dotenv from 'dotenv'; dotenv.config(); const client = new Steel({ steelAPIKey: process.env.STEEL_API_KEY, }); async function main() { // Create a session const session = await client.sessions.create(); console.log('Session created:', session.id); console.log(`View live session at: ${session.sessionViewerUrl}`); // Your session is now ready to use! // When done, release the session await client.sessions.release(session.id); console.log('Session released'); } main().catch(console.error); ``` -------------------------------- ### Install ts-node for TypeScript Source: https://context7_llms Installs `ts-node` globally, which is required for running TypeScript examples with the Steel CLI. ```bash npm install -g ts-node ``` -------------------------------- ### Define and Run Agent with Task in Python Source: https://docs.steel.dev/integrations/browser-use/quickstart Shows the definition and execution of an agent in Python. It includes setting up the agent with a task, language model, and browser session, then running the agent and measuring execution time. ```python import time # Define the task for the agent task = os.getenv("TASK") or "Go to Wikipedia and search for machine learning" # Create the agent with the task, model, and browser session agent = Agent( task=task, llm=model, browser_session=browser_session ) async def main(): try: start_time = time.time() print(f"🎯 Executing task: {task}") print("=" * 60) # Run the agent result = await agent.run() duration = f"{(time.time() - start_time):.1f}" print("\n" + "=" * 60 ``` -------------------------------- ### Project Setup with npm and TypeScript Source: https://context7_llms Initializes a new TypeScript project using npm. Installs development dependencies like typescript, @types/node, and ts-node. Configures TypeScript compilation and sets up a start script for running TypeScript files with ts-node. Creates the main index.ts file and a .env file. ```bash mkdir steel-magnitude && \ cd steel-magnitude && \ npm init -y && \ npm install -D typescript @types/node ts-node && \ npx tsc --init && \ npm pkg set scripts.start="ts-node index.ts" && \ touch index.ts .env ``` -------------------------------- ### Set up Steel API Key Source: https://docs.steel.dev/cookbook/playwright Before running the example, you need to create a .env file and add your Steel API key. Replace 'your_api_key_here' with your actual API key obtained from Steel's website. ```shell STEEL_API_KEY=your_api_key_here ``` -------------------------------- ### Set Up Python Virtual Environment with Pip Source: https://docs.steel.dev/integrations/crewai/quickstart This section outlines the steps to create and activate a Python virtual environment using the 'venv' module and Pip. It then proceeds to install project dependencies. This is a standard approach for managing project dependencies in Python. ```shell python -m venv .venv source .venv/bin/activate pip install crewai[tools] steel-sdk python-dotenv pydantic ``` -------------------------------- ### Install Dependencies with npm Source: https://docs.steel.dev/cookbook/puppeteer This command installs the necessary Node.js dependencies for the Steel + Puppeteer starter project. It assumes you have Node.js and npm installed on your system. ```shell git clone https://github.com/steel-dev/steel-cookbook cd steel-cookbook/examples/steel-puppeteer-starter npm install ``` -------------------------------- ### Configure API Keys and Task Source: https://docs.steel.dev/integrations/browser-use/quickstart Sets up environment variables for Steel and OpenAI API keys, and defines the agent's task. This uses a .env file for secure storage of credentials. ```env STEEL_API_KEY=your_steel_api_key_here OPENAI_API_KEY=your_openai_api_key_here TASK=Go to Wikipedia and search for machine learning ``` -------------------------------- ### Python LLM Integration Setup with Pydantic Models Source: https://docs.steel.dev/integrations/stagehand/quickstart-py This Python code snippet sets up the necessary imports for interacting with LLMs, loading environment variables, and defining data models for structured output. It includes Pydantic models for 'Story' and 'Stories', specifying fields for title, rank, and a list of stories. Dependencies include asyncio, os, dotenv, pydantic, steel, and stagehand. ```python import asyncio import os from dotenv import load_dotenv from pydantic import BaseModel, Field from steel import Steel from stagehand import StagehandConfig, Stagehand # Load environment variables load_dotenv() # Get API keys from environment STEEL_API_KEY = os.getenv("STEEL_API_KEY") OPENAI_API_KEY = os.getenv("OPENAI_API_KEY") # Define data models for structured extraction class Story(BaseModel): title: str = Field(..., description="Story title") rank: int = Field(..., description="Story rank number") class Stories(BaseModel): stories: list[Story] = Field(..., description="List of top stories") ``` -------------------------------- ### Install Dependencies with uv Source: https://docs.steel.dev/integrations/stagehand/quickstart-py Installs the necessary Python packages: steel-sdk, stagehand, pydantic, and python-dotenv, using the 'uv' package manager. ```bash uv add steel-sdk stagehand pydantic python-dotenv ``` -------------------------------- ### Agent Initialization and Setup Source: https://docs.steel.dev/integrations/gemini-computer-use/quickstart-py Initializes the Agent class, setting up the client for content generation, Steel API integration, and browser-related configurations. It defines tools for browser interaction and content generation. ```python class Agent: def __init__(self): self.client = genai.Client(api_key=GEMINI_API_KEY) self.steel = Steel(steel_api_key=STEEL_API_KEY) self.session = None self.contents: List[Content] = [] self.current_url = "about:blank" self.viewport_width = 1280 self.viewport_height = 768 self.tools: List[Tool] = [ Tool( computer_use=types.ComputerUse( environment=types.Environment.ENVIRONMENT_BROWSER, ) ) ] self.config = GenerateContentConfig(tools=self.tools) ``` -------------------------------- ### Environment Variable Task Examples Source: https://docs.steel.dev/integrations/crewai/quickstart Examples of how to set the TASK environment variable to customize the crew's behavior. These examples demonstrate different objectives, such as summarizing API documentation, researching trends, or comparing frameworks. ```env TASK = "Visit https://docs.steel.dev and summarize the Sessions API lifecycle with citations." # or TASK = "Find the latest research trends in open-weights LLMs and produce a bullet summary with 5 sources." # or TASK = "Compare two AI agent frameworks and write a short pros/cons table with links." ``` -------------------------------- ### Create Steel Browser Session with Python Source: https://docs.steel.dev/integrations/browser-use/quickstart This Python code snippet demonstrates how to initialize the Steel SDK client using an API key and create a new browser session. It includes instructions for obtaining an API key and provides a link to the Steel dashboard. The output includes a URL to view the live browser session. ```python import os from steel import Steel from dotenv import load_dotenv # Load environment variables load_dotenv() STEEL_API_KEY = os.getenv("STEEL_API_KEY") or "your-steel-api-key-here" # Validate API key if STEEL_API_KEY == "your-steel-api-key-here": print("⚠️ WARNING: Please replace with your actual Steel API key") print(" Get your API key at: https://app.steel.dev/settings/api-keys") return # Create a Steel browser session client = Steel(steel_api_key=STEEL_API_KEY) session = client.sessions.create() print("✅ Steel browser session started!") print(f"View live session at: {session.session_viewer_url}") ``` -------------------------------- ### Clone Steel Cookbook Repository (Shell) Source: https://docs.steel.dev/cookbook/playwright-python This command clones the Steel Cookbook repository from GitHub, which contains example projects like the steel-playwright-python-starter. This is the first step to getting the example code. ```shell git clone https://github.com/steel-dev/steel-cookbook cd steel-cookbook/examples/steel-playwright-python-starter ``` -------------------------------- ### Python Environment Setup and API Key Configuration Source: https://docs.steel.dev/integrations/gemini-computer-use/quickstart-py This Python script sets up the environment for using Steel.dev and Gemini. It loads API keys from environment variables or uses default placeholders, defines the task, and specifies the Gemini model to be used. It also includes a helper function to format the current date. ```python import os import json from typing import List, Optional, Tuple, Dict, Any from datetime import datetime from dotenv import load_dotenv from steel import Steel from google import genai from google.genai import types from google.genai.types import ( Content, Part, FunctionCall, FunctionResponse, Candidate, FinishReason, Tool, GenerateContentConfig, ) load_dotenv(override=True) STEEL_API_KEY = os.getenv("STEEL_API_KEY") or "your-steel-api-key-here" GEMINI_API_KEY = os.getenv("GEMINI_API_KEY") or "your-gemini-api-key-here" TASK = os.getenv("TASK") or "Go to Steel.dev and find the latest news" MODEL = "gemini-2.5-computer-use-preview-10-2025" MAX_COORDINATE = 1000 def format_today() -> str: return datetime.now().strftime("%A, %B %d, %Y") ``` -------------------------------- ### Basic Steel Puppeteer Setup Source: https://docs.steel.dev/cookbook/puppeteer This snippet shows the fundamental setup for launching a browser instance with Steel and Puppeteer. It initializes the Steel configuration and launches a Chromium browser. ```javascript const steel = require("steel"); async function run() { const browser = await steel.launch({ headless: false, args: [ "--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage", "--disable-gpu", ], }); const page = await browser.newPage(); await page.goto("https://example.com"); // ... further actions await browser.close(); } run(); ``` -------------------------------- ### Python Setup and Configuration for Steel Stagehand Source: https://docs.steel.dev/integrations/stagehand/quickstart-py This Python script initializes Steel and Stagehand, loads environment variables, and configures API keys. It requires the 'steel', 'dotenv', and 'pydantic' libraries. The script defines Pydantic models for structured data and includes a main function to demonstrate usage. ```python import asyncio import os from dotenv import load_dotenv from pydantic import BaseModel, Field from steel import Steel from stagehand import StagehandConfig, Stagehand # Load environment variables load_dotenv() # Replace with your own API keys STEEL_API_KEY = os.getenv("STEEL_API_KEY") or "your-steel-api-key-here" OPENAI_API_API_KEY = os.getenv("OPENAI_API_KEY") or "your-openai-api-key-here" # Define Pydantic models for structured data extraction class Story(BaseModel): title: str = Field(..., description="Story title") rank: int = Field(..., description="Story rank number") class Stories(BaseModel): stories: list[Story] = Field(..., description="List of top stories") async def main(): print("🚀 Steel + Stagehand Python Starter") print("=" * 60) if STEEL_API_KEY == "your-steel-api-key-here": print("⚠️ WARNING: Please replace 'your-steel-api-key-here' with your actual Steel API key") ``` -------------------------------- ### Python: Initialize Steel Client and Create Session Source: https://docs.steel.dev/integrations/browser-use/quickstart This code initializes the Steel client using your API key and then creates a new browser session. It prints confirmation messages and provides a URL to view the live session. ```python from steel import Steel # Initialize Steel client client = Steel(steel_api_key=STEEL_API_KEY) try: # Create a new browser session session = client.sessions.create() print("✅ Steel browser session started!") print(f"View live session at:{session.session_viewer_url}") print(f"\nSteel Session created!\nView session at{session.session_viewer_url}\n") # CDP URL for direct connection cdp_url = f"wss://connect.steel.dev?apiKey={STEEL_API_KEY}&sessionId={session.id}" print(f"\n{cdp_url}\n") except Exception as e: print(f"Error creating Steel session: {e}") ``` -------------------------------- ### Run Async Main Function with Asyncio Source: https://docs.steel.dev/integrations/stagehand/quickstart-py Executes the `main()` asynchronous function using the asyncio event loop. This is the standard way to start an asyncio application. It handles loop creation, running the coroutine, and closing the loop. ```python import asyncio async def main(): print('Hello') await asyncio.sleep(1) print('World') if __name__ == '__main__ dapat: asyncio.run(main()) ``` -------------------------------- ### Install Dependencies Source: https://docs.steel.dev/integrations/gemini-computer-use/quickstart-py Installs the necessary Python packages: steel-sdk, google-genai, and python-dotenv. These are required for interacting with Steel and Google Gemini APIs and managing environment variables. ```bash steel-sdk google-genai python-dotenv ``` -------------------------------- ### Navigate to URL in Python Source: https://docs.steel.dev/integrations/gemini-computer-use/quickstart-py Navigates to a specified URL. It ensures the URL starts with 'http://' or 'https://', then simulates typing the URL into the address bar and pressing Enter. A short wait and screenshot are included. The function returns the screenshot and the updated current URL. ```python url = args.get("url", "") if not url.startswith(("http://", "https://")): url = "https://" + url self.steel.sessions.computer( self.session.id, action="press_key", keys=["Control", "l"], ) self.steel.sessions.computer( self.session.id, action="type_text", text=url, ) self.steel.sessions.computer( self.session.id, action="press_key", keys=["Enter"], ) self.steel.sessions.computer( self.session.id, action="wait", duration=2, ) self.current_url = url screenshot = self._take_screenshot() return screenshot, self.current_url ``` -------------------------------- ### Install Dependencies with npm Source: https://docs.steel.dev/integrations/agentkit/quickstart Installs the necessary packages for the Steel SDK, Inngest Agent Kit, Zod, Playwright, and Dotenv. These packages provide the core functionalities for building AI-powered applications. ```bash npm install steel-sdk @inngest/agent-kit zod playwright dotenv ``` -------------------------------- ### Install Dependencies with Poetry Source: https://docs.steel.dev/integrations/crewai/quickstart This snippet demonstrates how to add necessary dependencies to your project using Poetry. It includes crewai with tools, steel-sdk, python-dotenv, and pydantic. Ensure Poetry is installed and initialized in your project. ```shell poetry add crewai[tools] steel-sdk python-dotenv pydantic ``` -------------------------------- ### Add Steel SDK and Dependencies (poetry) Source: https://docs.steel.dev/integrations/agno/quickstart Installs the necessary Python packages for Agno, Steel SDK, and environment variable management using the 'poetry' package manager. This command should be run within an activated virtual environment. ```shell poetry add agno steel-sdk python-dotenv playwright ```