cpuos

Integration · Agent framework

LlamaIndex with cpuos sandboxes

Give a LlamaIndex FunctionAgent a code execution tool that runs in a cpuos microVM, next to your RAG tools.

SDK
@cpuos/sdk · pip install cpuos
Model endpoint
https://gpuos.si/v1 or any OpenAI-compatible
Status
Early access

A FunctionAgent with a sandbox tool

LlamaIndex agents accept plain Python functions as tools and read the docstring as the tool description. Retrieval answers questions about your documents; the sandbox computes anything the documents do not state directly.

Install
pip install llama-index llama-index-llms-openai-like cpuos
agent.py
import asyncioimport osfrom cpuos import Sandboxfrom llama_index.core.agent.workflow import FunctionAgentfrom llama_index.llms.openai_like import OpenAILikellm = OpenAILike(    model="qwen3-32b",    api_base="https://gpuos.si/v1",    api_key=os.environ["GPUOS_API_KEY"],    is_chat_model=True,    is_function_calling_model=True,    context_window=32768,)sbx = Sandbox.create(template="python", timeout="30m")def run_python(code: str) -> str:    """Run a Python 3 script in an isolated sandbox. Files live in /work.    Returns the exit code, stdout and stderr."""    sbx.files.write("/work/main.py", code)    run = sbx.exec("cd /work && python main.py", timeout="2m")    return f"exit_code={run.exit_code}\n{run.stdout[-4000:]}\n{run.stderr[-2000:]}"agent = FunctionAgent(    tools=[run_python],    llm=llm,    system_prompt="Use run_python for any calculation. Files are in /work.",)async def main():    print(await agent.run("What is the compound growth of 1,000 at 4% over 17 years?"))    sbx.pause()asyncio.run(main())

The examples point the model at gpuOS, which serves open models on your own GPUs at https://gpuos.si/v1 with an OpenAI-compatible API. Any other OpenAI-compatible provider works the same way: change the base URL, the key and the model name.

cpuos is in early access: @cpuos/sdk (npm) and cpuos (PyPI) ship to early-access teams first, and read the API key from CPUOS_API_KEY. The calls on this page show the current API shape.

Official documentation: www.llamaindex.ai

Questions

Why is_function_calling_model=True?
OpenAILike does not know which models support tool calling. The flag tells FunctionAgent to send tools in the OpenAI format, which models like Qwen3 handle.
Can the agent analyze files from my index?
Yes. Write the source file into /work with files.write before the run, or give the agent a tool that does it, then let it load the file in Python.
Does the sandbox see my vector store?
No. Retrieval runs in your process; the sandbox only receives the code and files you send it. That keeps your index credentials out of the sandbox.

Related

Run LlamaIndex tool calls in a sandbox

cpuos is in early access: a Firecracker microVM per task, hosted in the EU or on your servers, billed per second and free while paused.

gpuOS · where models think

Need the model too? Run it on gpuOS

gpuOS serves open models on your own GPUs behind one OpenAI-compatible API. The model reasons on gpuOS, the agent acts in a cpuOS sandbox.