Python client¶
The ArenaClient class, the inference Agent for calling deployed agents, and the errors they raise. The page is generated from the docstrings of the agilerl version Arena currently supports. To set up credentials, see Install and sign in.
- class ArenaClient(*, api_key=None, org_key=None, external_user_id=None, request_timeout=30, upload_timeout=300, verbose=True)¶
Client for the Arena RLOps platform.
Handles authentication, environment management, and training job submission.
Authentication is resolved in priority order:
org_key plus external_user_id (constructor or
ARENA_ORG_KEY/ARENA_EXTERNAL_USER_ID). SendsAuthorization: Bearer <org key>andX-External-User-Id.api_key constructor argument
ARENA_API_KEYenvironment variableStored OAuth credentials from
~/.arena/credentials.jsonInteractive
login()(device authorization flow)
For PAT / OAuth credentials, the value is sent as
Authorization: Bearer <value>. Use a personal access token from your Arena account profile (arena_pat_<uuid>_<secret>) to skip OAuth device login. You can also pass a Keycloak access token in the same way if you obtain one elsewhere. Organisation keys (arena_org_…) are for partner servers and must be paired with an external user id.- Parameters:
api_key (str | None) – Bearer token material (profile PAT or OAuth access token). When set, device login is not required.
org_key (str | None) – Organisation API key (
arena_org_…). Requires external_user_id.external_user_id (str | None) – Partner user id sent as
X-External-User-Id. Requires org_key.request_timeout (int) – Default timeout in seconds for API requests.
upload_timeout (int) – Timeout in seconds for file uploads and cluster register.
verbose (bool) – Whether to enable verbose logging.
- Returns:
None
- Return type:
None
ArenaClient¶
Sign-in and account¶
- classmethod ArenaClient.configure(*, base_url=None, keycloak_url=None, realm=None, client_id=None)¶
Override default URLs for local development or testing.
An explicit
base_url/keycloak_urltakes precedence over theARENA_BASE_URL/ARENA_KEYCLOAK_URLenvironment variables.Returns the class so calls can be chained with instantiation:
client = ArenaClient.configure( base_url="http://localhost:3001", keycloak_url="http://localhost:8023", )()
- Parameters:
base_url (str | None)
keycloak_url (str | None)
realm (str | None)
client_id (str | None)
- Return type:
type[ArenaClient]
- ArenaClient.login(timeout=300)¶
Sign in through the browser, then end the previously saved login.
Only one login is kept in
~/.arena/credentials.json, so this is also how to switch user or environment. Organisation-key credentials skip it. An API key stays on this client until the browser sign-in succeeds.- Parameters:
timeout (int) – Maximum seconds to wait for browser authorization.
- Return type:
None
- ArenaClient.logout()¶
End the saved login and remove stored credentials.
- Return type:
None
- property ArenaClient.is_authenticated: bool¶
Truewhen the client holds an org key, API key, or access token.
- ArenaClient.get_current_user()¶
Get the authenticated user’s profile details.
Includes account fields such as email and name. When the Arena server exposes them, the payload may also contain entitlement flags (e.g. enterprise / BYOC access) relevant to CLI feature gating.
- Return type:
dict[str, Any]
- ArenaClient.get_user_credits()¶
Get the authenticated user’s credit information.
- Return type:
None | bool | int | float | str | list[JSONValue] | dict[str, JSONValue]
- ArenaClient.get_credit_balance()¶
Get the active organization’s balance and its accrued, uncharged cost.
- Returns:
balance(spendable credits),accrued_cost(run up by running jobs and deployments but not charged yet),balance_after_accruedandaccrued, one entry per running item withkind,id,experiment_id,name,since,hourly_costandaccrued_cost.- Return type:
dict[str, Any]
- Raises:
ArenaAPIError – With status 404 from an Arena server without accrued cost.
- ArenaClient.get_credit_ledger(*, job_id=None, deployment_id=None, limit=None)¶
List the active organization’s charges and credits, newest first.
- Parameters:
job_id (int | None) – Only charges for this job.
deployment_id (int | None) – Only charges for this deployment.
limit (int | None) – Most entries to return (the server caps it at 1000).
- Returns:
Entries with
time,kind,job_id,deployment_id,experiment_id,item,description,amount(negative for charges) andbalance(after the entry).- Return type:
list[dict[str, Any]]
- Raises:
ArenaAPIError – With status 404 from an Arena server without the ledger.
- ArenaClient.close()¶
Close the underlying HTTP connection pool.
- Return type:
None
Projects¶
- ArenaClient.list_projects()¶
List all projects in Arena for the authenticated user.
- Returns:
A list of projects.
- Return type:
list[dict[str, Any]]
- ArenaClient.create_project(name, description=None, llm_based=True)¶
Create a new LLM project in Arena.
- Parameters:
name (str) – The name of the project to create.
description (str | None) – The description of the project to create.
llm_based (bool) – Accepted for agilerl-arena 1.x callers; must be True.
- Returns:
A dictionary containing the project creation result.
- Return type:
dict[str, Any]
- Raises:
ArenaValidationError – When
llm_basedis False.
- ArenaClient.delete_project(name)¶
Delete a project in Arena.
- Parameters:
name (str) – The name of the project to delete.
- Return type:
None
- ArenaClient.get_default_project()¶
Return the default project name from
~/.arena/config.json, or None if unset.- Return type:
str | None
- ArenaClient.set_default_project(name)¶
Validate that name exists and persist it as the default project.
- Parameters:
name (str) – The project name to set as default.
- Raises:
ArenaConfigError – If the project does not exist.
- Return type:
None
Environments¶
- ArenaClient.list_environments(name=None, include_arena=False)¶
List environments available to the authenticated user.
- Parameters:
name (str | None) – Environment name. If None, list all environments.
include_arena (bool) – Whether to include the built-in environments available in Arena.
- Returns:
A nested dictionary keyed by environment name, then version:
{ "<name>": { "<version>": { "validated": True, } } }
- Return type:
dict[str, dict[str, dict[str, bool]]]
- ArenaClient.environment_exists(name, version=None)¶
Check whether an environment name/version is registered.
- Parameters:
name (str) – Environment name.
version (str | None) – Environment version. Defaults to None, which resolves to the latest version.
- Returns:
True if the environment exists, False otherwise.
- Return type:
bool
- ArenaClient.list_environment_entrypoints(name, version=None)¶
List available entrypoints for an environment version.
- Parameters:
name (str) – Environment name, as specified in Arena.
version (str | None) – Environment version. Defaults to None, which resolves to the latest version.
- Returns:
A list of entrypoints.
- Return type:
list[str]
- ArenaClient.validate_environment(*, name, version=None, source=None, env_config=None, requirements=None, entrypoint=None, description=None, do_rollouts=False)¶
Validate a custom GEM environment on Arena.
When source is provided the environment is uploaded, created, and validated in a single step. When source is None an already-registered environment is validated by name/version.
- Parameters:
name (str) – Environment name.
version (str | None) – Environment version. If creating an environment from scratch, defaults to “v1”, if validating an already-registered environment, defaults to None, which resolves to the latest version.
source (str | os.PathLike[str] | bytes | None) – Environment source — a directory path (compressed automatically), a
.tar.gzfile path, or rawbytes.env_config (str | os.PathLike[str] | None) – Path to the environment configuration file containing the environment parameters. When source is a directory and this is None, a top-level
env_config.yaml,env_config.yml, orenv_config.json(in that order) is picked up automatically. Default is None.requirements (str | os.PathLike[str] | None) – Path to additional dependencies needed for the environment. When source is a directory and this is None, a top-level
requirements.txtis picked up automatically. Default is None.entrypoint (str | None) – Optional entrypoint override. Default is None.
description (str | None) – Optional description of the environment. Default is None.
do_rollouts (bool) – Whether to also run sample episodes against the environment and include them in the result. Default is False.
- Returns:
A dictionary containing the validation result.
- Return type:
dict[str, Any]
- ArenaClient.delete_environment(*, name, version=None, confirm=False)¶
Delete an environment version (or all versions if version is None).
- Parameters:
name (str) – Environment name, as specified in Arena.
version (str | None) – Environment version. If None, delete all environment versions.
confirm (bool) – Whether to confirm the deletion.
- Return type:
dict[str, Any] | None
- ArenaClient.duplicate_environment_version(*, name, new_version, version=None)¶
Duplicate a custom environment version to a new version name.
- Parameters:
name (str) – Environment name.
new_version (str) – New
versionfor the duplicate (e.g.v2).version (str | None) – Source version; when omitted, the latest version is used.
- Return type:
dict[str, Any]
Datasets¶
- ArenaClient.list_datasets(*, search=None)¶
List datasets or search HuggingFace datasets.
- Parameters:
search (str | None) – HuggingFace dataset search query.
- Returns:
List of datasets or search results from Arena.
- Return type:
list[dict[str, Any]]
- ArenaClient.dataset_exists(name)¶
Check whether a dataset name is registered for the active org.
- Parameters:
name (str) – Dataset name.
- Returns:
exists, anddatasetTypewhen the name is registered.- Return type:
dict[str, bool | str]
- ArenaClient.create_dataset(*, name, category, column_mapping=None, description=None, file=None, config=None, hf_dataset_name=None, hf_config=None, hf_split=None)¶
Create an LLM dataset on Arena.
Upload a local CSV, a parquet file, a Hugging Face parquet folder, import from HuggingFace, or create metadata only. Validation is performed by the Arena API; a local
tracesfile is also checked against the traces spec before upload.- Parameters:
name (str) – Dataset name.
category (str) – Dataset category (
reasoning,preference,sft, ortraces).column_mapping (str | dict[str, Any] | None) – Column mapping as a JSON string or dict. Required except for
traces, whose column names are the spec.description (str | None) – Optional description.
file (str | os.PathLike[str] | bytes | None) – Local CSV, JSONL or parquet path, a directory of parquet shards, or raw CSV bytes (bytes are uploaded as
dataset.csv).config (str | None) – Parquet config name when file is a folder with more than one config (e.g. gsm8k
mainvssocratic).hf_dataset_name (str | None) – HuggingFace dataset id for import.
hf_config (str | None) – HuggingFace dataset config name.
hf_split (str | None) – HuggingFace split (required when importing from HF).
- Returns:
Created dataset metadata from Arena.
- Return type:
dict[str, Any]
- Raises:
ArenaValidationError – If a
tracesfile breaks the spec.
- ArenaClient.delete_dataset(name, *, confirm=False)¶
Archive a dataset by name.
- Parameters:
name (str) – Dataset name.
confirm (bool) – When
True, skip the interactive confirmation prompt.
- Returns:
Archive result, or
Noneif the user declined confirmation.- Return type:
dict[str, Any] | None
Models and GPUs¶
- ArenaClient.list_models()¶
List HuggingFace models in the Arena catalog.
- Returns:
Catalog rows including
model_name,num_params,lora_info,max_context_length,lora_ranks, andenabled.- Return type:
list[dict[str, Any]]
- ArenaClient.get_model_info(model_name)¶
Fetch LoRA modules and catalog metadata for a model.
- Parameters:
model_name (str) – HuggingFace model id as stored in the catalog.
- Returns:
modules,parameters,lora_info,num_params,max_context_length, andlora_ranks.- Return type:
dict[str, Any]
- ArenaClient.list_resources(algorithm=None)¶
List the GPU types and GPU counts a submit accepts.
Each
gpuTypeis a valueArenaClient.submit_experimentaccepts asgpu_type, and each of itsnumGpusa value fornum_gpus. An older platform returns resourcetiersinstead.- Parameters:
algorithm (str | None) – The run’s
algorithm.name. Arena then lists only the GPU counts that algorithm trains on: a GRPO-family run generates on its own GPU, so it needs at least two. Without it the list is for LLM training and includes single GPUs.- Returns:
{"gpuTypes": [{"gpuType": str, "gpusPerNode": list[int], "numGpus": list[int], "devOnly": bool}]}.- Return type:
dict[str, Any]
- ArenaClient.estimate_memory(manifest, gpu=None, device_gb=None, num_gpus=None, gpus_per_node=None)¶
Size a training manifest’s GPU memory on one device.
- Parameters:
manifest (dict[str, Any]) – The raw manifest document.
gpu (str | None) – GPU type from
arena resources list, or a GPU name.device_gb (float | None) – GPU memory in GiB; overrides the GPU’s when both are set.
num_gpus (int | None) – GPUs in the allocation, for the engine layout the run picks.
gpus_per_node (int | None) – GPUs on one node;
Noneputs allnum_gpuson one.
- Returns:
The exit code (0 fits, 3 over budget, 2 usage error) and report.
- Return type:
MemoryEstimate
- ArenaClient.solve_memory(manifest, field, gpu=None, device_gb=None, num_gpus=None, hi=None)¶
Solve the largest value of one manifest setting that fits on one device.
- Parameters:
manifest (dict[str, Any]) – The raw manifest document.
field (str) – The setting to solve; only
max_model_len.gpu (str | None) – GPU type from
arena resources list, or a GPU name.device_gb (float | None) – GPU memory in GiB; overrides the GPU’s when both are set.
num_gpus (int | None) – GPUs on the node, for the engine layout the run picks.
hi (int | None) – Search ceiling; the checkpoint’s RoPE limit also caps it.
- Returns:
The exit code (0 solved, 3 nothing fits, 2 usage error) and report.
- Return type:
MemoryEstimate
Experiments¶
- ArenaClient.get_default_run_spec(algorithm, *, env_name=None, env_version=None, env_entrypoint=None, dataset_name=None, field=None, pretrained_model_name_or_path=None)¶
Fetch a default RunSpec for an algorithm.
fieldreturns one section instead of the full spec.- Parameters:
algorithm (str) – Catalog algorithm name.
env_name (str | None) – Arena environment name.
env_version (str | None) – Environment version. Required with
env_entrypoint(v1and1are both accepted).env_entrypoint (str | None) – Environment entrypoint.
dataset_name (str | None) – Dataset name.
field (str | None) – RunSpec section to return (
algorithm,environment,network,replay_buffer, ortraining).pretrained_model_name_or_path (str | None) – HuggingFace model name in the catalog.
- Returns:
A filled RunSpec, or one section when
fieldis set.- Return type:
dict[str, Any]
- Raises:
ArenaValidationError – When
algorithmis a classic RL algorithm.
- ArenaClient.quote_experiment(manifest, *, num_gpus=None, gpu_type=None, project=None, experiment_name=None, reward_file=None, completion=None)¶
Price an experiment without starting it.
Arena runs the submit checks and picks the class exactly as
submit_experiment()would, then stops before creating anything.Arguments match
submit_experiment().- Returns:
resource_id,resource_name,gpu_type,num_gpus,num_nodes,hourly_cost(credits per hour),max_steps,step_seconds,estimated_hoursandestimated_cost. The last two areNonewhen Arena has no duration estimate.reward_errorsays why the reward fails the checksubmit_experiment()runs, elseNone.- Return type:
dict[str, Any]
- Raises:
ArenaAPIError – With status 404 from an Arena server that cannot price a run before it starts.
- Parameters:
manifest (str | Path | dict[str, Any])
num_gpus (int | None)
gpu_type (str | None)
project (str | None)
experiment_name (str | None)
reward_file (str | PathLike[str] | bytes | None)
completion (str | None)
- ArenaClient.submit_experiment(manifest, *, num_gpus=None, gpu_type=None, project=None, experiment_name=None, reward_file=None, completion=None, idempotency_key=None)¶
Submit an experiment (a training job).
- Parameters:
manifest (str | Path | dict[str, Any]) – Training manifest as a YAML/JSON file path, raw YAML string, or a pre-parsed dict.
num_gpus (int | None) – Total GPUs for the job. Arena uses the fewest nodes that fit the run’s memory estimate.
gpu_type (str | None) – Short GPU name such as
h100-80,b200orl4.project (str | None) – The project to submit the experiment to.
experiment_name (str | None) – The name of the experiment to submit.
reward_file (str | os.PathLike[str] | bytes | None) – Python rubric or reward module scoring a rollout job. When set, the request is sent as
multipart/form-dataand a rollout manifest withoutenvironment.rubric_file_pathgets the file’s basename (reward.pyfor bytes).completion (str | None) – Optional model completion for reward validation. When omitted, the server uses the reference answer from the first dataset row.
idempotency_key (str | None) – Reuse this key to replay the same submit instead of starting another job. The key is org-wide.
- Raises:
ArenaValidationError – When
num_gpusis below 1, the manifest turns on HPO, or the manifest’s rubric path names a different file thanreward_file, or a local file whenreward_fileis unset.- Return type:
dict[str, Any]
- ArenaClient.list_experiments(project=None)¶
List all experiments in a project.
- Parameters:
project (str | None) – The name of the project. Falls back to the default project from
~/.arena/config.jsonif not provided.- Returns:
A list of experiments.
- Return type:
list[dict[str, Any]]
- ArenaClient.get_experiment_status(experiment_name, project=None)¶
Return an experiment’s status and, when it failed, why.
- Parameters:
experiment_name (str) – Experiment name (latest match in scope).
project (str | None) – Project, when the experiment name exists in more than one.
- Returns:
experiment_name,status,failure_reason(Noneunless the run failed) andlast_modified.- Return type:
dict[str, Any]
- ArenaClient.get_experiment_logs(experiment_name, *, tail=None, after=None, limit=None, level=None, project=None)¶
Return one page of an experiment’s training logs (the web Log view).
- Parameters:
experiment_name (str) – Experiment name (latest match in scope).
tail (int | None) – Return the newest
taillines (1-1000). Not withafter.after (int | None) – Return lines after this line
timestamp(Unix microseconds), oldest first. Pass the previous page’snext_after.limit (int | None) – Lines per page when not tailing (1-1000, server default 500).
level (Literal["info", "warning", "error"] | None) – Lowest severity to return.
project (str | None) – Project, when the experiment name exists in more than one.
- Returns:
The status fields of
get_experiment_status()pluslines(timestamp,severity,message,event_type),next_afterandhas_more.- Return type:
dict[str, Any]
- ArenaClient.iter_experiment_logs(experiment_name, *, tail=None, follow=False, level=None, project=None, poll_interval=5.0)¶
Yield pages of an experiment’s training logs until there are no more.
With
follow, keep polling while the experiment is pending or running, and stop once it has ended and a poll brings no new lines.- Parameters:
experiment_name (str) – Experiment name (latest match in scope).
tail (int | None) – Start with the newest
taillines instead of the first line.follow (bool) – Keep polling for new lines while the experiment runs.
level (Literal["info", "warning", "error"] | None) – Lowest severity to return.
project (str | None) – Project, when the experiment name exists in more than one.
poll_interval (float) – Seconds between polls when following.
- Returns:
Pages as returned by
get_experiment_logs(); the last one carries the finalstatusandfailure_reason.- Return type:
Iterator[dict[str, Any]]
- ArenaClient.set_stream_handler(handler)¶
Register a callback invoked for each
StreamEventduring streaming.Set to
Noneto clear the handler.- Parameters:
handler (Callable[[StatusEvent | CheckEvent | ErrorEvent | LogEvent], None] | None)
- Return type:
None
- ArenaClient.stop_experiment(experiment_name, project=None)¶
Stop a running experiment in Arena.
- Parameters:
experiment_name (str) – Experiment name to halt.
project (str | None) – Project, when the experiment name exists in more than one.
- Return type:
None | bool | int | float | str | list[JSONValue] | dict[str, JSONValue]
- ArenaClient.quote_resume(experiment_name, max_steps=None, checkpoint=None, new_name=None, project=None)¶
Price a resume without starting it.
A resume runs on the experiment’s own hardware. Arguments match
resume_experiment().- Returns:
The fields
quote_experiment()returns, for the steps left between the checkpoint andmax_stepson that hardware.- Return type:
dict[str, Any]
- Raises:
ArenaAPIError – With status 404 from an Arena server that cannot price a resume before it starts.
- Parameters:
experiment_name (str)
max_steps (int | None)
checkpoint (str | None)
new_name (str | None)
project (str | None)
- ArenaClient.resume_experiment(experiment_name, max_steps=None, checkpoint=None, new_name=None, project=None)¶
Resume an experiment (a training job).
- Parameters:
experiment_name (str) – The name of the experiment to resume.
max_steps (int | None) – Total training steps, counted from the start of the original run; must be greater than the checkpoint’s step. Omit to keep the stored total.
checkpoint (str | None) – Checkpoint to resume from. Omit to use the best checkpoint.
new_name (str | None) – Name for the resumed experiment.
project (str | None) – Project, when the experiment name exists in more than one.
- Returns:
A dictionary containing the resume result.
- Return type:
dict[str, Any]
- ArenaClient.list_checkpoints(experiment_name, project=None)¶
List all checkpoints for an experiment.
- Parameters:
experiment_name (str) – The name of the experiment to list checkpoints for.
project (str | None) – Project, when the experiment name exists in more than one.
- Returns:
A list of checkpoints.
- Return type:
list[dict[str, Any]]
- ArenaClient.list_experiment_metric_names(experiment_name, *, project=None, details=False)¶
List metric catalog rows recorded for an experiment (JSON).
For a CSV preview with
--metric/--preview-rows-style filters, usepreview_experiment_metrics_csv().- Parameters:
experiment_name (str) – Experiment name (latest updated match in scope).
project (str | None) – Optional exact project name in the current org.
details (bool) – When True, the API returns
{\"metrics\": […catalog…]}.
- Returns:
Catalog rows
{display_name, category}, or that object whendetailsis True.- Return type:
list[dict[str, Any]] | dict[str, Any]
- ArenaClient.preview_experiment_metrics_csv(experiment_name, *, preview_rows, metrics=None, project=None)¶
Fetch a capped CSV snippet (Arena CLI
--metric/--preview-rows).Uses
GET /api/cli/v1/experiments/metricswithpreview_rowsset. Omitmetricsto include all columns.- Parameters:
experiment_name (str) – Experiment name (latest match in scope).
preview_rows (int) – Maximum number of data rows in the CSV (server-capped).
metrics (Sequence[str] | None) – Metric column names to include (repeat query param
metric).project (str | None) – Optional exact project name.
- Returns:
A tuple of the metrics payload, content type, and disposition.
- Return type:
tuple[bytes, str | None, str | None]
- ArenaClient.download_experiment_metrics(experiment_name, output_path=None, metrics=None, project=None, overwrite=False)¶
Download experiment metrics to a local file.
- Parameters:
experiment_name (str) – The name of the experiment to download metrics for.
output_path (str | os.PathLike[str] | None) – Destination file path or directory. If a directory, the filename is inferred from the server response. Defaults to
{experiment_name}_metrics.csvin the current directory.metrics (list[str] | None) – The metrics to download. If None, download all metrics.
project (str | None) – Project name; defaults to the saved default project.
overwrite (bool) – Replace the file at the resolved output path if it exists.
- Returns:
The path to the written file.
- Return type:
Path
- Raises:
FileExistsError – If the resolved output path is a directory, or is an existing file and
overwriteis False.NotADirectoryError – If the parent path exists but is not a directory.
Secrets¶
- ArenaClient.list_secrets()¶
List your organization’s secrets without their values.
- Returns:
One row per secret with
name,created_at,updated_atandupdated_by.- Return type:
list[dict[str, Any]]
- ArenaClient.set_secret(name, value)¶
Create or replace an organization secret.
- Parameters:
name (str) – Secret name, such as
ANTHROPIC_API_KEY.value (str) – Secret value. Sent once and never returned.
- Returns:
The stored row’s
name,created_at,updated_atandupdated_by.- Return type:
dict[str, Any]
- ArenaClient.delete_secret(name)¶
Delete an organization secret.
- Parameters:
name (str) – Secret name.
- Returns:
{"deleted": True, "name": name}.- Return type:
dict[str, Any]
Deployments¶
- ArenaClient.deploy_agent(experiment_name, checkpoint=None, memory_scope=None, num_gpus=None, gpu_type=None)¶
Create an inference deployment from an experiment checkpoint.
Without
num_gpusorgpu_type, a redeploy keeps the agent’s resources. A new deployment runs on the cluster the agent was trained on if that is your own cluster, else on the cheapest node type that can serve the model. If Arena can’t size the model, it uses its default node type and rejectsnum_gpusandgpu_type.- Parameters:
experiment_name (str) – The name of the experiment to deploy.
checkpoint (str | None) – Steps of the checkpoint to deploy, as listed by
list_checkpoints()(e.g."500"). If None, deploy the checkpoint with the most steps.memory_scope (MemoryScope | None) – Who the deployment keeps chat sessions for.
"user"gives every caller their own conversations,"organization"shares them across the organisation. A new deployment defaults to"user". Redeploying withNonekeeps the scope already stored, it does not reset it, and the scope cannot be changed after the deployment exists.num_gpus (int | None) – GPUs on the agent’s node.
gpu_type (str | None) – Short GPU name such as
h100-80,b200orl4.
- Returns:
A dictionary containing the deployment result.
- Return type:
dict[str, Any]
- Raises:
ArenaValidationError – When
num_gpusis below 1 ormemory_scopeis unknown.
- ArenaClient.update_inference_deployment(name, new_name=None, description=None, enabled=None, experiment_name=None, project_name=None)¶
Rename, describe, or enable a deployment.
- Parameters:
name (str) – Current deployment name.
new_name (str | None) – Replacement display name.
description (str | None) – Replacement description.
enabled (bool | None) –
Trueenables the deployment,Falsedisables it.experiment_name (str | None) – Experiment name when several deployments share
name.project_name (str | None) – Project name when several deployments share
name.
- Returns:
The updated deployment.
- Return type:
dict[str, Any]
- ArenaClient.list_inference_deployments(*, name=None, experiment_name=None, project_name=None)¶
List inference deployments available to the user.
- Parameters:
name (str | None) – The name of the deployment to list.
experiment_name (str | None) – The name of the experiment to list deployments for.
project_name (str | None) – The name of the project to list deployments for.
- Returns:
A list of deployments.
- Return type:
list[dict[str, Any]]
- ArenaClient.delete_inference_deployment(name, experiment_name=None, project_name=None)¶
Archive a deployment.
- Parameters:
name (str) – Deployment name.
experiment_name (str | None) – Experiment name when several deployments share
name.project_name (str | None) – Project name when several deployments share
name.
- Returns:
{"success": true}when the deployment is archived.- Return type:
dict[str, Any]
- ArenaClient.open_inference_agent(deployment_name, *, refresh=False, experiment_name=None, project_name=None, timeout=None)¶
Build an
Agentfor a named deployment.Attempts to load the deployment from the cache, and if not found, fetches it from the API.
The agent carries this client’s own credential, so run
login()or setARENA_API_KEYbefore using a deployment that keeps memory per user. It reads the credential on each request, so a login’s access token is refreshed before it expires.- Parameters:
deployment_name (str) – The name of the deployment to open.
refresh (bool) – Whether to refresh the deployment metadata.
experiment_name (str | None) – Experiment name to disambiguate when multiple deployments share the same deployment name.
project_name (str | None) – Project name to disambiguate when multiple deployments share the same deployment name.
timeout (int | None)
- Return type:
A redeploy moves the deployment to a new URL, which leaves the cached one answering 404. Rather than make you pass refresh to find that out, a 404 from the cached URL refetches it once and retries.
- Parameters:
timeout (int | None) – HTTP timeout in seconds for the returned agent’s inference requests.
deployment_name (str)
refresh (bool)
experiment_name (str | None)
project_name (str | None)
- Returns:
An
Agentinstance.- Return type:
Inference¶
ArenaClient.open_inference_agent returns an Agent bound to one deployment.
- class Agent(endpoint, *, api_key=None, org_key=None, external_user_id=None, timeout=30, generate_params=None, probe_on_init=True, assertion_source=None)¶
HTTP client for a deployed Arena inference endpoint.
When probe_on_init is
True(default),status()runs once at construction and storesmetadata. Wrong endpoint for the deployment type returns HTTP 400 from the server.Every request carries your own Arena credential as
Authorization: Bearer. A deployment that keeps memory per user works out who is calling from it, so there is nothing else to pass. Organisation-key clients also sendX-External-User-Id. The credential is never logged, shown inrepr(), or written to disk.- Parameters:
endpoint (str) – Base URL of the Arena inference deployment.
api_key (str | Callable[[], str | None] | None) – Profile PAT (
arena_pat_<uuid>_<secret>) or access token, or a callable that returns one for each request. A login’s access token expires within minutes, soopen_inference_agent()passes a callable that refreshes it. Falls back to theARENA_API_KEYenvironment variable.org_key (str | None) – Organisation API key (
arena_org_…). Requires external_user_id. Falls back toARENA_ORG_KEY.external_user_id (str | None) – Partner user id sent as
X-External-User-Id. Requires org_key. Falls back toARENA_EXTERNAL_USER_ID.timeout (int) – Request timeout in seconds.
generate_params (LLMParams | None) – Default LLM sampling parameters; defaults to
LLMParamswhenNone.probe_on_init (bool) – If
True, fetchGET /statusduring__init__.assertion_source (Callable[[str], DeploymentAssertion] | None) – Mints a
DeploymentAssertionfor the deployment id inmetadata.
- status(*, refresh=False)¶
Return deployment metadata.
- Parameters:
refresh (bool) – Whether to refresh the metadata.
- Returns:
The deployment metadata.
- Return type:
StatusResponse
- generate(prompts, *, params=None, session_id=None)¶
Generate LLM completions.
- Parameters:
prompts (str | list[str]) – The prompts to the agent.
params (LLMParams | dict[str, Any] | None) – The parameters to the agent.
session_id (str | None) – Chat session to continue, as listed by
list_sessions(). When omitted, a new session id is sent, so the call starts a new conversation.
- Returns:
The LLM results.
- Return type:
LLMResults
- generate_stream(prompt, *, params=None, session_id=None)¶
Stream generated tokens for a single prompt.
- Parameters:
prompt (str) – The prompt to the agent.
params (LLMParams | dict[str, Any] | None) – The parameters to the agent.
session_id (str | None) – Chat session to continue, as listed by
list_sessions(). When omitted, a new session id is sent, so the call starts a new conversation.
- Returns:
An iterator of strings.
- Return type:
Iterator[str]
- list_sessions()¶
List the chat sessions the calling user has with this deployment.
- Returns:
The sessions, most recently updated first as ordered by the deployment. Empty when the user has no conversations yet.
- Return type:
list[SessionInfo]
- get_session(session_id)¶
Fetch one chat session and its messages.
- Parameters:
session_id (str) – The ID of the session to fetch.
- Returns:
The session and its messages.
- Return type:
SessionDetail
- delete_session(session_id)¶
Delete a chat session and every turn the deployment stored for it.
Deleting is idempotent: a session that is already gone, or that belongs to someone else under the deployment’s memory scope, answers the same way, so this reports whether there was anything to delete rather than raising.
- Parameters:
session_id (str) – The ID of the session to delete.
- Returns:
Trueif the session was deleted,Falseif the deployment has no such session visible to you.- Return type:
bool
- close()¶
Close the underlying HTTP connection pool.
- Return type:
None
- class LLMParams¶
LLM sampling parameters model.
- Parameters:
max_new_tokens (int) – The maximum number of new tokens to generate.
temperature (float) – The temperature of the LLM.
top_p (float) – The top-p value of the LLM.
do_sample (bool) – Whether to sample the LLM.
- field do_sample: bool = True¶
- field max_new_tokens: int = 100¶
- field temperature: float = 0.7¶
- field top_p: float = 0.9¶
Errors¶
Every error the client raises is an ArenaError.
- exception ArenaError¶
Base exception for all Arena client errors.
- exception ArenaAuthError(message, *, sdk_hint='', cli_hint='')¶
Raised when authentication fails or credentials are missing/expired.
- Parameters:
message (str)
sdk_hint (str)
cli_hint (str)
- Return type:
None
- exception ArenaTimeoutError(message, *, sdk_hint='', cli_hint='')¶
Raised when the device-flow login times out waiting for user authorization.
- Parameters:
message (str)
sdk_hint (str)
cli_hint (str)
- Return type:
None
- exception ArenaAPIError(detail, *, status_code=0, extras=None, sdk_hint='', cli_hint='')¶
Raised when the Arena API returns a non-2xx response.
- Parameters:
detail (str) – Human-readable error description.
status_code (int) – HTTP status code from the API response.
extras (dict[str, Any] | None) – Supplementary context from the error body.
sdk_hint (str) – Guidance shown when running from the Python SDK.
cli_hint (str) – Guidance shown when running from the CLI.
- Return type:
None
- exception ArenaValidationError(detail, *, status_code=0, extras=None, sdk_hint='', cli_hint='')¶
Raised when environment validation fails or client arguments are invalid.
- Parameters:
detail (str)
status_code (int)
extras (dict[str, Any] | None)
sdk_hint (str)
cli_hint (str)
- Return type:
None
- exception ArenaInferenceError(detail, *, status_code=0, extras=None, sdk_hint='', cli_hint='')¶
Raised when an Arena inference deployment request fails or inputs are invalid.
- Parameters:
detail (str)
status_code (int)
extras (dict[str, Any] | None)
sdk_hint (str)
cli_hint (str)
- Return type:
None
- exception ArenaTrainingError(detail, *, status_code=0, extras=None, sdk_hint='', cli_hint='')¶
Raised when a training job submission or execution fails.
- Parameters:
detail (str)
status_code (int)
extras (dict[str, Any] | None)
sdk_hint (str)
cli_hint (str)
- Return type:
None
- exception ArenaClientUpgradeRequiredError(detail, *, status_code=0, extras=None, sdk_hint='', cli_hint='')¶
Raised when Arena refuses this agilerl release as below its minimum (HTTP 426).
- Parameters:
detail (str)
status_code (int)
extras (dict[str, Any] | None)
sdk_hint (str)
cli_hint (str)
- Return type:
None
- exception ArenaEnvironmentNotFoundError(detail, *, status_code=0, extras=None, sdk_hint='', cli_hint='')¶
Raised when a referenced environment does not exist in Arena.
- Parameters:
detail (str)
status_code (int)
extras (dict[str, Any] | None)
sdk_hint (str)
cli_hint (str)
- Return type:
None
- exception ArenaConfigError(message, *, sdk_hint='', cli_hint='')¶
Raised when required configuration (e.g. default project) is missing.
- Parameters:
message (str)
sdk_hint (str)
cli_hint (str)
- Return type:
None