NorbixConfig class

Base configuration for any Norbix SDK client.

Carries the host URL, the API version, credentials (API key and/or bearer token), HTTP timeout and retry policy. Extended by the per-host configs in norbix_api and norbix_hub.

Three ways to construct one:

// 1) Defaults — points at the public norbix.ai endpoint.
final cfg = NorbixConfig(baseUrl: 'https://api.norbix.ai');

// 2) Explicit overrides for self-hosted deployments.
final cfg = NorbixConfig(
  baseUrl: 'http://localhost:5000',
  apiKey: 'nbx_dev_...',
);

// 3) Read everything from environment variables.
final cfg = NorbixConfig.fromEnv(
  baseUrlVar: 'NORBIX_API_URL',
  apiKeyVar:  'NORBIX_API_KEY',
  defaultBaseUrl: 'https://api.norbix.ai',
);
Annotations
  • @immutable

Constructors

NorbixConfig({required String baseUrl, String apiVersion = 'v1', String? apiKey, String? bearerToken, Duration timeout = const Duration(seconds: 30), int maxRetries = 0, Map<String, String>? defaultHeaders})
NorbixConfig.fromEnv({required String defaultBaseUrl, String baseUrlVar = 'NORBIX_BASE_URL', String apiVersionVar = 'NORBIX_API_VERSION', String apiKeyVar = 'NORBIX_API_KEY', String bearerTokenVar = 'NORBIX_BEARER_TOKEN', String timeoutMsVar = 'NORBIX_TIMEOUT_MS', String maxRetriesVar = 'NORBIX_MAX_RETRIES', Map<String, String>? overrides})
Build a config from environment variables. Falls back to defaultBaseUrl when the URL var is not set, so callers always get a usable client.
factory

Properties

apiKey String?
Static API key, sent as x-api-key. Optional.
final
apiVersion String
API version segment injected into routes that contain {version}.
final
baseUrl String
Base URL of the host, e.g. https://api.norbix.ai, https://api.norbix.isidos.lt or http://localhost:5000. Trailing slashes are stripped.
final
bearerToken String?
Bearer JWT token, sent as Authorization: Bearer .... Optional. Wins over apiKey when both are set.
final
defaultHeaders Map<String, String>
Extra headers added to every request.
final
hashCode int
The hash code for this object.
no setterinherited
maxRetries int
How many times to retry transient (5xx, 429, network) failures. Defaults to 0 (no retry). Set to 2–3 for production.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeout Duration
HTTP request timeout. Defaults to 30 s.
final

Methods

copyWith({String? baseUrl, String? apiVersion, String? apiKey, String? bearerToken, Duration? timeout, int? maxRetries, Map<String, String>? defaultHeaders}) NorbixConfig
Returns a copy with selected fields replaced. Useful for runtime token rotation without mutating shared state.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited