OptixLog Docs
API Reference

OptixClient

Generated typed client — auto-fills credentials from your saved login and provides per-project overloaded ingest methods.

OptixClient is not part of the installed optixlog package. It is emitted into your repository by optixlog generate as optixlog_gen.py (or a package). You import it from that generated file.

from optixlog_gen import OptixClient

OptixClient wraps SDKClient and Pipeline and exposes a project(id) method that is overloaded per project ID. Passing a node type that does not belong to a given project is a static type error caught by pyright (reportArgumentType) or mypy ([call-overload]) before you ever run your code.

See Generated Bindings for how to run optixlog generate and what the output looks like.


OptixClient.__init__(...)

Construct the generated client. Credentials are auto-filled from your saved login when not explicitly provided.

Signature

def __init__(
    self,
    *,
    base_url: str | None = None,
    api_key: str | None = None,
    **kw: Any,
) -> None: ...

Parameters

Prop

Type

Returns — None.

Side effects — Calls resolve_credential() to read ~/.optixlog/credentials.toml and/or environment variables. No network request is made during construction.

Raises — CredentialsError if no API key can be resolved from any source (argument, environment variable, or stored profile). Run optixlog login to create a stored profile.

Example

ingest.py
from optixlog_gen import OptixClient, Projects, SimulationNode

# Credentials auto-filled from `optixlog login` or environment variables
client = OptixClient()

result = client.project(Projects.GRATING_COUPLER_LAB).ingest(
    data=SimulationNode(config={}, solver="fdtd"),
    prompt="Simulated a grating coupler at 1550 nm.",
)
print(result.node_id)

OptixClient.project(id)

Return a typed project wrapper for the given project ID. The return type is overloaded per literal ID so the type checker knows exactly which node types are valid for each project.

Signature

# One overload per project defined in optixlog.toml (example with two projects):
@overload
def project(self, id: Literal["proj_grating_7f3a"]) -> _Project_proj_grating_7f3a: ...
@overload
def project(self, id: Literal["proj_modulator_22b1"]) -> _Project_proj_modulator_22b1: ...
def project(self, id: str) -> Any: ...

Parameters

Prop

Type

Returns — A generated per-project wrapper class (e.g. _Project_proj_grating_7f3a). The wrapper exposes a single ingest() method typed to only accept node classes valid for that project. The exact class name is an implementation detail; you interact with it only through ingest().

Side effects — None (read-only). Constructs a wrapper around an already-initialized PipelineProject — no network call.

Raises — KeyError at runtime if id does not match any project in the generated _PROJECT_WRAPPERS dict (i.e. a project ID not present in optixlog.toml at generate time).

Example

from optixlog_gen import OptixClient, Projects, SimulationNode, LayoutNode

client = OptixClient()

# Type-safe: SimulationNode is valid for GRATING_COUPLER_LAB
client.project(Projects.GRATING_COUPLER_LAB).ingest(
    data=SimulationNode(config={}, solver="eme"),
    prompt="Ran an EME simulation.",
)

# Static type error (pyright/mypy): LayoutNode is not in GRATING_COUPLER_LAB's schema
# client.project(Projects.GRATING_COUPLER_LAB).ingest(data=LayoutNode(gds_path="x.gds"), prompt="...")

OptixClient.sdk

Property that exposes the underlying SDKClient. Use this when you need the low-level client to construct Management or Pipeline views manually.

Signature

@property
def sdk(self) -> SDKClient: ...

Parameters — None.

Returns — SDKClient: the authenticated client instance. The same instance that backs OptixClient's own pipeline calls.

Side effects — None (read-only).

Raises — Does not raise.

Example

from optixlog_gen import OptixClient
from optixlog.management import Management

client = OptixClient()

# Use the underlying SDKClient for management operations
mgmt = Management(client.sdk)
config = mgmt.project("proj_grating_7f3a").config.get()
print(config.name)

OptixClient.close()

Close the underlying SDKClient and its HTTP connection pool.

Signature

def close(self) -> None: ...

Parameters — None.

Returns — None.

Side effects — Closes all open HTTP connections. Subsequent requests will fail.

Raises — Does not raise under normal conditions.

Example

from optixlog_gen import OptixClient

client = OptixClient()
try:
    # ... do work ...
    pass
finally:
    client.close()

On this page