Configuration
The SDK takes its settings from three places: arguments to zyonix.init(), environment variables
whose names start with ZYONIX_, and an optional file, zyonix.yaml. Most applications need only
two environment variables, ZYONIX_ENDPOINT and ZYONIX_API_KEY, plus ZYONIX_EGRESS_ALLOW when
the Zyonix address is a public name.
To see what the SDK actually uses in a given environment, run zyonix doctor there. Its first lines
show the file it read, the service, mode, capture, redaction, endpoint and (masked) key.
Precedence
For each setting, the first of these that sets it wins:
- an argument to
zyonix.init(); - a
ZYONIX_*environment variable; zyonix.yaml;- the built-in default.
Exceptions to this order:
| Setting | Rule |
|---|---|
capture | There is no environment variable. init(capture=...) wins over the file; without either, it is hash_only. |
egress_allow | ZYONIX_EGRESS_ALLOW adds hosts to the file's list. init(egress_allow=...) replaces the list. |
mode | If none of the three sets it: remote when there is an API key, off when there is none. |
An invalid zyonix.yaml | Turns tracing off, whatever the arguments and variables say (see The configuration file). |
Environment variables
Every variable the SDK reads:
| Variable | Setting | Default | Meaning |
|---|---|---|---|
ZYONIX_API_KEY | api_key | none | An sdk key (zx_sdk_...). Without it, remote mode is off. Never put it in zyonix.yaml. |
ZYONIX_ENDPOINT | endpoint | http://localhost:8000 | Your Zyonix address, for example https://zyonix.example.com. |
ZYONIX_EGRESS_ALLOW | egress_allow | empty | Public host names the SDK may send to, separated by commas: zyonix.example.com. A https:// prefix is removed; no wildcards, ports or paths. |
ZYONIX_CA_FILE | ca_file | none | Path of a PEM file with the certificate authority to trust, for a server with a private certificate. |
ZYONIX_SERVICE | service | unknown-service | Name of the application. |
ZYONIX_RELEASE | release | none | The deployed version (git commit, build id). |
ZYONIX_MODE | mode | see Modes | remote, local, console or off. |
ZYONIX_LOCAL_PATH | local_path | zyonix-traces.jsonl | File that local mode appends to, relative to the working directory. |
ZYONIX_CONFIG | config file | zyonix.yaml | Path of the configuration file. |
ZYONIX_LOCAL_ONLY | local_only | true | false lifts the data-boundary check. 1/true/yes/on and 0/false/no/off; anything else means true. |
ZYONIX_OTEL_PROVIDER | otel_provider | private | private or shared (see OpenTelemetry). Other values are ignored. |
ZYONIX_GUARD_POLICY | Guard policy file | none | Runtime repair only; has no effect in customer installations. |
ZYONIX_DEBUG | zyonix command | off | 1: the zyonix command prints a (scrubbed) traceback on an unexpected error. |
NO_COLOR | zyonix command | off | Any value: plain output without colour. |
An empty variable counts as not set.
The SDK also sends the OpenTelemetry resource attributes of its process, which include anything in
the standard OTEL_RESOURCE_ATTRIBUTES variable. Do not put secrets or personal data there.
Arguments to init
zyonix.init(api_key=, service=, release=, endpoint=, mode=, config_file=, **options). The options
are capture, ca_file, local_only, egress_allow, otel_provider, instrument, local_path,
max_payload_bytes, redaction_presets, custom_patterns and the export settings. The full table
is in the API reference.
Keep the key and the address out of your code: pass service and release, and leave the rest to
the environment and the file.
The configuration file, zyonix.yaml
The SDK looks for zyonix.yaml in the working directory of the process (the folder it was
started from), or at the path in ZYONIX_CONFIG or init(config_file=...). The file is optional.
zyonix init writes a commented starter file:
zyonix init --service invoice-extractor --endpoint https://zyonix.example.com
It refuses to overwrite an existing file unless you add --force. Options: --service
(default my-extraction-service), --endpoint (default http://localhost:8000), --path
(default zyonix.yaml).
The file zyonix init writes contains capture: full, which sends your redacted documents to
Zyonix. That line comes from the template; it is not a decision. Change it to capture: hash_only
until you have agreed what may be sent. See Capture.
How the file is read
| Situation | Result |
|---|---|
| No file | Defaults; capture is hash_only. |
The file named by ZYONIX_CONFIG or config_file does not exist | Defaults, with a warning. |
| The file is empty or only comments | Defaults, with a warning. |
A valid file that does not set capture | Its settings, with capture hash_only. |
| A file that exists but is invalid: a YAML syntax error, an unknown key, a wrong type or value | Tracing is off until it is fixed, with a warning that names the error type. zyonix doctor shows the full reason. Your application keeps running. |
Tracing stops for an invalid file because the SDK cannot know what the file meant to restrict
(hash_only, local mode, redaction patterns). Unknown keys are errors too, so a typo cannot
silently drop a setting.
Every key
service: invoice-extractor # name of the application
endpoint: https://zyonix.example.com # your Zyonix address
ca_file: zyonix-ca.pem # only for a private certificate authority
mode: remote # remote | local | console | off
capture: hash_only # hash_only | full
redaction:
presets: [email, phone, iban, card_number] # also: national_id
custom_patterns:
- name: customer_ref
pattern: "CUST-[0-9]{6}"
max_payload_bytes: 524288 # 512 KB
local_path: zyonix-traces.jsonl # the file local mode writes
instrument: auto # auto | none | [openai, anthropic, ...]
local_only: true # data boundary
egress_allow: [zyonix.example.com] # public hosts you allow
otel_provider: private # private | shared
export:
queue_size: 2048
queue_max_bytes: 268435456
batch_size: 256
schedule_delay_s: 1.0
timeout_s: 5.0
max_batch_bytes: 4194304
compression: gzip # gzip | none
replay:
setup: invoice_extractor.zyonix_hooks:setup
config_provider: invoice_extractor.zyonix_hooks:current_config
config_arg: config
python_path: [src]
guard:
enabled: true
policy_file: null
| Key | Type | Default | Meaning |
|---|---|---|---|
service | string | unknown-service | Name of the application. |
endpoint | URL | http://localhost:8000 | Your Zyonix address. Use https://. |
ca_file | path | none | PEM bundle of a private certificate authority to trust for the endpoint. |
mode | remote, local, console, off | automatic | See Modes. |
capture | full, hash_only | hash_only | See Capture. |
redaction.presets | list | [email, phone, iban, card_number] | Built-in masks: email, phone, iban, card_number, national_id. An empty list turns them off. |
redaction.custom_patterns | list | [] | Your own masks; see Redaction. |
max_payload_bytes | integer, at least 1024 | 524288 | See Payload size. |
local_path | path | zyonix-traces.jsonl | The file local mode appends to. |
instrument | auto, none or a list | auto | Which LLM libraries to record. See LLM libraries. |
local_only | boolean | true | See Data boundary. |
egress_allow | list of host names | [] | See Data boundary. |
otel_provider | private, shared | private | See OpenTelemetry. |
export.queue_size | integer, at least 16 | 2048 | Spans waiting to be sent. When full, new spans are dropped and counted. |
export.queue_max_bytes | integer, at least 1 MB | 268435456 (256 MB) | The same limit in bytes, so a slow server can never fill your process's memory. |
export.batch_size | integer, at least 1 | 256 | Spans per request. |
export.schedule_delay_s | number above 0 | 1.0 | Seconds between sends. |
export.timeout_s | number above 0 | 5.0 | Timeout of one request. |
export.max_batch_bytes | integer, at least 65536 | 4194304 (4 MB) | Bytes of one request before compression. If the server or a proxy answers "too large" (HTTP 413), the SDK halves it by itself. |
export.compression | gzip, none | gzip | Request compression. |
replay.setup | module:function | none | Used by zyonix test / zyonix replay: called once before any case runs. |
replay.config_provider | module:function | none | Returns the configuration (a dict) your application uses now. |
replay.config_arg | string | config | The replayable step's argument that receives that configuration. |
replay.python_path | list of paths | [] | Extra folders to import your code from (the working directory is always included). |
guard.enabled | boolean | true | false turns runtime repair off for good. Runtime repair does not run in customer installations anyway. |
guard.policy_file | path | none | Runtime repair only. |
The API key has no key in the file, on purpose: it comes only from ZYONIX_API_KEY (or
init(api_key=...)).
Modes
| Mode | What happens | Chosen when |
|---|---|---|
remote | Sends to your Zyonix server over HTTPS, in the background. | default when an API key is set |
local | Appends everything to a JSON Lines file (local_path) instead. No key needed, nothing leaves the machine. | ZYONIX_MODE=local, for development and checks |
console | Prints one line per span to standard error (kind, name, duration, trace id, doc_id, status). No content. | ZYONIX_MODE=console, for a quick look |
off | Nothing is recorded; every decorator is a pass-through. | default when there is no API key |
remote without a key falls back to off with a warning. An unknown mode also means off.
Local mode writes exactly what remote mode would send (after redaction, capture and size limits), which makes it the way to check what leaves your process. See Testing locally.
Capture: hash_only and full
Capture decides whether content leaves your process.
hash_only (default) | full | |
|---|---|---|
| Content | Every piece of content is replaced by its SHA-256 hash before it leaves the process: document text, prompts, AI answers, step inputs and outputs, the output record, exception messages, check details, corrections, and whatever the LLM instrumentation records. | The redacted content is sent: document text, prompts, AI answers, step inputs and outputs, the output record, exception messages, check details, corrections and the file name (doc_name). |
| Always sent in clear (both modes) | doc_id, source, service, release; step, function, tool and check names; the schema name; model names, token counts, timings, statuses, finish reasons, exception types; feedback verdicts and reviewer; the OpenTelemetry resource (including OTEL_RESOURCE_ATTRIBUTES) | the same |
| Documents checked | No: shown as not checked | Yes |
| Causes, evidence, grounding | No | Yes |
zyonix test, zyonix replay | Not available | Available |
Things to know:
- Full capture is never a default. Content is sent only if a
zyonix.yamlthat was read and validated sayscapture: full, or your code callszyonix.init(capture="full"). An unknown value meanshash_only. - A hash is not anonymous. Each value is hashed on its own with plain SHA-256, without a
secret, so a short or guessable value (an amount, an invoice number) can be checked against its
hash. Treat
hash_onlydata as pseudonymised, not anonymous. - Redaction is not complete anonymisation either. It masks the patterns you configured. Check what would be sent in local mode before you switch to full capture.
zyonix doctorreports the capture in use and where it came from:capture=full (set in zyonix.yaml),(set in init()), orcapture=hash_only: no configuration file was loaded.
A span that cannot be prepared safely for sending (for example a value nested too deeply to redact) is not sent as it is: the value is replaced by its hash, or the span is withheld and counted.
Redaction
Redaction runs in your process, before anything is sent, in every capture mode (in hash_only
the hash is taken of the redacted text). A masked value is replaced by [REDACTED:<NAME>], for
example [REDACTED:EMAIL].
Presets
| Preset | Masks | On by default |
|---|---|---|
email | email addresses | yes |
phone | phone numbers written with a country code (+44 20 7946 0958) or in the North American (555) 555-0100 form | yes |
iban | IBANs, compact or in groups of four | yes |
card_number | payment card numbers | yes |
national_id | national identity numbers | no |
Choosing presets replaces the default list:
redaction:
presets: [email, phone, iban, card_number, national_id]
Your own patterns
Add a pattern for each kind of value in your documents that must not leave your process: customer numbers, policy numbers, names after a known label.
redaction:
custom_patterns:
# mask every customer reference
- name: customer_ref
pattern: "CUST-[0-9]{6}"
# mask a 10-digit number only after a "Mobile" or "Tel" label, or under a JSON field named so
- name: mobile
pattern: "[0-9]{10}"
context: "(?i)mobile|tel"
window: 32
# mask 10-digit numbers, except right after the printed label "Invoice No:"
- name: account_number
pattern: "[0-9]{10}"
unless: "Invoice No\\s*:\\s*"
| Field | Required | Meaning |
|---|---|---|
name | yes | Label used in the mask, upper-cased: [REDACTED:CUSTOMER_REF]. |
pattern | yes | A Python regular expression. |
context | no | Mask a match only when this regular expression matches within window characters before it, or names the JSON field the value is stored under. |
unless | no | Keep a match readable when this regular expression matches within window characters before it in the text itself (a printed label; never a JSON field name). |
window | no | Characters searched before a match, 1 to 200. Default 32. |
How patterns are applied:
- Each string inside a value is redacted on its own, before the value is turned into JSON. So
write patterns for the document text as it is: a line break is a real newline (use
^with(?m), or\b), never the two characters\n, and never JSON syntax such as"invoice_no": ". - A JSON field name is a context, never an exemption: a value under a field called
notesis still masked if it matches. - Within one run, a value is masked the same way everywhere: masked once because of its context, masked in every other payload of that run too. That keeps the document and the extracted record comparable.
- Patterns run on your application's thread, on every payload. Keep them simple and linear (no
nested repetition such as
(a+)+), and test them on a large document.
In YAML, prefer double-quoted strings for patterns and double each backslash ("\\d"), or use
single quotes ('\d').
Payload size
max_payload_bytes (default 512 KB) caps each step input, step output, output record and
instrumentation attribute. A larger one is cut and marked truncated. Your application is not
affected, but Zyonix then sees only part of the document:
- values it cannot find in that part are reported as not verified, not as failures;
- a truncated output record makes the document not checkable;
- a truncated input of the replayable step cannot become a regression case (the SDK warns once per step).
If your documents are larger than 512 KB of text, raise it:
max_payload_bytes: 2097152 # 2 MB
Requests to the server are limited separately by export.max_batch_bytes.
Data boundary
The SDK sends data to exactly one place: the configured endpoint. By default (local_only: true)
it does so only if the endpoint is local by its address:
localhost,*.localhost,127.0.0.0/8,::1;- a private or link-local IP address (
10.x,172.16-31.x,192.168.x,169.254.x,fc00::/7,fe80::/10); - a name without a dot (
zyonix,api: Docker Compose service names, intranet hosts), or a name ending in.local,.internal,.lan,.home.arpa,.localhost,.test,.exampleor.invalid.
Any other host, such as zyonix.example.com, is refused until you list it:
egress_allow: [zyonix.example.com]
export ZYONIX_EGRESS_ALLOW=zyonix.example.com
A refused endpoint turns remote tracing off (your application is unaffected) and logs a warning
that names the host. zyonix doctor reports it as boundary.endpoint. The check looks at the
address only; it does not resolve names. local_only: false lifts it entirely, which is rarely
what you want: listing your host is safer.
Independently of that, the SDK refuses plain http:// to a public host (the key and your
documents would cross the internet unencrypted), whatever egress_allow says. Plain http:// to a
local or private address works, with a warning unless it is this machine (localhost). Use the
https:// address.
The SDK never follows redirects: a server that redirects (for example from http:// to
https://) is reported by zyonix doctor with the address to use instead.
Private certificate authority
If your Zyonix server uses a certificate from your organisation's own certificate authority, Python
does not trust it and the connection fails with CERTIFICATE_VERIFY_FAILED. Give the SDK the
authority's certificate (a public .pem file your administrator provides):
export ZYONIX_CA_FILE=/etc/zyonix/zyonix-ca.pem
$env:ZYONIX_CA_FILE = "C:\zyonix\zyonix-ca.pem"
or ca_file: zyonix-ca.pem in zyonix.yaml. With it, the SDK trusts only that authority for
the endpoint, not the system's list. Never turn certificate checking off.
OpenTelemetry in your application
The SDK uses OpenTelemetry internally, on a private tracer provider that it never installs as the global one. If your application has its own OpenTelemetry setup:
- your exporters never receive Zyonix spans, and Zyonix never receives your spans;
- only traces that start with a Zyonix run are sent to Zyonix.
otel_provider: shared makes the SDK join your application's global tracer provider instead.
Then your own exporters also receive Zyonix spans and the LLM instrumentation's attributes,
including prompts and answers, unredacted, because redaction happens only on the way to Zyonix.
zyonix doctor warns when it is set. Use it only if you want your other tracing tool to show the
Zyonix runs.
See also LLM libraries.
Examples
Production, hash_only, public address:
export ZYONIX_ENDPOINT=https://zyonix.example.com
export ZYONIX_EGRESS_ALLOW=zyonix.example.com
export ZYONIX_API_KEY=zx_sdk_xxxxxxxx
export ZYONIX_RELEASE=$(git rev-parse --short HEAD)
Production, full capture, with a file next to the application:
# zyonix.yaml
service: invoice-extractor
endpoint: https://zyonix.example.com
egress_allow: [zyonix.example.com]
capture: full
redaction:
presets: [email, phone, iban, card_number]
custom_patterns:
- {name: customer_ref, pattern: "CUST-[0-9]{6}"}
max_payload_bytes: 1048576
export ZYONIX_API_KEY=zx_sdk_xxxxxxxx
A self-hosted server on the internal network (local by address, no egress_allow needed):
export ZYONIX_ENDPOINT=https://zyonix.internal
export ZYONIX_CA_FILE=/etc/zyonix/zyonix-ca.pem
export ZYONIX_API_KEY=zx_sdk_xxxxxxxx
Development, nothing sent:
export ZYONIX_MODE=local
export ZYONIX_LOCAL_PATH=zyonix-dev.jsonl