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

# DynexConfig

> Configuration handler for credentials, backend selection, and SDK behavior

# DynexConfig

Handles all SDK configuration: credentials, compute backend, gRPC endpoint, timeouts, and output formatting.

```python theme={null}
from dynex import DynexConfig, ComputeBackend, QPUModel
```

## Constructor

```python theme={null}
DynexConfig(
    sdk_key: Optional[str] = None,
    grpc_endpoint: Optional[str] = None,
    solver_path: Optional[str] = None,
    compute_backend: Union[ComputeBackend, str] = ComputeBackend.UNSPECIFIED,
    qpu_model: Optional[Union[QPUModel, str]] = None,
    use_notebook_output: bool = True,
    default_timeout: float = 300.0,
    default_description: str = "Dynex SDK Job",
    retry_count: int = 5,
    preserve_solutions: bool = False,
    remove_local_solutions: bool = False,
    debug_save_solutions: bool = False,
    dotenv_path: Optional[str] = None,
)
```

## Parameters

<ParamField path="sdk_key" type="str" optional>
  SDK authentication key. If not provided, loaded from `DYNEX_SDK_KEY` environment variable or `.env` file.
</ParamField>

<ParamField path="grpc_endpoint" type="str" optional>
  gRPC server endpoint. Defaults to `"127.0.0.1:9090"`. Set via `DYNEX_GRPC_ENDPOINT` env var or provide directly.

  Production: `"quantum-router-engine-grpc.hz.dynex.co:3000"`
</ParamField>

<ParamField path="compute_backend" type="ComputeBackend | str" default="ComputeBackend.UNSPECIFIED">
  Compute backend to use. Accepts enum value or string:

  | Value                  | String    | Description                                        |
  | ---------------------- | --------- | -------------------------------------------------- |
  | `ComputeBackend.GPU`   | `"gpu"`   | **Dynex neuromorphic GPU chips — primary backend** |
  | `ComputeBackend.QPU`   | `"qpu"`   | Specific QPU hardware model                        |
  | `ComputeBackend.CPU`   | `"cpu"`   | CPU workers on the network                         |
  | `ComputeBackend.LOCAL` | `"local"` | Local binary, no network required                  |
</ParamField>

<ParamField path="qpu_model" type="QPUModel | str" optional>
  Required when `compute_backend=QPU`. Available models:

  | Value                   | String           |
  | ----------------------- | ---------------- |
  | `QPUModel.APOLLO_RC1`   | `"apollo_rc1"`   |
  | `QPUModel.APOLLO_10000` | `"apollo_10000"` |
</ParamField>

<ParamField path="use_notebook_output" type="bool" default="True">
  Enable Jupyter-friendly output formatting (progress bars, tables).
</ParamField>

<ParamField path="default_timeout" type="float" default="300.0">
  Job timeout in seconds. Applies to network backends.
</ParamField>

<ParamField path="default_description" type="str" default="&#x22;Dynex SDK Job&#x22;">
  Default job description shown in the Dynex job dashboard.
</ParamField>

<ParamField path="retry_count" type="int" default="5">
  Number of retries for transient network failures.
</ParamField>

<ParamField path="preserve_solutions" type="bool" default="False">
  If `True`, keep solution files on disk after sampling completes. Applies to `LOCAL` backend only — network backends store solutions in memory.
</ParamField>

<ParamField path="remove_local_solutions" type="bool" default="False">
  If `True`, automatically delete local solution files after reading. Applies to `LOCAL` backend only.
</ParamField>

<ParamField path="debug_save_solutions" type="bool" default="False">
  If `True`, write solution data to disk even when using a network backend (CPU, GPU, QPU). Files are saved to the `tmp/` directory alongside job files. Useful for debugging raw solver output without switching to `LOCAL` mode.
</ParamField>

<ParamField path="dotenv_path" type="str" optional>
  Custom path to `.env` file. If not provided, searches current directory and up to 3 parent directories.
</ParamField>

<ParamField path="solver_path" type="str" optional>
  Custom path to directory containing `dynexcore` binary (LOCAL mode only).
</ParamField>

## Configuration priority

Parameters are resolved in this order (highest to lowest priority):

1. Constructor arguments
2. Environment variables (`DYNEX_SDK_KEY`, `DYNEX_GRPC_ENDPOINT`, etc.)
3. `.env` file values (if `python-dotenv` is installed)
4. Default values

## Examples

```python theme={null}
from dynex import DynexConfig, ComputeBackend, QPUModel

# GPU — Dynex neuromorphic chips, primary production backend
config = DynexConfig(compute_backend=ComputeBackend.GPU)

# QPU — specific hardware model
config = DynexConfig(
    compute_backend=ComputeBackend.QPU,
    qpu_model=QPUModel.APOLLO_RC1,
    default_timeout=600.0,
    default_description="Production portfolio optimization",
)

# CPU — lightweight network testing
config = DynexConfig(compute_backend=ComputeBackend.CPU)

# LOCAL — offline development, no credentials needed
config = DynexConfig(compute_backend=ComputeBackend.LOCAL)

# Inspect configuration
print(config.as_dict())
print(config.get_platform_prefix())  # "APOLLO-RC1" | "CPU" | "LOCAL" etc.
```

## `as_dict()` method

Returns all configuration parameters as a dictionary:

```python theme={null}
config.as_dict()
# {
#   'sdk_key': '...',
#   'grpc_endpoint': 'quantum-router-engine-grpc.hz.dynex.co:3000',
#   'mainnet': True,
#   'solver_path': None,
#   'retry_count': 5,
#   'compute_backend': 'qpu',
#   'qpu_model': 'apollo_rc1',
#   'use_notebook_output': True,
#   'default_timeout': 300.0,
#   'default_description': 'Dynex SDK Job',
#   'preserve_solutions': False,
#   'remove_local_solutions': False,
#   'debug_save_solutions': False,
# }
```

## Errors

| Exception           | Cause                                                                                |
| ------------------- | ------------------------------------------------------------------------------------ |
| `ValueError`        | Invalid `compute_backend` or `qpu_model` string; missing `qpu_model` for QPU backend |
| `FileNotFoundError` | `dynexcore` binary not found in LOCAL mode                                           |
| `PermissionError`   | Cannot create `tmp/` directory                                                       |
