---
sidebar:
  label: roboto.env
  order: 9
title: roboto.env
---
## Module Contents

### ROBOTO_ENV_VAR_PREFIX

```python
roboto.env.ROBOTO_ENV_VAR_PREFIX = 'ROBOTO_'
```

`from roboto.env import ROBOTO_ENV_VAR_PREFIX`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/env.py#L18-L18)

Prefix of the name of every environment variable in `RobotoEnvKey`.

### RobotoEnv

```python
class roboto.env.RobotoEnv(
    _case_sensitive: bool | None = None,
    _nested_model_default_partial_update: bool | None = None,
    _env_prefix: str | None = None,
    _env_prefix_target: pydantic_settings.sources.EnvPrefixTarget | None = None,
    _env_file: pydantic_settings.sources.DotenvType | None = ENV_FILE_SENTINEL,
    _env_file_encoding: str | None = None,
    _env_file_depth: int | None = None,
    _env_ignore_empty: bool | None = None,
    _env_nested_delimiter: str | None = None,
    _env_nested_max_split: int | None = None,
    _env_parse_none_str: str | None = None,
    _env_parse_enums: bool | None = None,
    _cli_prog_name: str | None = None,
    _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None,
    _cli_settings_source: pydantic_settings.sources.CliSettingsSource[Any] | None = None,
    _cli_parse_none_str: str | None = None,
    _cli_hide_none_type: bool | None = None,
    _cli_avoid_json: bool | None = None,
    _cli_enforce_required: bool | None = None,
    _cli_use_class_docs_for_groups: bool | None = None,
    _cli_show_env_vars: bool | None = None,
    _cli_exit_on_error: bool | None = None,
    _cli_prefix: str | None = None,
    _cli_flag_prefix_char: str | None = None,
    _cli_implicit_flags: bool | Literal['dual', 'toggle'] | None = None,
    _cli_ignore_unknown_args: bool | None = None,
    _cli_kebab_case: bool | Literal['all', 'no_enums'] | None = None,
    _cli_shortcuts: collections.abc.Mapping[str, str | list[str]] | None = None,
    _secrets_dir: pydantic_settings.sources.PathType | None = None,
    _build_sources: tuple[tuple[pydantic_settings.sources.PydanticBaseSettingsSource, ...], dict[str, Any]] | None = None,
    **values: Any,
)
```

`from roboto import RobotoEnv`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/env.py#L181-L304)

Bases: `pydantic_settings.BaseSettings`

Values of the Roboto environment variables the SDK reads, parsed when the instance is created.

Each field reads the variable `RobotoEnvKey` names, and is `None` when that variable is unset unless its docstring says otherwise. `default` returns one instance shared across the process.

**Parameters**

- **`_case_sensitive`** (`bool | None`)
- **`_nested_model_default_partial_update`** (`bool | None`)
- **`_env_prefix`** (`str | None`)
- **`_env_prefix_target`** (`pydantic_settings.sources.EnvPrefixTarget | None`)
- **`_env_file`** (`pydantic_settings.sources.DotenvType | None`)
- **`_env_file_encoding`** (`str | None`)
- **`_env_file_depth`** (`int | None`)
- **`_env_ignore_empty`** (`bool | None`)
- **`_env_nested_delimiter`** (`str | None`)
- **`_env_nested_max_split`** (`int | None`)
- **`_env_parse_none_str`** (`str | None`)
- **`_env_parse_enums`** (`bool | None`)
- **`_cli_prog_name`** (`str | None`)
- **`_cli_parse_args`** (`bool | list[str] | tuple[str, ...] | None`)
- **`_cli_settings_source`** (`pydantic_settings.sources.CliSettingsSource[Any] | None`)
- **`_cli_parse_none_str`** (`str | None`)
- **`_cli_hide_none_type`** (`bool | None`)
- **`_cli_avoid_json`** (`bool | None`)
- **`_cli_enforce_required`** (`bool | None`)
- **`_cli_use_class_docs_for_groups`** (`bool | None`)
- **`_cli_show_env_vars`** (`bool | None`)
- **`_cli_exit_on_error`** (`bool | None`)
- **`_cli_prefix`** (`str | None`)
- **`_cli_flag_prefix_char`** (`str | None`)
- **`_cli_implicit_flags`** (`bool | Literal['dual', 'toggle'] | None`)
- **`_cli_ignore_unknown_args`** (`bool | None`)
- **`_cli_kebab_case`** (`bool | Literal['all', 'no_enums'] | None`)
- **`_cli_shortcuts`** (`collections.abc.Mapping[str, str | list[str]] | None`)
- **`_secrets_dir`** (`pydantic_settings.sources.PathType | None`)
- **`_build_sources`** (`tuple[tuple[pydantic_settings.sources.PydanticBaseSettingsSource, ...], dict[str, Any]] | None`)
- **values** (`Any`)

