Skip to main content

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:

  1. an argument to zyonix.init();
  2. a ZYONIX_* environment variable;
  3. zyonix.yaml;
  4. the built-in default.

Exceptions to this order:

SettingRule
captureThere is no environment variable. init(capture=...) wins over the file; without either, it is hash_only.
egress_allowZYONIX_EGRESS_ALLOW adds hosts to the file's list. init(egress_allow=...) replaces the list.
modeIf none of the three sets it: remote when there is an API key, off when there is none.
An invalid zyonix.yamlTurns tracing off, whatever the arguments and variables say (see The configuration file).

Environment variables​

Every variable the SDK reads:

VariableSettingDefaultMeaning
ZYONIX_API_KEYapi_keynoneAn sdk key (zx_sdk_...). Without it, remote mode is off. Never put it in zyonix.yaml.
ZYONIX_ENDPOINTendpointhttp://localhost:8000Your Zyonix address, for example https://zyonix.example.com.
ZYONIX_EGRESS_ALLOWegress_allowemptyPublic 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_FILEca_filenonePath of a PEM file with the certificate authority to trust, for a server with a private certificate.
ZYONIX_SERVICEserviceunknown-serviceName of the application.
ZYONIX_RELEASEreleasenoneThe deployed version (git commit, build id).
ZYONIX_MODEmodesee Modesremote, local, console or off.
ZYONIX_LOCAL_PATHlocal_pathzyonix-traces.jsonlFile that local mode appends to, relative to the working directory.
ZYONIX_CONFIGconfig filezyonix.yamlPath of the configuration file.
ZYONIX_LOCAL_ONLYlocal_onlytruefalse lifts the data-boundary check. 1/true/yes/on and 0/false/no/off; anything else means true.
ZYONIX_OTEL_PROVIDERotel_providerprivateprivate or shared (see OpenTelemetry). Other values are ignored.
ZYONIX_GUARD_POLICYGuard policy filenoneRuntime repair only; has no effect in customer installations.
ZYONIX_DEBUGzyonix commandoff1: the zyonix command prints a (scrubbed) traceback on an unexpected error.
NO_COLORzyonix commandoffAny 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 starter file says capture: full

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​

SituationResult
No fileDefaults; capture is hash_only.
The file named by ZYONIX_CONFIG or config_file does not existDefaults, with a warning.
The file is empty or only commentsDefaults, with a warning.
A valid file that does not set captureIts settings, with capture hash_only.
A file that exists but is invalid: a YAML syntax error, an unknown key, a wrong type or valueTracing 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
KeyTypeDefaultMeaning
servicestringunknown-serviceName of the application.
endpointURLhttp://localhost:8000Your Zyonix address. Use https://.
ca_filepathnonePEM bundle of a private certificate authority to trust for the endpoint.
moderemote, local, console, offautomaticSee Modes.
capturefull, hash_onlyhash_onlySee Capture.
redaction.presetslist[email, phone, iban, card_number]Built-in masks: email, phone, iban, card_number, national_id. An empty list turns them off.
redaction.custom_patternslist[]Your own masks; see Redaction.
max_payload_bytesinteger, at least 1024524288See Payload size.
local_pathpathzyonix-traces.jsonlThe file local mode appends to.
instrumentauto, none or a listautoWhich LLM libraries to record. See LLM libraries.
local_onlybooleantrueSee Data boundary.
egress_allowlist of host names[]See Data boundary.
otel_providerprivate, sharedprivateSee OpenTelemetry.
export.queue_sizeinteger, at least 162048Spans waiting to be sent. When full, new spans are dropped and counted.
export.queue_max_bytesinteger, at least 1 MB268435456 (256 MB)The same limit in bytes, so a slow server can never fill your process's memory.
export.batch_sizeinteger, at least 1256Spans per request.
export.schedule_delay_snumber above 01.0Seconds between sends.
export.timeout_snumber above 05.0Timeout of one request.
export.max_batch_bytesinteger, at least 655364194304 (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.compressiongzip, nonegzipRequest compression.
replay.setupmodule:functionnoneUsed by zyonix test / zyonix replay: called once before any case runs.
replay.config_providermodule:functionnoneReturns the configuration (a dict) your application uses now.
replay.config_argstringconfigThe replayable step's argument that receives that configuration.
replay.python_pathlist of paths[]Extra folders to import your code from (the working directory is always included).
guard.enabledbooleantruefalse turns runtime repair off for good. Runtime repair does not run in customer installations anyway.
guard.policy_filepathnoneRuntime 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​

ModeWhat happensChosen when
remoteSends to your Zyonix server over HTTPS, in the background.default when an API key is set
localAppends everything to a JSON Lines file (local_path) instead. No key needed, nothing leaves the machine.ZYONIX_MODE=local, for development and checks
consolePrints one line per span to standard error (kind, name, duration, trace id, doc_id, status). No content.ZYONIX_MODE=console, for a quick look
offNothing 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
ContentEvery 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 checkedNo: shown as not checkedYes
Causes, evidence, groundingNoYes
zyonix test, zyonix replayNot availableAvailable

Things to know:

  • Full capture is never a default. Content is sent only if a zyonix.yaml that was read and validated says capture: full, or your code calls zyonix.init(capture="full"). An unknown value means hash_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_only data 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 doctor reports the capture in use and where it came from: capture=full (set in zyonix.yaml), (set in init()), or capture=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​

PresetMasksOn by default
emailemail addressesyes
phonephone numbers written with a country code (+44 20 7946 0958) or in the North American (555) 555-0100 formyes
ibanIBANs, compact or in groups of fouryes
card_numberpayment card numbersyes
national_idnational identity numbersno

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*"
FieldRequiredMeaning
nameyesLabel used in the mask, upper-cased: [REDACTED:CUSTOMER_REF].
patternyesA Python regular expression.
contextnoMask a match only when this regular expression matches within window characters before it, or names the JSON field the value is stored under.
unlessnoKeep 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).
windownoCharacters 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 notes is 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, .example or .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