Your first model¶
Train one model from your backend, from uploading a dataset to a deployed endpoint. The calls are the same on hosted Arena and on a self-hosted tenant; only the host and key change. The Partner API reference has every field of every call.
Before you start¶
You need an API host and an organisation key. On hosted Arena, AgileRL issues both. On a self-hosted tenant, your operator gives you the tenant’s host and key.
Value |
Hosted |
Self-hosted |
|---|---|---|
Host |
|
|
Key |
|
|
Every request sends the key and the ID your product uses for the person making the request:
Authorization: Bearer arena_org_8c1f…_Qx7…
X-External-User-Id: customer-user-17
export ARENA_BASE="https://arena.agilerl.com" # or your tenant's host
export ARENA_ORG_KEY="arena_org_8c1f…_Qx7…"
export ARENA_USER="customer-user-17"
Use the same X-External-User-Id for the same person on every call. Arena creates a matching user the first time it sees an ID.
Keep the key on your backend. Never send it to a browser.
1. See what you can train on¶
curl -sS "$ARENA_BASE/api/cli/v1/resources" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER"
{
"ok": true,
"data": {
"gpuTypes": [
{ "gpuType": "b300", "gpusPerNode": [8], "numGpus": [8] }
]
}
}
This also confirms the key works. Submit takes a gpuType from the list as gpu_type, and one of its numGpus as num_gpus; both are optional. On a self-hosted tenant the list holds only the tenant’s own GPUs, and Arena charges nothing for the GPUs themselves, so price them in your own product. The tenant’s platform fee (byocFee in the self-hosted reference, $2 per run-hour by default) still applies, and submit shows it as Estimated cost.
2. Upload a dataset¶
curl -sS "$ARENA_BASE/api/cli/v1/datasets/create" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
-F "name=support-tickets-sft" -F "category=sft" \
-F 'column_mapping={"prompt":"instruction","target":"response"}' \
-F "file=@./train.parquet;type=application/vnd.apache.parquet"
Training can start once the reply has "is_ready": true. column_mapping maps Arena’s column names to yours; the categories and their columns are in Data.
On a self-hosted tenant the stored file can be at most 64 MiB, and datasets from Hugging Face return 400 huggingface_offline because the tenant can’t reach the internet. Upload the file instead.
3. Create a project and pick a base model¶
curl -sS "$ARENA_BASE/api/cli/v1/projects/create" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
-H "Content-Type: application/json" -d '{"name":"support-bot"}'
curl -sS "$ARENA_BASE/api/cli/v1/models" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER"
/models lists the base models you can train. On a self-hosted tenant those are the ones your operator registered (Base models). Use a model_name from the list exactly as written:
export ARENA_MODEL="qwen3.5-9b"
4. Get training settings and check them¶
curl -sS -G "$ARENA_BASE/api/cli/v1/experiments/run-spec/default" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
--data-urlencode "algorithm=SFT" \
--data-urlencode "datasetName=support-tickets-sft" \
--data-urlencode "pretrainedModelNameOrPath=$ARENA_MODEL" > run-spec.json
Change what your product exposes, for example algorithm.lr, network.max_context_length or training.max_steps. network.max_context_length is a power of 2 from 1024 up to the model’s maximum. Leave training.max_steps unset to train one pass over the dataset. Then ask Arena whether the run fits:
curl -sS "$ARENA_BASE/api/cli/v1/experiments/validate-run-spec" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
-H "Content-Type: application/json" -d @run-spec.json
If it doesn’t fit, the reply is 400 run_does_not_fit, with what the run needs and what is available (Check a run fits). Show it to your user with a suggestion: a smaller model, a shorter context, or a smaller batch.
5. Start training¶
curl -sS -N "$ARENA_BASE/api/cli/v1/experiments/jobs/submit" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
-H "Content-Type: application/json" \
-d '{"project":"support-bot","experiment_name":"support-bot-v1","manifest":'"$(cat run-spec.json)"'}'
Arena picks the GPUs from the run’s memory estimate. The reply streams one JSON object per line and ends with "status":"completed" (accepted) or "status":"failed" (with a reason). experiment_name is the handle for every later call.
6. Track status¶
curl -sS "$ARENA_BASE/api/cli/v1/experiments/list?project=support-bot" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER"
|
Meaning |
What your product shows |
|---|---|---|
|
Accepted; the GPUs are busy. Starts on its own, in submit order. |
Waiting for GPUs |
|
GPUs assigned, workers starting |
Starting |
|
Training |
Progress from metrics |
|
A stop call is taking effect |
Stopping |
|
Stopped by a stop call |
Stopped |
|
Finished |
Ready to download or deploy |
|
Stopped with an error |
The row’s |
Each row also has status_label, the text Arena shows for the run while it waits or starts. You never need to retry a queued job.
7. Show metrics, stop and resume¶
curl -sS -G "$ARENA_BASE/api/cli/v1/experiments/metrics" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
--data-urlencode "experiment_name=support-bot-v1"
curl -sS -X POST "$ARENA_BASE/api/cli/v1/experiments/jobs/stop" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
-H "Content-Type: application/json" -d '{"experiment_name":"support-bot-v1"}'
curl -sS "$ARENA_BASE/api/cli/v1/experiments/jobs/resume" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
-H "Content-Type: application/json" \
-d '{"experiment_name":"support-bot-v1","checkpoint":"final","new_name":"support-bot-v1-more","max_steps":2000}'
Metrics update while the job runs. A stop takes effect within seconds. A resume’s max_steps counts from the start of the original run, so it must be greater than the checkpoint’s step.
8. Download the trained model¶
List checkpoints, then ask for download links for one of them:
curl -sS -G "$ARENA_BASE/api/cli/v1/experiments/jobs/checkpoints" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
--data-urlencode "experiment_name=support-bot-v1"
curl -sS -X POST "$ARENA_BASE/api/internal/partners/checkpoint-exports" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
-H "Content-Type: application/json" \
-d '{"experimentName":"support-bot-v1","steps":500}'
500 is a steps value from the checkpoint list. A model over 32 MiB comes back with state queued or running and no links yet. Poll the same route with GET until state is complete:
curl -sS -G "$ARENA_BASE/api/internal/partners/checkpoint-exports" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
--data-urlencode "experimentName=support-bot-v1" \
--data-urlencode "steps=500"
Each urls[] entry is {key, url, expiresAt} and lasts about 15 minutes. Check each file against files[].sha256 and files[].bytes for the same key. The files are a Hugging Face model (config.json, tokenizer, .safetensors). Renewing expired links and resuming a download are in Download the trained model.
9. Deploy the model¶
curl -sS "$ARENA_BASE/api/cli/v1/inference/deploy" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
-H "Content-Type: application/json" -d '{"experimentName":"support-bot-v1","name":"support-bot"}'
curl -sS -G "$ARENA_BASE/api/cli/v1/inference/deployments/one" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
--data-urlencode "name=support-bot"
The deployment is ready when its status is Deployed. Its url takes POST <url>/generate, or POST <url>/generate_stream to stream the reply, as described in the inference contract. A session_id keeps one conversation’s history together:
DEPLOYMENT_URL="https://…" # url from deployments/one
curl -sS "$DEPLOYMENT_URL/generate" \
-H "Authorization: Bearer $ARENA_ORG_KEY" -H "X-External-User-Id: $ARENA_USER" \
-H "Content-Type: application/json" \
-d '{"session_id":"ticket-4411","prompts":["My order has not arrived."],"params":{"max_new_tokens":256}}'
On a self-hosted tenant url is https://<host>/api/deployments/<id>/inference, and this call works with the organisation key (Calling the deployed model). On hosted Arena the inference server doesn’t yet accept an organisation key, so this last call is refused there. Contact AgileRL if your product needs to call deployments on hosted Arena.
On a self-hosted tenant the deployment runs on the tenant’s GPUs, under the tenant’s domain. While it runs, those GPUs aren’t available for training, so new runs may wait as Queued. Take a deployment offline with PATCH /api/cli/v1/inference/deployments and "enabled": false, or remove it with DELETE (Deploy the model).
Python¶
The same steps from Python, after uv add agilerl (or pip install agilerl):
from agilerl import ArenaClient
ArenaClient.configure(base_url="https://arena.tenant-a.internal")
client = ArenaClient(org_key=key, external_user_id="customer-user-17")
client.create_dataset(
name="support-tickets-sft",
category="sft",
file="./train.parquet",
column_mapping={"prompt": "instruction", "target": "response"},
)
The Python section of the reference lists every method.