OptixLog Docs
Python SDK

Installation and Setup

Install the optixlog Python package, check requirements, and run a minimal end-to-end example.

Requirements

  • Python 3.10 or later.
  • An OptixLog API key (sk-opt-...). Keys come in two types: service (for automation) and user (for interactive work).

Install

pip install optixlog

For development (running the test suite or contributing):

pip install -e ".[dev]"

Run this from the root of the python-sdk-spec/ directory when working from source.

Verify the install

optixlog --version
optixlog whoami

If the CLI is not on your path after install, check that your Python environment's bin/ directory is in PATH.

Minimal end-to-end example

The snippet below shows the full lifecycle: construct the client, read project config, ingest a node via the generated typed client, then close the connection.

minimal.py
from optixlog import SDKClient
from optixlog.management import Management

# 1. Build the transport client
client = SDKClient(
    base_url="https://optixlog.leidos.com",
    api_key="sk-opt-your-key-here",
)

# 2. Read a project's config
mgmt = Management(client)
project = mgmt.project("proj_grating_7f3a")
config = project.config.get()
print(f"Project: {config.name!r}  status={config.status}")

# 3. Ingest a node using the generated typed client
#    (run `optixlog generate` first to produce optixlog_gen.py)
from optixlog_gen import OptixClient, Projects, SimulationNode

opt = OptixClient()  # auto-fills base_url and api_key from `optixlog login` or env
result = opt.project(Projects.GRATING_COUPLER_LAB).ingest(
    data=SimulationNode(config={"mesh": "fine"}, solver="fdtd", wavelength_nm=1550.0),
    prompt="FDTD simulation of a grating coupler at 1550 nm.",
)
print(f"Ingested node_id={result.node_id!r}  created={result.created}")

# 4. Always close the client when you're done
client.close()

Generated bindings

OptixClient, Projects, and SimulationNode come from optixlog_gen.py, which is produced by optixlog generate. See Generated Bindings for how to set that up.

Environment variables

You can supply credentials without changing code:

VariablePurpose
OPTIXLOG_API_KEYHighest-precedence key override
OPTIXLOG_BASE_URLOverride the default base URL
OPTIXLOG_CONFIG_HOMEOverride the ~/.optixlog config directory
OPTIXLOG_FIXTUREPath to a JSON fixture for fully offline use

Closing the client

Call client.close() when your program finishes, or use the client as a context manager if your application framework supports it. This releases the underlying HTTP connection pool.

client = SDKClient(base_url="...", api_key="...")
try:
    # ... your work ...
    pass
finally:
    client.close()

Credential hygiene

Never commit ~/.optixlog/credentials.toml. Only optixlog.toml (the non-secret project config) is safe to commit. See Credentials for details on what each file contains.

On this page