Skip to content

Use casesYour own harness

Keep the loop you wrote. Run it on our parts.

Point your own agent loop at the gateway, give it a sandbox to run code in, and read every model call back with what it cost.

Your loop, with routing, limits and traces you did not build.

The build

From your loop to a traced run, in five steps

  1. Install the SDK and make a client

    Create an API key in the console and give the client your gateway's address. This client is the only new thing in your loop.

    loop.py
    # pip install everstack
    import os
    from everstack import Everstack
    
    client = Everstack(
        base_url=os.environ["EVERSTACK_BASE_URL"],
        api_key=os.environ["EVERSTACK_API_KEY"],
    )
  2. Run the loop on any model

    The loop is yours: call a model, run the tools it asks for, go round again. Name the model in the request and the gateway finds its provider.

    loop.py
    messages = [{"role": "user", "content": "Summarise sales by region."}]
    
    while True:
        reply = client.chat.completions.create(
            model="@anthropic/claude-sonnet-4-5",
            messages=messages,
            tools=TOOLS,
        ).choices[0].message
        if not reply.tool_calls:
            break
        messages.append(reply.model_dump(exclude_none=True))
        messages += run_tools(reply.tool_calls)
  3. Create a sandbox for its code

    One call makes an isolated machine with the CPU and memory you ask for.

    loop.py
    sandbox = client.agents.sandboxes.create(
        name="loop-workspace",
        cpu_limit=1,
        memory_mb=1024,
    )
  4. Run the model's tool calls there

    When the model asks to run code, send the command to the sandbox instead of running it on your own machine. This one is a plain request: the SDK does not wrap it yet.

    loop.py
    import requests
    
    def run_in_sandbox(sandbox_id: str, command: str):
        return requests.post(
            f"{os.environ['EVERSTACK_BASE_URL']}/v1/sandbox/{sandbox_id}/command",
            headers={"Authorization": f"Bearer {os.environ['EVERSTACK_API_KEY']}"},
            json={"command": command},
        ).json()
    
    run_in_sandbox(SANDBOX_ID, "python analyse.py orders.csv")
  5. Read the run back

    Every model call the loop made is recorded with its tokens, latency and cost. Open it in the console.

Good to know

Before you start

The gateway also speaks the OpenAI chat completions and Responses APIs, so a loop built on an OpenAI client works by changing its base URL.

The Python and Node SDKs create and manage sandboxes. Running a command and reading files are HTTP routes today.

Your provider bills you for inference. Everstack records the tokens and cost of each call.

Put Everstack in front of your next request

Run it yourself in a few minutes, or start on Everstack Cloud with your own provider keys.

Star on GitHubOpen source under Apache 2.0. A star helps others find it.