Getting Started

Installation

Install the AI Computer Python client using pip:

1pip install ai-computer-client

Quick Start

Here's a simple example to get you started with AI Computer:

1import asyncio
2from ai_computer import SandboxClient
3
4async def main():
5    # Initialize the client
6    client = SandboxClient()
7    
8    # Setup the client (gets token and creates sandbox)
9    setup_response = await client.setup()
10    if not setup_response.success:
11        print(f"Setup failed: {setup_response.error}")
12        return
13    
14    try:
15        # Simple code execution
16        code = """
17x = 10
18y = 20
19result = x + y
20print(f"The sum is: {result}")
21"""
22        response = await client.execute_code(code)
23        if response.success:
24            print("Output:", response.data['output'])
25        else:
26            print("Execution failed:", response.error)
27    
28    finally:
29        # Clean up
30        await client.cleanup()
31
32if __name__ == "__main__":
33    asyncio.run(main())

Key Features

  • Secure sandbox environment for Python code execution
  • Asynchronous API for efficient operations
  • Real-time streaming of code output
  • Automatic resource cleanup
  • Built-in error handling and timeouts

Next Steps

  • Learn about core concepts like sandboxes and execution models in the Core Concepts guide
  • Explore the API Reference for detailed documentation
  • Check out Examples for common use cases and patterns