|
1 | | -# Runloop Python API library |
| 1 | +# Runloop Python SDK — secure sandboxes for AI agents |
2 | 2 |
|
3 | 3 | <!-- prettier-ignore --> |
4 | 4 | [)](https://pypi.org/project/runloop_api_client/) |
5 | 5 |
|
6 | | -The Runloop Python library provides convenient access to the Runloop REST API from any Python 3.9+ |
7 | | -application. The library includes type definitions for all request params and response fields, |
8 | | -and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx). |
| 6 | +Run AI agents and AI-generated code in **Devboxes**: isolated Linux sandboxes with a shell, a |
| 7 | +filesystem, networking, and optional GPUs. Use this library to create a sandbox, run commands in it, |
| 8 | +read and write files, expose ports over HTTPS, and snapshot the whole machine so you can pause and |
| 9 | +resume it later. |
9 | 10 |
|
10 | | -It is generated with [Stainless](https://www.stainless.com/). |
| 11 | +Why teams pick Runloop: |
11 | 12 |
|
12 | | -## Documentation |
13 | | - |
14 | | -The REST API documentation can be found on |
15 | | -[runloop.ai](https://runloop.ai). The full API of this library can be found in |
16 | | -[api.md](https://github.com/runloopai/api-client-python/blob/main/api.md). |
| 13 | +- **Safe by default.** Every devbox is isolated at both the VM and container level, so untrusted |
| 14 | + agent output never touches your infrastructure. |
| 15 | +- **Built for long-running agents.** Devboxes persist for as long as you need, and snapshots let you |
| 16 | + suspend, resume, and branch an agent's machine state. |
| 17 | +- **Fast starts.** Blueprints bake your dependencies into a reusable image so agents boot in seconds |
| 18 | + instead of installing tooling every run. |
| 19 | +- **Ready for production.** Secrets injection, AI gateways, network policies, and VPC deployment are |
| 20 | + part of the platform. |
| 21 | +- **Measurable.** Built-in benchmarks and evaluations score agent runs so you can tell whether a |
| 22 | + change actually helped. |
17 | 23 |
|
18 | 24 | ## Installation |
19 | 25 |
|
20 | 26 | ```sh |
21 | | -# install from PyPI |
22 | 27 | pip install runloop_api_client |
23 | 28 | ``` |
24 | 29 |
|
25 | | -## Usage |
26 | | - |
27 | | -The full API of this library can be found in [api.md](api.md). |
28 | | - |
29 | | -### Object-Oriented SDK |
| 30 | +## Quickstart |
30 | 31 |
|
31 | | -For a higher-level, Pythonic interface, check out the new [`RunloopSDK`](README-SDK.md) which layers an object-oriented API on top of the generated client (including synchronous and asynchronous variants). |
| 32 | +Set `RUNLOOP_API_KEY` in your environment ([get a free key](https://runloop.ai) — new accounts start |
| 33 | +with $50 in credits), then: |
32 | 34 |
|
33 | 35 | ```python |
34 | 36 | from runloop_api_client import RunloopSDK |
35 | 37 |
|
36 | 38 | runloop = RunloopSDK() # Uses RUNLOOP_API_KEY environment variable by default |
37 | 39 |
|
38 | | -# Create a devbox and execute commands with a clean, object-oriented interface |
| 40 | +# Create a sandbox, run a command in it, and clean it up on exit. |
39 | 41 | with runloop.devbox.create(name="my-devbox") as devbox: |
40 | | - result = devbox.cmd.exec("echo 'Hello from Runloop!'") |
| 42 | + devbox.file.write(file_path="main.py", contents="print('hello from a sandbox')") |
| 43 | + result = devbox.cmd.exec("python main.py") |
41 | 44 | print(result.stdout()) |
42 | 45 | ``` |
43 | 46 |
|
44 | | -**See the [SDK documentation](README-SDK.md) for complete examples and API reference.** |
| 47 | +**See the [SDK documentation](README-SDK.md) for complete examples and API reference**, and |
| 48 | +[docs.runloop.ai](https://docs.runloop.ai) for platform guides. Agents and LLM tooling can read |
| 49 | +[llms.txt](llms.txt) for a condensed overview of the whole platform. |
| 50 | + |
| 51 | +## Documentation |
| 52 | + |
| 53 | +- [Platform documentation](https://docs.runloop.ai) — devboxes, blueprints, snapshots, tunnels, agents, benchmarks |
| 54 | +- [`RunloopSDK` reference](README-SDK.md) — the high-level, object-oriented Python interface |
| 55 | +- [api.md](https://github.com/runloopai/api-client-python/blob/main/api.md) — the full generated REST surface |
| 56 | +- [examples/](examples) — runnable end-to-end scripts |
| 57 | +- [llms.txt](llms.txt) — condensed platform summary for AI coding agents |
| 58 | + |
| 59 | +## Usage |
| 60 | + |
| 61 | +This library ships two layers: the object-oriented `RunloopSDK` shown above, and the generated REST |
| 62 | +client it is built on. Both have synchronous and asynchronous variants, include type definitions for |
| 63 | +all request params and response fields, and are powered by |
| 64 | +[httpx](https://github.com/encode/httpx). The generated client is produced with |
| 65 | +[Stainless](https://www.stainless.com/). |
45 | 66 |
|
46 | 67 | ### REST API Client |
47 | 68 |
|
48 | | -Alternatively, you can use the generated REST API client directly: |
| 69 | +To use the generated REST API client directly: |
49 | 70 |
|
50 | 71 | ```python |
51 | 72 | import os |
|
0 commit comments