API Reference
Detailed documentation of the RunRL Python client API
API Reference
This page provides detailed documentation for all methods available in the RunRL Python client.
Client Initialization
Parameters
api_key
(str, required): Your RunRL API keybase_url
(str, optional): The base URL for the RunRL API. Defaults to "https://runrlusercontent.com"
User Data
get_user_data()
Retrieves information about the authenticated user.
Returns: A dictionary containing user information.
Runs
list_runs()
Lists all runs for the authenticated user.
Returns: A list of dictionaries, each containing information about a run.
create_run()
Creates a new run with the specified parameters.
Parameters:
model_name
(str, required): The name of the modelprompt_file
(str, required): ID of the uploaded prompt filereward_file
(str, required): ID of the uploaded reward file
Hyperparameters:
-
learning_rate
(float, optional): Controls the step size for updating model weights. Smaller values lead to slower but potentially more stable learning. In GRPO (Generative Reinforcement Learning with Proximal Optimization), it affects how quickly the agent's policy adapts. Defaults to 5e-6. -
weight_decay
(float, optional): A regularization technique that penalizes large weights, helping to prevent overfitting and improve the model's generalization. -
adam_beta1
(float, optional): The exponential decay rate for the first moment estimates (mean of gradients) in the Adam optimizer. Typically around 0.9. -
adam_beta2
(float, optional): The exponential decay rate for the second moment estimates (variance of gradients) in the Adam optimizer. Typically around 0.999. -
warmup_ratio
(float, optional): Fraction of total training steps for a learning rate warmup, where the learning rate gradually increases. Helps stabilize training early on. -
kl_beta
(float, optional): Coefficient for the KL divergence penalty. It controls how much the policy can change in one update, ensuring stability. Setting this to 0.0 will significantly reduce memory requirements.
Configuration Parameters:
-
lora_rank
(int, optional): The rank of the Low-Rank Adaptation matrices. Higher values allow for more expressive parameter updates but require more memory and computation. A value of 0 means LoRA is not used. Defaults to 0. -
max_seq_length
(int, optional): The maximum length of input sequences. Longer sequences provide more context but require more memory and computation. Defaults to 1024. -
epochs
(int, optional): The number of complete passes through the training dataset. Defaults to 1. -
gpu_type
(str, optional): The type of GPU to use for training. Options include "H100", "A100", etc. Defaults to "H100". -
n_gpus
(int, optional): The number of GPUs to use for training. Defaults to 8. -
turbo
(bool, optional): When enabled, uses a specific configuration optimized for speed (requires H100 GPUs and n_gpus=8). Defaults to True. -
hf_token
(str, optional): Hugging Face token for accessing gated models.
Returns: A dictionary containing information about the created run.
Note: When turbo=True
, gpu_type
must be "H100" and n_gpus
must be 8.
get_run_details(run_id)
Gets detailed information about a specific run.
Parameters:
run_id
(str, required): The ID of the run
Returns: A dictionary containing detailed information about the run.
cancel_run(run_id)
Cancels a running job.
Parameters:
run_id
(str, required): The ID of the run to cancel
Returns: A dictionary containing the result of the cancellation.
Prompt Files
For details on prompt file format requirements, see the File Formats documentation.
list_prompt_files()
Lists all prompt files for the authenticated user.
Returns: A list of dictionaries, each containing information about a prompt file.
upload_prompt_file(file_path, friendly_name=None)
Uploads a new prompt file.
Parameters:
file_path
(str, required): Path to the file to uploadfriendly_name
(str, optional): A user-friendly name for the file
Returns: A dictionary containing information about the uploaded file.
delete_prompt_file(file_id)
Deletes a prompt file.
Parameters:
file_id
(str, required): The ID of the file to delete
Returns: A dictionary containing the result of the deletion.
get_prompt_file_preview(file_id)
Gets a preview of a prompt file.
Parameters:
file_id
(str, required): The ID of the file to preview
Returns: A dictionary containing the file preview.
Reward Files
For details on reward function format requirements, see the File Formats documentation.
list_reward_files()
Lists all reward files for the authenticated user.
Returns: A list of dictionaries, each containing information about a reward file.
upload_reward_file(file_path, friendly_name=None)
Uploads a new reward file.
Parameters:
file_path
(str, required): Path to the file to uploadfriendly_name
(str, optional): A user-friendly name for the file
Returns: A dictionary containing information about the uploaded file.
delete_reward_file(file_id)
Deletes a reward file.
Parameters:
file_id
(str, required): The ID of the file to delete
Returns: A dictionary containing the result of the deletion.
get_reward_file_content(file_id)
Gets the content of a reward file.
Parameters:
file_id
(str, required): The ID of the file to get content for
Returns: A dictionary containing the file content.
Models & Deployments
download_model(job_name, output_path)
Downloads a trained model.
Parameters:
job_name
(str, required): The name of the job/model to downloadoutput_path
(str, required): The path where the model should be saved
Returns: None. Prints a success message when the download is complete.
list_deployments(job_name)
Lists all deployments for a specific job/model.
Parameters:
job_name
(str, required): The name of the job/model
Returns: A list of dictionaries, each containing information about a deployment.
deploy_model(job_name)
Deploys a trained model.
Parameters:
job_name
(str, required): The name of the job/model to deploy
Returns: A dictionary containing information about the deployment.
Metrics & Logs
get_stored_metrics(run_id)
Gets stored metrics for a specific run.
Parameters:
run_id
(str, required): The ID of the run
Returns: A dictionary containing metrics for the run.
get_stored_logs(run_id, max_lines=2000)
Gets stored logs for a specific run.
Parameters:
run_id
(str, required): The ID of the runmax_lines
(int, optional): Maximum number of log lines to retrieve. Defaults to 2000
Returns: A dictionary containing logs for the run.
stream_logs(run_id, follow=True)
Streams logs for a specific run in real-time.
Parameters:
run_id
(str, required): The ID of the runfollow
(bool, optional): Whether to continue streaming new logs as they arrive. Defaults to True
Returns: An async generator that yields log entries as dictionaries.
GPU Prices
get_gpu_price(gpu_type)
Gets the price for a specific GPU type.
Parameters:
gpu_type
(str, required): The type of GPU
Returns: A dictionary containing pricing information.
get_all_gpu_prices()
Gets prices for all available GPU types.
Returns: A list of dictionaries, each containing pricing information for a GPU type.
Error Handling
The RunRL client defines several exception classes for handling different types of errors: