Skip to content

aliyun/wuying-agentbay-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PyPI Downloads NPM Downloads Go Report Card License

AgentBay

The Cloud Sandbox Built for AI Agents
Browser Β· Desktop Β· Mobile Β· Code


πŸ“¦ Installation

Language Install Command Documentation
Python pip install wuying-agentbay-sdk Python Docs
TypeScript npm install wuying-agentbay-sdk TypeScript Docs
Golang go get github.com/aliyun/wuying-agentbay-sdk/golang/pkg/agentbay Golang Docs

πŸš€ Prerequisites

Before using the SDK, you need to:

  1. Register an Alibaba Cloud account: https://aliyun.com
  2. Get APIKEY credentials: AgentBay Console
  3. Set environment variable:
    • For Linux/MacOS:
      export AGENTBAY_API_KEY=your_api_key_here
    • For Windows:
      setx AGENTBAY_API_KEY your_api_key_here

πŸš€ Quick Start

Python (Sync)

from agentbay import AgentBay, CreateSessionParams

# Create session and execute code
agent_bay = AgentBay()
session = agent_bay.create(CreateSessionParams(image_id="code_latest")).session
result = session.code.run_code("print('Hello AgentBay')", "python")
if result.success:
    print(result.result)  # Hello AgentBay

# Clean up
agent_bay.delete(session)

Python (Async)

import asyncio
from agentbay import AsyncAgentBay, CreateSessionParams

async def main():
    # Create session and execute code
    agent_bay = AsyncAgentBay()
    session = (await agent_bay.create(CreateSessionParams(image_id="code_latest"))).session
    result = await session.code.run_code("print('Hello AgentBay')", "python")
    if result.success:
        print(result.result)  # Hello AgentBay

    # Clean up
    await agent_bay.delete(session)

if __name__ == "__main__":
    asyncio.run(main())

TypeScript

import { AgentBay } from 'wuying-agentbay-sdk';

// Create session and execute code
const agentBay = new AgentBay();
const session = (await agentBay.create({ imageId: "code_latest" })).session;
const result = await session.code.runCode("print('Hello AgentBay')", "python");
if (result.success) {
    console.log(result.result);  // Hello AgentBay
}

// Clean up
await agentBay.delete(session);

Golang

import "github.com/aliyun/wuying-agentbay-sdk/golang/pkg/agentbay"

// Create session and execute code
client, _ := agentbay.NewAgentBay("", nil)
result, _ := client.Create(agentbay.NewCreateSessionParams().WithImageId("code_latest"))
session := result.Session

res, _ := session.Code.RunCode("print('Hello AgentBay')", "python")
fmt.Println(res.Output)  // Hello AgentBay

// Clean up
client.Delete(session, false)

πŸ”„ Python Sync vs Async API

AgentBay Python SDK provides both synchronous and asynchronous APIs to suit different application needs.

Feature Sync API (AgentBay) Async API (AsyncAgentBay)
Import from agentbay import AgentBay from agentbay import AsyncAgentBay
Best for Scripts, simple tools, CLI apps Web servers (FastAPI/Django), high-concurrency apps
Blocking Yes, blocks thread until complete No, allows other tasks to run
Usage client.create(...) await client.create(...)

🎯 Use Cases

Browser Use

🌐 Browser Use

Automate web operations including content scraping, testing, and workflows. Cross-browser compatible with natural language control and remote access.

Learn more β†’

Computer Use

πŸ–₯️ Computer Use

Cloud desktop environment for enterprise application automation. Standardized interfaces enable legacy software automation with intelligent resource scheduling.

Learn more β†’

Mobile Use

πŸ“± Mobile Use

Cloud-based mobile environment for intelligent app automation. Precise UI recognition and control with parallel task processing for testing scenarios.

Learn more β†’

Code Space

πŸ’» Code Space

Professional cloud development environment supporting multi-language code generation, compilation, and debugging. Secure, intelligent automated programming experience.

Learn more β†’

πŸ“š Documentation

Complete Documentation - Full guides, tutorials, and API references

πŸ‘‹ Choose Your Learning Path

πŸ†• New Users - If you're new to AgentBay or cloud development:

πŸš€ Experienced Users - Already familiar with browser automation, computer use, mobile testing, or cloud development environments:

πŸ”§ Core Features

πŸŽ›οΈ Session Management

  • Session Creation & Lifecycle - Create, manage, and delete cloud environments
  • Environment Configuration - Configure SDK settings, regions, and endpoints
  • Session Monitoring - Monitor session status and health validation

πŸ› οΈ Common Modules

  • Command Execution - Execute Shell commands in cloud environments
  • File Operations - Upload, download, and manage cloud files
  • Data Persistence - Save and retrieve data across sessions
  • Context Management - Synchronize data and maintain state

🎯 Scenario-Based Features

  • Computer Use - General automation and desktop operations
  • Browser Use - Web automation, scraping, and browser control
  • CodeSpace - Code execution and development environment
  • Mobile Use - Mobile device simulation and control

πŸ€– AI-Assisted Development

If you're using AI coding assistants (Claude, Cursor, GitHub Copilot, etc.) to develop with AgentBay SDK, you can use llms.txt and llms-full.txt as context for better code suggestions:

  • llms.txt - Concise documentation index (~900 tokens) for quick reference
  • llms-full.txt - Complete documentation corpus (~140k tokens) for comprehensive context

These files contain the full SDK documentation across all languages (Python, TypeScript, Golang), API references, and cookbook examples. Simply reference them in your AI assistant to get better understanding of the SDK's architecture and APIs.

πŸ†˜ Get Help

πŸ“ž Contact

Welcome to visit our product website and join our community!

πŸ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.