Guides/Basics/04 Set up your license and environment

Set up your license and environment

1from lynx import LYNX
2import os
3
4# 1. Explicit constructor arg — highest precedence
5model = LYNX("lynx-basic", key="LICENSE_KEY")
6
7# 2. Environment variable — picked up automatically
8os.environ["LYNX_API_KEY"] = "LICENSE_KEY"
9model = LYNX("lynx-basic")
10
11# 3. Saved key file from `lynx login` — lowest precedence
12model = LYNX("lynx-basic")

Precedence runs constructor → env var → saved file. This matters: a CI test can override whatever's on disk by passing key= explicitly, a Docker container can inject LYNX_API_KEY at runtime without rebuilding, and a developer can run lynx login once for interactive dev without worrying about that key bleeding into prod.

No license? You get demo mode automatically — 30 days of full functionality from first use, no signup needed. Past the 30-day window, loading the model raises LYNXLicenseError with verdict "LicenseExpired". Pass a valid license key to convert to unlimited use; an invalid or rejected key raises LYNXAuthError at load time.

Verify GPU acceleration: set LYNX_INFERENCE_LOG=1 on the box and re-run. The SDK logs the active execution provider chain to stderr on session build — you should see CoreMLExecutionProvider (macOS), CUDAExecutionProvider or TensorrtExecutionProvider (Linux GPU), DmlExecutionProvider (Windows), or CPUExecutionProvider if none of the above engaged. If you're paying for GPU and seeing CPU, that's the signal something's misconfigured.

Next
Make your code production-ready
A wrong key, an expired license, and a corrupt file each need different handling.