> ## Documentation Index
> Fetch the complete documentation index at: https://docs.r3al.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Quantize your first vision model on the R3AL platform in six steps.

Since 2.0 the SDK is a thin client. You install `r3alai` locally, but the quantization itself runs on the R3AL platform (GPU infrastructure at [platform.r3al.ai](https://platform.r3al.ai)). Your model is uploaded, the job runs on our hardware, and the quantized model is downloaded back to you.

<Note>
  The free plan includes **3 runs**. Each `quantize` or QAT job consumes one run; local `benchmark()` and export are free. A fourth run raises `PlanLimitError` (HTTP 402); upgrade your plan on the platform.
</Note>

## 1. Create an account and an API key

<Steps>
  <Step title="Sign up">
    Create an account at [platform.r3al.ai](https://platform.r3al.ai) and verify your email.
  </Step>

  <Step title="Mint a key">
    Open the **SDK / API keys** page and create a key. It looks like `r3l_live_...`. Copy it now: the secret is shown only once.
  </Step>
</Steps>

## 2. Install

```bash theme={null}
pip install "r3alai[vision]"
```

The `vision` extra pulls in `onnxruntime` and `pillow` so you can run and benchmark the quantized model locally. See [Installation](/installation) for other extras.

## 3. Authenticate

Point the SDK at your key, either in code or through the environment:

```python theme={null}
import r3alai.platform as platform

platform.login("r3l_live_...")   # sets the key for this process
```

Or store it once with the CLI, which verifies it before writing it `0600` — after
that neither the SDK nor the CLI needs an environment variable:

```bash theme={null}
export R3AL_API_KEY="r3l_live_..." && r3al login
```

<CodeGroup>
  ```bash Mac/Linux theme={null}
  export R3AL_API_KEY="r3l_live_..."
  ```

  ```powershell Windows Powershell theme={null}
  $Env:R3AL_API_KEY = "r3l_live_..."
  ```

  ```cmd Windows CMD theme={null}
  rem Do not wrap the API key with quotation marks below
  set R3AL_API_KEY=r3l_live_...
  ```
</CodeGroup>

## 4. Quantize on the platform

The default method is `ptq_static`: the best size and latency wins across vision models, including convolution-heavy backbones. It needs a few representative calibration samples (sample inputs drawn from your own data). One call uploads your model and calibration data, runs the job on R3AL GPUs, streams live progress, and downloads the quantized model into `output_dir`.

```python theme={null}
from r3alai.quant import Quantizer

result = Quantizer().quantize(
    "model.onnx",
    calibration_data=["img1.jpg", "img2.jpg", "img3.jpg"],  # a handful of representative inputs
    output_dir="./out",
)
print(result.path)   # local path to the downloaded model
```

<Note>
  No calibration data on hand? Use `method="ptq_dynamic"`, which needs none. It only quantizes MatMul and Gemm (fully connected) layers, so it suits transformer or MatMul-heavy models and is a poor fit for convolution-heavy vision backbones (it would find nothing to quantize). See [Pick the right method](/concepts/methods).
</Note>

<Note>
  Only have framework weights? Pass the checkpoint and the SDK exports it to ONNX locally before upload: `Quantizer(QuantConfig(method="ptq_static")).quantize("checkpoint.pt", source="pytorch", input_shape=[1, 3, 224, 224], calibration_data=["img1.jpg", "img2.jpg"], output_dir="./out")`. Local export needs the matching extra, for example `r3alai[export-torch]`.
</Note>

## 5. Watch the job live

While `quantize()` blocks, it prints progress on your terminal. You can also follow the same job on the platform's **Jobs** page, which shows its status and progress bar in real time and keeps a record of every run.

## 6. Measure it locally

Latency numbers only matter on the hardware you deploy to, so `benchmark()` runs on **your** machine, not the platform:

```python theme={null}
from r3alai.quant import Quantizer

eval_data = [preprocess(p) for p in Path("val_images").glob("*.jpg")]

result = Quantizer().benchmark(
    original_model="model.onnx",
    quantized_model="out/model.quantized.onnx",   # the ONNX file, not the bundle dir
    use_synthetic=True,
)
```

The benchmark runs on CPU or GPU, prints live progress, and reports the hardware it ran on. For more details and information on method options, see [Benchmarking](/guides/benchmarking).

## Calibration and the no-data alternative

`ptq_static` (the default) gives the smallest file and the best latency win, including on convolution-heavy backbones. The trade-off is that it needs representative calibration samples, and badly chosen samples cost accuracy. A small accuracy drop versus full precision is normal even with good calibration, so always validate.

If you have no calibration data, `ptq_dynamic` needs none:

```python theme={null}
from r3alai.quant import QuantConfig, Quantizer

result = Quantizer(QuantConfig(method="ptq_dynamic")).quantize(
    "model.onnx",
    output_dir="./out_dynamic",
)
```

It only quantizes MatMul and Gemm layers, so it fits transformer or MatMul-heavy models. On a convolution-heavy vision model it finds nothing to quantize and reports an unsupported config, so use `ptq_static` with calibration data instead.

Read [Integer arithmetic](/concepts/integer-arithmetic) for the dynamic-vs-static trade-off, and [Calibration](/concepts/calibration) for building a good calibration set.

## Next steps

<CardGroup cols={2}>
  <Card title="Using the platform" icon="cloud" href="/guides/platform">
    Accounts, API keys, the Jobs page, and your plan.
  </Card>

  <Card title="Pick the right method" icon="sliders" href="/concepts/methods">
    Dynamic vs static INT8 or INT4, and when to use QAT.
  </Card>

  <Card title="QAT explained" icon="dumbbell" href="/concepts/qat">
    Recover accuracy with quantization-aware training.
  </Card>

  <Card title="End-to-end workflow" icon="route" href="/guides/workflow">
    Export, quantize on the platform, validate locally.
  </Card>
</CardGroup>
