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

# Python SDK - OpenFeature provider

> Use Westyx Nexus as an OpenFeature provider in Python applications.

`westyx-nexus-openfeature` ships `NexusProvider`, an [`AbstractProvider`](https://github.com/open-feature/python-sdk) implementation for the [OpenFeature Python SDK](https://github.com/open-feature/python-sdk).

The provider wraps an already-initialized `NexusClient` and delegates all evaluations to its in-memory cache. **No additional I/O or network calls are made by the provider itself.**

Available since **v0.8.0**.

## Installation

The provider is a separate package - install it alongside the main SDK:

```sh theme={null}
pip install westyx-nexus-sdk westyx-nexus-openfeature
```

Both packages are hosted in the same [GitLab PyPI registry](https://gitlab.com/westyx/nexus/sdk/python/-/packages). Add the registry URL first if you have not already done so (see [Installation](installation)).

```text theme={null}
--extra-index-url https://gitlab.com/api/v4/projects/81978638/packages/pypi/simple
westyx-nexus-sdk==0.10.0
westyx-nexus-openfeature==0.10.0
```

## Quick start

```python theme={null}
from westyx_nexus import NexusClient, NexusConfig
from nexus_openfeature import NexusProvider
from openfeature import api as openfeature_api

# 1. Initialize the Nexus client.
client = NexusClient.create(NexusConfig(
    base_url="https://blue-ocean-a5rx7.westyx.dev",
    api_key="wxs_...",
))

# 2. Register the provider once at startup.
openfeature_api.set_provider(NexusProvider(client))

# 3. Evaluate flags and configs using the standard OpenFeature API.
of_client = openfeature_api.get_client("my-service")

enabled = of_client.get_boolean_value("dark-mode", False)
theme   = of_client.get_string_value("ui.theme", "light")
retries = of_client.get_integer_value("http.max-retries", 3)
rate    = of_client.get_float_value("rate-limit.rps", 100.0)
rules   = of_client.get_object_value("routing-rules", {})

# 4. Close the client on shutdown.
client.close()
```

## Evaluation mapping

| OpenFeature method  | Nexus call               | On miss                    | On type mismatch |
| ------------------- | ------------------------ | -------------------------- | ---------------- |
| `get_boolean_value` | `get_flag(key, default)` | returns default (`STATIC`) | n/a              |
| `get_string_value`  | `get_config(key)`        | `FLAG_NOT_FOUND`           | `TYPE_MISMATCH`  |
| `get_integer_value` | `get_config(key)`        | `FLAG_NOT_FOUND`           | `TYPE_MISMATCH`  |
| `get_float_value`   | `get_config(key)`        | `FLAG_NOT_FOUND`           | `TYPE_MISMATCH`  |
| `get_object_value`  | `get_config(key)`        | `FLAG_NOT_FOUND`           | `TYPE_MISMATCH`  |

Integer evaluation accepts `int`, `float`, and numeric strings. Float evaluation accepts any numeric value.

## EvaluationContext

`EvaluationContext` is accepted by all resolve methods but **ignored**. Nexus has no per-user flag targeting; every call returns the same cached value.

## Error details

Use `get_*_details` instead of `get_*_value` to inspect the full resolution:

```python theme={null}
details = of_client.get_string_details("ui.theme", "light")
if details.error_code:
    # FLAG_NOT_FOUND or TYPE_MISMATCH
    print(f"Evaluation error: {details.error_code} - {details.error_message}")
else:
    print(f"Value: {details.value} (reason: {details.reason})")
```
