> ## Documentation Index
> Fetch the complete documentation index at: https://buildfunctions.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK Quickstart - Docs

> Deploy with the Buildfunctions SDK

## Get Started

<Steps>
  <Step title="First Install">
    <CodeGroup>
      ```bash npm theme={null}
      npm install buildfunctions
      ```

      ```bash yarn theme={null}
      yarn add buildfunctions
      ```

      ```bash pnpm theme={null}
      pnpm add buildfunctions
      ```

      ```bash pip theme={null}
      pip install buildfunctions
      ```
    </CodeGroup>

    <Note>Mojo coming soon! 🔥</Note>
  </Step>

  <Step title="Create an API token">
    Create an API token at [https://www.buildfunctions.com/settings](https://www.buildfunctions.com/settings)

    <img src="https://mintcdn.com/buildfunctions/bQ7hppAN1Ity-0di/assets/images/dashboard_settings.jpeg?fit=max&auto=format&n=bQ7hppAN1Ity-0di&q=85&s=07e6c0cc9a4f8d9c90f1ef79940154d8" alt="Web Dashboard" width="1438" height="1029" data-path="assets/images/dashboard_settings.jpeg" />
  </Step>

  <Step title="Authenticate">
    Write your agent app code and authenticate with the Buildfunctions SDK:

    <CodeGroup dropdown>
      ```javascript theme={null}
      ...
      const apiToken = process.env.BUILDFUNCTIONS_API_TOKEN
      if (!apiToken) {
        return new NextResponse('Missing BUILDFUNCTIONS_API_TOKEN', { status: 500 })
      }

      // Authenticate with a Buildfunctions API token
      await Buildfunctions({ apiToken })
      ...
      ```
    </CodeGroup>
  </Step>

  <Step title="Create a GPU Sandbox and run inference">
    <CodeGroup dropdown>
      ```javascript theme={null}
      ...
      // Create a GPU Sandbox with Python and PyTorch
      const sandbox = await GPUSandbox.create({
        name: 'secure-agent-action',
        memory: '50000MB',
        gpu: 'T4G',
        timeout: 1200, // 24 hours max
        language: 'python', // language available within sandbox
        code: inferenceCode, // inline code or path to file
        requirements: ['transformers', 'torch', 'accelerate'], // python dependencies
        model: '/path/to/models/Qwen/Qwen3-8B', // path to folder with models can be local or remote (e.g., Hugging Face)
      })

      // Run inference within hardware-isolated VM (full GPU access)
      const result = await sandbox.run()
      ...

      ```

      ```python theme={null}
      ...
      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()
      ...

      ```
    </CodeGroup>
  </Step>

  <Step title="Add Runtime Controls">
    Help keep your agent running unattended. Runtime Controls wrap function calls with composable guardrails — no API key required.

    <CodeGroup dropdown>
      ```javascript theme={null}
      import { RuntimeControls } from 'buildfunctions'

      const controls = RuntimeControls.create({
        maxToolCalls: 50,
        timeoutMs: 30_000,
        retry: { maxAttempts: 3, initialDelayMs: 200, backoffFactor: 2 },
        loopBreaker: { warningThreshold: 5, quarantineThreshold: 8, stopThreshold: 12 },
        onEvent: (event) => console.log(`[controls] ${event.type}: ${event.message}`),
      })

      const guardedFetch = controls.wrap({
        toolName: 'api-call',
        runKey: 'agent-run-1',
        destination: 'https://api.example.com',
        run: async ([payload]) => {
          const res = await fetch('https://api.example.com/data', {
            method: 'POST',
            body: JSON.stringify(payload),
          })
          return res.json()
        },
      })

      const result = await guardedFetch({ query: 'latest results' })

      // Reset budget counters when starting a new run
      await controls.reset('agent-run-1')
      ```
    </CodeGroup>

    Works standalone or combined with Buildfunctions hardware-isolated sandboxes. For backend-specific integrations, validate behavior with your own integration tests. See the full [Runtime Controls](/docs/runtime-controls) docs for all control layers.
  </Step>
</Steps>

<Note>
  Buildfunctions is currently in its beta stage. If you encounter any issues or have specific syntax requirements, please reach out and [contact us](https://www.buildfunctions.com/contact), and we’ll work to address them.
</Note>
