# Variables

> Variables are plain configuration your app reads from the workspace that runs it: a region, a bucket name, a base URL, a feature flag. A variable is stored and shown in clear to every member of the wo...

**URL:** https://inference.sh/docs/extend/variables
**Last updated:** 2026-11-29

---

Variables are plain configuration your app reads from the workspace that runs it: a region, a bucket name, a base URL, a feature flag. A variable is stored and shown in clear to every member of the workspace and reaches the app as is.

Keys, tokens and passwords are [secrets](/docs/extend/secrets) or [credentials](/docs/extend/credentials), never variables.

---

## Declaring variables

List them under `vars:` in `inf.yml`:

```yaml
vars:
  - key: AWS_REGION
    description: Region for storage and inference

  - key: OUTPUT_BUCKET
    description: Bucket for rendered files
    default: my-team-output
    optional: true
```

| Property | Type | Description |
|----------|------|-------------|
| `key` | string | Environment variable name |
| `description` | string | Shown to users |
| `optional` | boolean | If false (the default), the run needs a value |
| `default` | string | Used when the workspace has not set the variable |

At run time the app gets the workspace's value for `key`, else `default`. A variable with neither that is not optional stops the run as a missing requirement; the setup dialog offers to add it.

Deploy checks every entry with the same rules as a saved variable (below). It also refuses a name declared twice, or declared under both `vars:` and `secrets:` / `credentials:`. An app lists at most 100 variables.

---

## Reading variables

Variables are environment variables, like secrets:

<div data-type="codegroup">

```python Python
import os
region = os.environ["AWS_REGION"]
bucket = os.environ.get("OUTPUT_BUCKET", "fallback-bucket")
```

```javascript Node.js
const region = process.env.AWS_REGION;
const bucket = process.env.OUTPUT_BUCKET ?? "fallback-bucket";
```

</div>

---

## Setting variables

Any workspace member can set variables, in the vault in the web app or with the CLI (belt v1.29.0+):

```bash
belt vars set AWS_REGION eu-west-1
belt vars set OUTPUT_BUCKET gs://my-bucket/out/ -d "where renders land"
belt vars set ALLOWED_ORIGINS - < origins.txt   # value from stdin
belt vars list
belt vars get AWS_REGION
belt vars delete AWS_REGION
```

Rules for a saved variable:

- The name is letters, digits and underscores, not starting with a digit, at most 128 characters.
- Names the platform keeps for itself are refused: `PATH`, `PYTHONPATH`, `NODE_OPTIONS`, `LD_*`, `ENGINE_*` and similar.
- A name that contains `KEY`, `TOKEN`, `SECRET`, `PASS`, `CREDENTIAL` or `PRIVATE` (any case) reads as a secret's and is refused.
- A value is at most 8 KiB, and one that looks like a credential is refused.
- A workspace holds at most 500 variables.

### Turn a secret into a variable

If a plain value was saved as a secret, `belt vars from-secret <key>` moves it to a variable of the same name and deletes the secret. Since the value is shown in clear from then on, it takes what revealing the secret takes: `secrets:reveal` and `secrets:write`, the manage-vault capability in the workspace, and the browser's step-up check. A provider's credential key cannot be converted. Then change the app's `inf.yml` from `secrets:` to `vars:`.

---

## REST API

| Method | Route | Scope |
|--------|-------|-------|
| GET | `/variables` | `apps:read` |
| POST | `/variables/list` | `apps:read` |
| GET | `/variables/{key}` | `apps:read` |
| PUT | `/variables/{key}` | `apps:write` |
| DELETE | `/variables/{key}` | `apps:write` |
| POST | `/variables/from-secret/{key}` | `apps:write`, `secrets:write`, `secrets:reveal` |

`PUT /variables/{key}` takes `{"value": "...", "description": "..."}`; it creates the variable or replaces its value, and `description`, when sent, replaces the stored one. Responses are `VariableDTO`: `id`, `key`, `value`, `description`, `team_id`, `user_id`, `created_at`, `updated_at`.

```bash
curl -X PUT "https://api.inference.sh/variables/AWS_REGION" \
  -H "Authorization: Bearer $INFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value": "eu-west-1"}'
```
