๐Ÿ’ก How to Launch Your First Sandbox with AgentBox

#1
by agentbox-master - opened

When working with AI models, you often need a quick, secure, and isolated environment to run experiments, test prompts, fine-tune logic, or integrate multiple models together.
AgentBox provides exactly that โ€” a cloud-based sandbox designed for AI developers.

๐Ÿš€ What is AgentBox?

AgentBox is a developer-oriented AI sandbox platform where you can:

  • Run and test LLMs with no local setup
  • Prototype agents and toolchains
  • Safely experiment in an isolated runtime
  • Avoid dependency conflicts on your machine

๐Ÿค Why combine Hugging Face + AgentBox?

You can discover a model on Hugging Face and immediately try it inside AgentBox โ€” no configuration, GPU drivers, or dependency setup required.

โœ… Getting Started (in 3 steps)

  1. Visit AgentBox Official Website
  2. Sign up and create your API Key
  3. Run your first model / prompt / agent inside the sandbox

Startup time is just a few seconds.

Example:

# pip install agentbox-python-sdk
from huggingface_hub import InferenceClient
from agentbox import Sandbox
import re

def match_code_block(llm_response: str) -> str:
    """
    Extract python code inside a markdown code block.
    Robust against variations like:
    ```python
    ...
    ```
    or just
    ```
    ...
    ```
    """
    pattern = re.compile(r"```(?:python)?\n(.*?)```", re.DOTALL | re.IGNORECASE)
    match = pattern.search(llm_response)
    if match:
        return match.group(1).strip()
    return ""

system_prompt = """You are a helpful coding assistant that can execute python code in a Jupyter notebook.
You are given tasks to complete and you run Python code to solve them.

Rules:
- ALWAYS FORMAT YOUR RESPONSE IN MARKDOWN
- ALWAYS RESPOND ONLY WITH CODE IN A CODE BLOCK LIKE THIS:
\`\`\`python
{code}
\`\`\`
"""
prompt = "Generate the first 15 Fibonacci numbers."

# Initialize the client
client = InferenceClient(
    provider="hf-inference",
    api_key="hf_......"
)

completion = client.chat.completions.create(
    model="xxx/xxx", # Or use any other model from Hugging Face
    messages=[
        {"role": "system", "content": system_prompt},
        {"role": "user", "content": prompt},
    ]
)

content = completion.choices[0].message.content
code = match_code_block(content)

sandbox = Sandbox(
    api_key="ab_......",
    domain="agentbox.cloud",
    template="template_id"
)
execution = sandbox.commands.run(code)
print(execution)

๐ŸŒ Try AgentBox

๐Ÿ‘‰ Start your first sandbox here:
AgentBox Official Website

agentbox-logo-64-64

Sign up or log in to comment