> docs / quickstart
Quickstart
Deploy an open model, call it with any OpenAI client, and give it a loop that tunes it overnight. About ten minutes.
Overview
Everything on Looping Labs is an app made of models, training runs, sandboxes and routes. Any of them can have a loop: an objective, guardrails and a search space that an agent explores for you. Results from every loop land in the ledger.
Install
pip install looping
This installs the Python SDK and the ll command line tool. Python 3.10 or later.
Authenticate
ll login # opens your browser
export LL_API_KEY=... # or use a key in CI
Deploy a model
import looping as ll
app = ll.App("support-assistant")
@app.model(
gpu="H200",
engine="auto", # the inference loop picks vLLM, SGLang or TRT-LLM
autoscale=ll.Autoscale(min=1, max=16, target_concurrency=48),
)
class Assistant:
weights = "Qwen/Qwen3-32B"
@app.loop(
objective=ll.minimize("cost_per_mtok"),
guards=[ll.p95_latency("< 300ms"), ll.eval("support-golden", min_score=0.92)],
canary=0.05,
)
def tune(): ...
# $ ll deploy app.py
ll deploy app.py
The first deploy starts from the best known config in the ledger for this model and GPU. You get an endpoint URL and a model name.
Call it
# any OpenAI client works. point it at LL Control.
from openai import OpenAI
client = OpenAI(
base_url="https://api.loopinglabs.dev/v1",
api_key=os.environ["LL_API_KEY"],
)
resp = client.chat.completions.create(
model="qwen3-32b",
messages=[{"role": "user", "content": "Summarise this ticket"}],
extra_body={
"ll": {
"route": "cheapest-within-slo",
"budget": "team:support",
"guardrails": ["pii-redact"],
}
},
)
The ll block is optional. Without it, requests go straight to the model you name.
Add a loop
A loop needs three things: an objective to improve, guards that must hold, and a canary fraction for trying changes. In the example above, @app.loop minimises cost per million tokens while p95 latency stays under 300 ms and the eval score stays above 0.92.
ll loops log support-assistant --since 24h
ll loops pause support-assistant # stop trying new configs
ll loops pin support-assistant iter-0414 # lock a known-good config
Fine-tune
import looping as ll
run = ll.training.finetune(
base="Qwen/Qwen3-8B",
data="s3://acme-data/support/train.jsonl",
method=ll.LoRA(rank=32),
gate=ll.eval("support-golden", min_score=0.92),
loop=ll.Sweep(lr=[1e-4, 2e-4], epochs=[2, 3], budget_gpu_hours=40),
)
best = run.best() # highest eval score that passed the gate
best.promote(endpoint="support-assistant", canary=0.05)
# RL with a verifier
ll.training.rl(
base=best,
algorithm="grpo",
reward="rewards.py:resolved_ticket",
)
Run a sandbox
import looping as ll
sb = ll.Sandbox.create(
image="python:3.12",
cpu=2, memory="4Gi",
egress=["pypi.org", "files.pythonhosted.org"],
timeout="15m",
)
sb.files.write("/work/solution.py", agent_code)
result = sb.exec("pytest -q /work")
if result.exit_code != 0:
snap = sb.snapshot() # keep the failing state
forks = [snap.fork() for _ in range(4)] # try 4 fixes in parallel
sb.terminate()
Route with Control
# control.yaml
routes:
support:
strategy: cheapest-within-slo
slo: { p95_ms: 800, eval: support-golden >= 0.92 }
candidates: [qwen3-32b, gpt-oss-120b, llama-3.3-70b]
fallback: gpt-oss-120b
guardrails: [pii-redact, prompt-injection]
budgets:
team:support: { monthly_usd: 20000, alert_at: 0.8 }
team:research: { monthly_usd: 5000, hard_stop: true }
telemetry:
otel_endpoint: https://otel.acme.internal:4317
ll control apply control.yaml
Python SDK
Main objects: ll.App, @app.model, @app.loop, ll.training, ll.Sandbox, ll.control. Every call is also available over REST.
CLI
# install and sign in
$ pip install looping
$ ll login
# deploy an open model in one line
$ ll deploy Qwen/Qwen3-32B --gpu H200 --autoscale 1:16
✓ endpoint https://api.loopinglabs.dev/v1 (model: qwen3-32b)
✓ loop inference · objective cost_per_mtok · guard p95 < 300ms
# see what the loops changed overnight
$ ll loops log qwen3-32b --since 24h
iter 0412 sglang bs=96 fp8 spec=eagle KEEP
iter 0413 trt-llm bs=96 fp8 spec=eagle ROLLBACK
iter 0414 sglang bs=96 fp8+kv8 KEEP
# fire up a sandbox for an agent
$ ll sandbox run --image python:3.12 --timeout 15m
MCP server
# let your coding agent drive the platform
# ~/.config/agent/mcp.json
{
"mcpServers": {
"looping": {
"url": "https://mcp.loopinglabs.dev",
"headers": { "Authorization": "Bearer $LL_API_KEY" }
}
}
}
# tools exposed to the agent
deploy_model get_endpoint_metrics start_training_run
run_sandbox read_loop_ledger set_budget
Give a coding agent these tools and it can deploy, test and tune models on your behalf, inside the budgets and permissions of its API key.