**Attributes**

- **RobotoEnv.action_inputs_manifest_file** (`pathlib.Path | None`) = `None`: Path to a JSON file holding the invocation's input manifest, from `ROBOTO_ACTION_INPUTS_MANIFEST`.

- **RobotoEnv.action_parameters_file** (`str | None`) = `None`: Path to a JSON file of the invocation's parameter values, from `ROBOTO_ACTION_PARAMETERS_FILE`.

- **RobotoEnv.action_runtime_config_dir** (`str | None`) = `None`: Directory of the invocation's runtime configuration, from `ROBOTO_ACTION_RUNTIME_CONFIG_DIR`.

- **RobotoEnv.action_timeout** (`str | None`) = `None`: Number of seconds the invocation may run before Roboto cancels it, from `ROBOTO_ACTION_TIMEOUT`.

- **RobotoEnv.api_key** (`str | None`) = `None`: Access token, from `ROBOTO_API_KEY`, or from `ROBOTO_BEARER_TOKEN` when that is unset.

- **RobotoEnv.cache_dir** (`str | None`) = `None`: Directory the SDK caches data from Roboto in, from `ROBOTO_CACHE_DIR`.

  `None` uses the operating system's per-user cache directory.

- **RobotoEnv.config_file** (`str | None`) = `None`: Path to the Roboto config file, from `ROBOTO_CONFIG_FILE`. `None` reads `~/.roboto/config.json`.

- **RobotoEnv.dataset_id** (`str | None`) = `None`: ID of the dataset the invocation was invoked on, from `ROBOTO_DATASET_ID`.

- **RobotoEnv.dataset_metadata_changeset_file** (`str | None`) = `None`: Path to the dataset's tag and metadata changes file, from `ROBOTO_DATASET_METADATA_CHANGESET_FILE`.

- **RobotoEnv.default_http_timeout** (`Timeout`) = `None`: Seconds to wait for a request to Roboto before giving up, from `ROBOTO_DEFAULT_HTTP_TIMEOUT`.

  `NotSet` when the variable is unset, which uses the config file profile's `default_http_timeout`, or 30 seconds. A request that times out is sent again only when repeating it cannot apply a change twice, as with a GET.

