> ## 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.

# API Reference

> Complete reference for all Dynex SDK classes and methods

# API Reference

The Dynex SDK exposes a small, focused set of classes. All public API is importable directly from the `dynex` package.

## Core classes

```python theme={null}
import dynex
from dynex import (
    DynexConfig,      # Configuration and credentials
    DynexSampler,     # Run annealing jobs
    DynexCircuit,     # Run gate circuits
    BQM,              # Binary Quadratic Model wrapper
    CQM,              # Constrained Quadratic Model wrapper
    DQM,              # Discrete Quadratic Model wrapper
    ComputeBackend,   # Backend enum (LOCAL, CPU, GPU, QPU)
    QPUModel,         # QPU hardware model enum
)
```

## Quick reference

| Class                                          | Purpose                                    |
| ---------------------------------------------- | ------------------------------------------ |
| [`DynexConfig`](/api-reference/dynex-config)   | Credentials, backend selection, timeouts   |
| [`DynexSampler`](/api-reference/dynex-sampler) | Submit annealing jobs and retrieve results |
| [`BQM`](/api-reference/models)                 | Wrap a dimod BinaryQuadraticModel          |
| [`CQM`](/api-reference/models)                 | Wrap a dimod ConstrainedQuadraticModel     |
| [`DQM`](/api-reference/models)                 | Wrap a dimod DiscreteQuadraticModel        |
| [`DynexCircuit`](/api-reference/dynex-circuit) | Submit gate circuit jobs                   |
| `ComputeBackend`                               | Enum: `LOCAL`, `CPU`, `GPU`, `QPU`         |
| `QPUModel`                                     | Enum: `APOLLO_RC1`, `APOLLO_10000`         |

## Minimal example

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

bqm = dimod.BinaryQuadraticModel({0: -1, 1: -1}, {(0, 1): 2}, 0.0, 'BINARY')
config = DynexConfig(compute_backend=ComputeBackend.GPU)
model = dynex.BQM(bqm)
sampler = dynex.DynexSampler(model, config=config)
sampleset = sampler.sample(num_reads=1000, annealing_time=200)
print(sampleset.first.sample, sampleset.first.energy)
```

## Return types

All samplers return a dimod [`SampleSet`](https://docs.ocean.dwavesys.com/en/stable/docs_dimod/reference/sampleset.html):

```python theme={null}
sampleset.first           # Best sample (lowest energy)
sampleset.first.sample    # dict: {variable: value}
sampleset.first.energy    # float: objective value
sampleset.samples()       # Iterator over all samples
sampleset.to_pandas_dataframe()  # pandas DataFrame
```
