OptixLog Docs
Python SDK

Initializing the Client

Construct SDKClient and the generated OptixClient, configure timeouts and retries, and manage the connection lifecycle.

The SDK has two client classes with different responsibilities.

  • SDKClient — the raw transport. You construct it explicitly with a base URL and API key. Pass it to Management or Pipeline to make API calls.
  • OptixClient — the generated typed client produced by optixlog generate. It wraps SDKClient internally and auto-fills credentials from your saved login or environment variables. Its project() method is overloaded per project, so the type checker knows which node types each project accepts.

Constructing SDKClient

sdk_client.py
from optixlog import SDKClient

client = SDKClient(
    base_url="https://optixlog.leidos.com",  # required
    api_key="sk-opt-your-key-here",           # required
    timeout_seconds=30.0,                     # default: 30.0
    max_retries=2,                            # default: 2
    user_agent="my-pipeline/1.0",             # optional, appended to User-Agent header
    default_headers={"X-Request-Source": "my-app"},  # optional extra headers on every request
)

Parameters

Prop

Type

Getting a project reference

SDKClient.project creates a lightweight ProjectRef — an id-only reference you pass to Management or Pipeline:

ref = client.project("proj_grating_7f3a")
# ref.id == "proj_grating_7f3a"

ProjectRef does not make any network calls on its own. It exists so you can pass project ids around without hardcoding string literals throughout your code.

Constructing the generated OptixClient

The generated OptixClient (in optixlog_gen.py) wraps SDKClient and fills in credentials from your saved profile or environment variables.

optix_client.py
from optixlog_gen import OptixClient

# Auto-fill from `optixlog login` credentials or OPTIXLOG_API_KEY / OPTIXLOG_BASE_URL env vars
opt = OptixClient()

# Or provide credentials explicitly
opt = OptixClient(
    base_url="https://optixlog.leidos.com",
    api_key="sk-opt-your-key-here",
)

The underlying SDKClient is available as opt.sdk if you need to pass it to Management:

from optixlog.management import Management

opt = OptixClient()
mgmt = Management(opt.sdk)
project = mgmt.project_from(opt.sdk.project("proj_grating_7f3a"))

Client lifecycle

Both SDKClient and OptixClient hold an HTTP connection pool. Call .close() when your program finishes to release those resources cleanly.

lifecycle.py
from optixlog import SDKClient

client = SDKClient(base_url="...", api_key="...")
try:
    # ... use Management, Pipeline, etc. ...
    pass
finally:
    client.close()

For the generated client:

from optixlog_gen import OptixClient

opt = OptixClient()
try:
    # ... ingest nodes, etc. ...
    pass
finally:
    opt.close()   # closes the underlying SDKClient

Short-lived scripts

In a short-lived script where the process exits immediately after the SDK calls, not calling close() is safe — the OS reclaims the connections on exit. In long-running services or test suites, always close explicitly to avoid connection leaks.

Credential precedence

When constructing SDKClient directly, you supply both arguments explicitly. For the generated OptixClient the SDK resolves them in this order:

API key: OPTIXLOG_API_KEY env var → --api-key flag → stored profile → interactive prompt.

Base URL: --base-url flag → OPTIXLOG_BASE_URL env var → stored profile → default (https://optixlog.leidos.com).

See Environment Variables and Credentials for the full resolution rules.

On this page