Skip to main content

The Buildfunctions SDK for Agents: Hardware-isolated CPU and GPU Sandboxes for untrusted AI actions

Project description

logo

The Buildfunctions SDK for Agents

 

logo

Hardware-isolated execution environments for AI agents

Installation

pip install buildfunctions

Quick Start

1. Create an API Token

Get your API token at buildfunctions.com/settings

2. CPU Function

import asyncio
import os
from buildfunctions import Buildfunctions, CPUFunction

async def main():
    client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})

    deployed_function = await CPUFunction.create({
        "name": "my-cpu-function",
        "code": "./cpu_function_code.py",
        "language": "python",
        "memory": 128,
        "timeout": 30,
    })

    print(f"Endpoint: {deployed_function.endpoint}")

    await deployed_function.delete()

asyncio.run(main())

3. CPU Sandbox

import asyncio
import os
from buildfunctions import Buildfunctions, CPUSandbox

async def main():
    client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})

    sandbox = await CPUSandbox.create({
        "name": "my-cpu-sandbox",
        "language": "python",
        "code": "/path/to/code/cpu_sandbox_code.py",
        "memory": 128,
        "timeout": 30,
    })

    result = await sandbox.run()
    print(f"Result: {result}")

    await sandbox.delete()

asyncio.run(main())

4. GPU Function

import asyncio
import os
from buildfunctions import Buildfunctions, GPUFunction

async def main():
    client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})

    deployed_function = await GPUFunction.create({
        "name": "my-gpu-function",
        "code": "/path/to/code/gpu_function_code.py",
        "language": "python",
        "gpu": "T4",
        "vcpus": 30,
        "memory": "50000MB",
        "timeout": 300,
        "requirements": ["transformers==4.47.1", "torch", "accelerate"],
    })

    print(f"Endpoint: {deployed_function.endpoint}")

    await deployed_function.delete()

asyncio.run(main())

5. GPU Sandbox with Local Model

import asyncio
import os
from buildfunctions import Buildfunctions, GPUSandbox

async def main():
    client = await Buildfunctions({"apiToken": os.environ["BUILDFUNCTIONS_API_TOKEN"]})

    sandbox = await GPUSandbox.create({
        "name": "my-gpu-sandbox",
        "language": "python",
        "memory": 10000,
        "timeout": 300,
        "vcpus": 6,
        "code": "./gpu_sandbox_code.py",
        "model": "/path/to/models/Qwen/Qwen3-8B",
        "requirements": "torch",
    })

    result = await sandbox.run()
    print(f"Response: {result}")

    await sandbox.delete()

asyncio.run(main())

The SDK is currently in beta.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

buildfunctions-0.2.1.tar.gz (4.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

buildfunctions-0.2.1-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file buildfunctions-0.2.1.tar.gz.

File metadata

  • Download URL: buildfunctions-0.2.1.tar.gz
  • Upload date:
  • Size: 4.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0rc1

File hashes

Hashes for buildfunctions-0.2.1.tar.gz
Algorithm Hash digest
SHA256 5cf97e2de14483385c86e1a3ddfb40fd0ee5f6a8896ffd9c380808e03ae06b63
MD5 822a7da8a662bdec07fe047e17e1c2c8
BLAKE2b-256 b3b1a205fc5f2a9daa9b0494989723f4bf1ffe1d2d54fc75f1a714a2c740f254

See more details on using hashes here.

File details

Details for the file buildfunctions-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: buildfunctions-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0rc1

File hashes

Hashes for buildfunctions-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 147e797a7c3bcc36d623d532f290d9b8a496fe808cbd2fe73f55f9a8ea2d018a
MD5 a5fa4219c3c94fc4109a78c2202e5178
BLAKE2b-256 fbf93dd6a7bcba364c584a4c3d98f659cfb4d829a9cc72b39b06a1a73e995a34

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page