westyx_nexus. Both NexusClient (sync) and AsyncNexusClient (async) share the same read API - only the lifecycle methods (sync, connect_stream, close) differ.
Construction
NexusClient.create(config: NexusConfig) -> NexusClient
Synchronous factory. Performs a blocking initial sync.
await AsyncNexusClient.create(config: NexusConfig) -> AsyncNexusClient
Async factory. Same blocking initial sync semantics, but expressed as a coroutine.
Configs
nexus.get_config(key: str, default: Any = None) -> Any
Returns the resolved config value as Any (the wire-decoded JSON value), or default if the key is absent.
nexus.get_config_as(key: str, type_: type[T], default: T | None = None) -> T | None
Returns the config value coerced to the given type, using a standard call (type_(value)).
nexus.get_all_configs() -> dict[str, Any]
Snapshot copy of every config key-value pair currently in the cache.
Feature flags
nexus.get_flag(key: str, default: bool = False) -> bool
Returns the is_active state of a flag, or default when the key is absent.
nexus.get_all_flags() -> dict[str, bool]
Snapshot copy of every flag key-is_active pair in the cache.
AB Testing (v0.3.0)
nexus.evaluate_ab(keys: list[str], user_id: str, attributes: dict[str, Any]) -> dict[str, bool]
Batch-evaluate AB Testing flags for a given user. Issues a single POST /v1/flags/evaluate-ab request; the server applies each flag’s rollout / targeting rules to the supplied user_id and attributes, and returns a key -> bool map.
Unlike get_flag, this is a network call - the result depends on user_id, so it cannot be served from the local snapshot cache.
Secrets (secret key only)
nexus.get_secret(key: str) -> str
Returns the plaintext value of a text-type secret.
nexus.get_secret_file_path(key: str) -> str | None (v0.3.0)
Returns the on-disk path of a file-type secret, or None.
The SDK materialises the value as a temp file on every sync and exposes the absolute path here:
None for text-type secrets, unknown keys, or when the on-disk write failed - fall back to get_secret for text-type values.
Secrets - Write API (v0.5.0) (secret key only)
nexus.set_secret(key: str, value: str, secret_type: str = "text") -> None
Creates or updates a secret with the given key and value.
nexus.delete_secret(key: str) -> None
Deletes a secret by key.
nexus.delete_secret_version(key: str, version: int) -> None (v0.5.0)
Deletes a specific version of a secret.
Metadata
Sync / lifecycle (sync API)
nexus.sync() -> None
Forces a sync now, bypassing the TTL. Rarely needed - the SDK syncs automatically.
nexus.connect_stream() -> None / nexus.disconnect_stream() -> None
Start/stop the SSE thread. The SDK calls connect_stream() automatically after the initial sync (unless stream=False in config). Idempotent.
nexus.close() -> None
Stops the SSE thread and releases the underlying HTTP client. Always call on shutdown (or use a with block).
Sync / lifecycle (async API)
The async client has matching coroutine versions:async with await AsyncNexusClient.create(config) as nexus: for guaranteed cleanup.
Error types
Logger interface
Protocol - any object with these three methods qualifies. The SDK ships a StdlibNexusLogger adapter that forwards to the stdlib logging module.