Skip to main content

Install

pip install nexus-library

Get your Nexus API key

Create or sign in to the Nexus platform and copy your nexus_api_key: In examples below, nexus_key means your nexus_api_key.

Run your first manual trace

The source tree exports NexusClient from nexus_library.nexus_core.
from nexus_library.nexus_core import NexusClient

nexus_key = "your_nexus_api_key"
client = NexusClient(api_key=nexus_key)

with client.span("root-workflow", event_type="chain", input_data={"question": "What is Nexus?"}) as root:
    with client.span("lookup-tool", event_type="tool", input_data={"query": "nexus-library"}) as tool_span:
        tool_span.set_output({"result": "Tracing library for AI systems"})

    root.set_output({"status": "ok"})

client.flush()

Add LangChain callback tracing

from nexus_library.nexus_core import NexusClient
from nexus_library.langchain import PrintingHandler

nexus_key = "your_nexus_api_key"
nexus_client = NexusClient(api_key=nexus_key)
callback_handler = PrintingHandler(nexus_client)

# Attach `callback_handler` to your LangChain runnable / agent callbacks

Verify the trace exists

After your run finishes:
  • use client.get_all_events() to fetch stored rows
  • use client.print_tree_structure() to inspect hierarchy in terminal
  • use client.get_trace_tree_string() to get an LLM-readable tree dump

Next steps

nexus_key should be your Nexus platform nexus_api_key. Keep it secret and load it from environment variables in production.