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.0.2.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.0.2-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: buildfunctions-0.0.2.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.0.2.tar.gz
Algorithm Hash digest
SHA256 ee6ec02644a70e76aa41ceb4b38d3f4d4924aefa2d8669640efea55e4c72aeff
MD5 f55e418275c30a1ca77d9183096b4545
BLAKE2b-256 62ac7a7de286bc35b0c1d4784fecf47f8bf548fb85e39ec8ec67b3e3e441453a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: buildfunctions-0.0.2-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.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 67cc3f046abec48f3cd182047bd5017240833ebe47e4a69b68a4d1e13875424e
MD5 6779a7a387fba350b2dd38c344ba860a
BLAKE2b-256 bd939be6e6f48ae18bc94bc14651179b107fdd6d57cea26d86015e766e3bc7c5

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