- **RobotoEnv.dry_run** (`bool | None`) = `None`: Whether the invocation is a dry run, from `ROBOTO_DRY_RUN`. `False` when the variable is unset.

  `roboto actions invoke-local --dry-run` sets it, so an action can be tested without changing anything in Roboto. During a dry run, an action should skip side effects, such as:

  - Uploading files to datasets.
  - Changing metadata.
  - Requests to other services that change their state.

  Actions read it through [`is_dry_run`](/docs/reference/python-sdk/roboto/action_runtime/invocation_context#roboto.action_runtime.invocation_context.InvocationContext.is_dry_run).

- **RobotoEnv.file_metadata_changeset_file** (`str | None`) = `None`: Path to the file of tag and metadata changes for output files, from `ROBOTO_FILE_METADATA_CHANGESET_FILE`.

- **RobotoEnv.input_dir** (`str | None`) = `None`: Directory the invocation's selected files are downloaded into, from `ROBOTO_INPUT_DIR`.

- **RobotoEnv.invocation_id** (`str | None`) = `None`: ID of the invocation, from `ROBOTO_INVOCATION_ID`.

- **RobotoEnv.log_level** (`str | None`) = `None`: Log level requested for the invocation, from `ROBOTO_LOG_LEVEL`.

- **RobotoEnv.org_id** (`str | None`) = `None`: ID of the organization to act in, from `ROBOTO_ORG_ID`.

- **RobotoEnv.output_dir** (`str | None`) = `None`: Directory for the action's output files, from `ROBOTO_OUTPUT_DIR`.

- **RobotoEnv.profile** (`str | None`) = `None`: Name of the config file profile to read, from `ROBOTO_PROFILE`. `None` reads the file's default profile.

- **RobotoEnv.roboto_env** (`str | None`) = `None`: Description of where the SDK runs, recorded on the files and directories it uploads, from `ROBOTO_ENV`.

- **RobotoEnv.roboto_service_endpoint** (`str | None`) = `None`: URL of the Roboto API to send requests to, from `ROBOTO_SERVICE_ENDPOINT`.

  Applies when the access token comes from the environment. `None` uses `https://api.roboto.ai`.

- **RobotoEnv.roboto_service_url** (`str | None`) = `None`: Deprecated. URL of the Roboto API, from `ROBOTO_SERVICE_URL`.

  Use `roboto_service_endpoint` instead; the SDK never reads this field.

#### RobotoEnv.default()

```python
@classmethod
def default() -> RobotoEnv
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/env.py#L189-L198)

Return the process's shared `RobotoEnv`, created from the environment on the first call.

Later changes to the environment do not reach it; create a `RobotoEnv` to read the current values.

**Returns**

- `RobotoEnv`

#### RobotoEnv.get_env_var()

```python
def get_env_var(var_name: str, default_value: Optional[str] = None) -> Optional[str]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/env.py#L295-L304)

Return the current value of environment variable `var_name`, or `default_value` when it is unset.

Reads the process's environment at call time, not the values this instance parsed.

**Parameters**

- **var_name** (`str`): Name of the environment variable.
- **default_value** (`Optional[str]`): Value to return when the variable is unset.

**Returns**

- `Optional[str]`

### RobotoEnvKey

```python
class roboto.env.RobotoEnvKey
```

`from roboto.env import RobotoEnvKey`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/env.py#L55-L173)

Bases: `roboto.compat.StrEnum`

Names of the environment variables the SDK reads, and that Roboto sets for an action's code.

Each member's value is the variable's name, such as `ROBOTO_DATASET_ID`.

**Attributes**

- **RobotoEnvKey.ActionInputs** = `'ROBOTO_ACTION_INPUTS'`: Input manifest of the invocation, as JSON: the files, sessions, and topics it was invoked on.

  Set when Roboto does not download the invocation's selected files and the manifest fits in an environment variable. [`get_input()`](/docs/reference/python-sdk/roboto/action_runtime/invocation_context#roboto.action_runtime.invocation_context.InvocationContext.get_input) reads the manifest from the first of `ROBOTO_ACTION_INPUTS`, `ROBOTO_ACTION_INPUTS_URL` and `ROBOTO_ACTION_INPUTS_MANIFEST` that is set.

- **RobotoEnvKey.ActionInputsManifest** = `'ROBOTO_ACTION_INPUTS_MANIFEST'`: Path to a JSON file holding the invocation's input manifest.

  When Roboto downloads the selected files, this manifest also gives each file's path under `ROBOTO_INPUT_DIR`.

- **RobotoEnvKey.ActionInputsUrl** = `'ROBOTO_ACTION_INPUTS_URL'`: URL to fetch the invocation's input manifest from, when it is too large for `ROBOTO_ACTION_INPUTS`.

- **RobotoEnvKey.ActionParametersFile** = `'ROBOTO_ACTION_PARAMETERS_FILE'`: Path to a JSON file of the invocation's parameter values, with the action's defaults filled in.

- **RobotoEnvKey.ActionRuntimeConfigDir** = `'ROBOTO_ACTION_RUNTIME_CONFIG_DIR'`: Directory of the invocation's runtime configuration.

  Holds `secrets.json`, the values of the parameters that name secrets.

- **RobotoEnvKey.ActionTimeout** = `'ROBOTO_ACTION_TIMEOUT'`: Number of seconds the invocation may run before Roboto cancels it.

- **RobotoEnvKey.ApiKey** = `'ROBOTO_API_KEY'`: Access token the SDK authenticates with, read ahead of `ROBOTO_BEARER_TOKEN` and the config file.

- **RobotoEnvKey.BearerToken** = `'ROBOTO_BEARER_TOKEN'`: Access token the SDK authenticates with when `ROBOTO_API_KEY` is unset.

- **RobotoEnvKey.CacheDir** = `'ROBOTO_CACHE_DIR'`: Directory the SDK caches data from Roboto in. Unset uses the operating system's per-user cache directory.

- **RobotoEnvKey.ConfigFile** = `'ROBOTO_CONFIG_FILE'`: Path to the Roboto config file. Unset reads `~/.roboto/config.json`.

- **RobotoEnvKey.DatasetId** = `'ROBOTO_DATASET_ID'`: ID of the dataset the invocation was invoked on.

- **RobotoEnvKey.DatasetMetadataChangesetFile** = `'ROBOTO_DATASET_METADATA_CHANGESET_FILE'`: Path to a file in which the action records changes to its dataset's tags and metadata.

  Roboto applies the changes when the invocation finishes.

- **RobotoEnvKey.DryRun** = `'ROBOTO_DRY_RUN'`: Whether the invocation is a dry run, in which the action should skip side effects.

  `roboto actions invoke-local --dry-run` sets it.

- **RobotoEnvKey.FileMetadataChangesetFile** = `'ROBOTO_FILE_METADATA_CHANGESET_FILE'`: Path to a file in which the action records tag and metadata changes for the files in `ROBOTO_OUTPUT_DIR`.

  Roboto applies the changes after it uploads those files.

- **RobotoEnvKey.InputDir** = `'ROBOTO_INPUT_DIR'`: Directory Roboto downloads the invocation's selected files into, when it downloads them.

- **RobotoEnvKey.InvocationId** = `'ROBOTO_INVOCATION_ID'`: ID of the invocation.

- **RobotoEnvKey.LogLevel** = `'ROBOTO_LOG_LEVEL'`: Log level requested for the invocation: `ERROR`, `WARNING`, `INFO` or `DEBUG`.

  The action applies it; [`log_level`](/docs/reference/python-sdk/roboto/action_runtime/invocation_context#roboto.action_runtime.invocation_context.InvocationContext.log_level) reads it.

- **RobotoEnvKey.OrgId** = `'ROBOTO_ORG_ID'`: ID of the organization to act in.

  Roboto sets it to the invocation's organization. The CLI and [`from_env()`](/docs/reference/python-sdk/roboto/roboto_search#roboto.roboto_search.RobotoSearch.from_env) use it when the caller names no organization.

- **RobotoEnvKey.OutputDir** = `'ROBOTO_OUTPUT_DIR'`: Directory for the action's output files, which Roboto uploads to a dataset when the invocation finishes.

- **RobotoEnvKey.Profile** = `'ROBOTO_PROFILE'`: Name of the config file profile to read.

  Unset uses the config file's default profile, and an empty value names the profile `default`.

- **RobotoEnvKey.RobotoEnv** = `'ROBOTO_ENV'`: Description of where the SDK runs, recorded as the origination of the files and directories it uploads.

  Roboto sets it in an action's container, such as `invocation: <invocation_id>`. Unset, uploads record `roboto <SDK version>`.

- **RobotoEnvKey.RobotoServiceEndpoint** = `'ROBOTO_SERVICE_ENDPOINT'`: URL of the Roboto API to send requests to, when the access token comes from the environment.

  Unset uses `https://api.roboto.ai`.

- **RobotoEnvKey.RobotoServiceUrl** = `'ROBOTO_SERVICE_URL'`: Deprecated. URL of the Roboto API.

  Use `ROBOTO_SERVICE_ENDPOINT` instead; the SDK never reads this variable.

- **RobotoEnvKey.StageInputs** = `'ROBOTO_STAGE_INPUTS'`: Whether Roboto downloads the invocation's selected files into `ROBOTO_INPUT_DIR` before the action's code runs.

  `1` when the action's [`requires_downloaded_inputs`](/docs/reference/python-sdk/roboto/domain/actions/action#roboto.domain.actions.action.Action.requires_downloaded_inputs) is true, and `0` otherwise. Either way, the action learns what it was invoked on from its input manifest.

#### RobotoEnvKey.for_parameter()

```python
@staticmethod
def for_parameter(param_name: str) -> str
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/env.py#L165-L173)

Return the name of the environment variable that holds the value of action parameter `param_name`.

Roboto sets one such variable, `ROBOTO_PARAM_<param_name>`, for each parameter value of an invocation.

**Parameters**

- **param_name** (`str`): Name of the action parameter.

**Returns**

- `str`

### Timeout

```python
type roboto.env.Timeout = typing.Optional[typing.Union[float, NotSetType]]
```

`from roboto.env import Timeout`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/env.py#L21-L21)

Timeout of a request to Roboto, in seconds.

`None` waits indefinitely, and `NotSet` uses the client's default timeout.

### resolve_env_variables()

```python
def roboto.env.resolve_env_variables(value: str)
```

`from roboto.env import resolve_env_variables`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/env.py#L28-L52)

Return `value` with each `$NAME` and `${NAME}` replaced by the value of environment variable `NAME`.

A variable that is unset is replaced with the empty string.

**Parameters**

- **value** (`str`): Text that may name environment variables.
