Reflex Docs
Python SDK

reflex.Client

The top-level Python SDK entry point with namespaced sub-clients.

reflex.Client is a one-stop wrapper around every product API exposed by the Reflex platform. Instantiate it once and reach into namespaces like client.datasets, client.training, or client.deployments.

For one-shot inference or a streaming control loop, prefer reflex.ActionStream or @reflex.connect.

Constructor

import reflex

client = reflex.Client(api_key=None, url=None, convex_url=None)
ParameterDefaultDescription
api_keyREFLEX_API_KEY env / saved keyAPI key. See Authentication.
urlproductionOverride the Actions API URL.
convex_urlproductionOverride the backend URL.

Sub-clients

client.actions       # metered one-shot inference
client.datasets      # dataset registration / listing
client.training      # training runs
client.deployments   # deployments
client.sessions      # session lifecycle
client.robots        # robot schemas, robots, pairing tokens
client.instances     # managed compute instances
client.receipts      # billing receipts

Each sub-client mirrors the equivalent module-level helpers in the SDK (e.g. client.datasets.list() is the same call as reflex.list_datasets()), but reads the API key and URLs from the parent Client instead of from env vars on every call.

Example

import reflex

client = reflex.Client()

# Register a dataset and start training
dataset = client.datasets.register_huggingface("hf://datasets/owner/repo")
client.datasets.validate(dataset["id"])

run = client.training.create(
    dataset_id=dataset["id"],
    fine_tuning_type="lora",
    epochs=3,
)

# Poll for completion
while True:
    state = client.training.get(run["id"])
    if state["status"] in ("succeeded", "failed", "stopped"):
        break
    time.sleep(10)

When to reach for Client vs. module helpers

  • Use Client when you need a single configured handle to share across many calls in the same process.
  • Use the module-level helpers (reflex.list_datasets(...), etc.) for short scripts where the env var is enough configuration.
  • Use reflex.ActionStream or @reflex.connect for streaming inference loops.
  • Use reflex.connect_runner.run_from_config to embed the same YAML-driven loop that reflex connect exposes.