> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trynexus.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Install Nexus and emit your first trace

## Install

**LangChain integration**

```bash theme={null}
pip install nexus-library[langchain]
```

**OpenAI Agents SDK integration**

```bash theme={null}
pip install nexus-library[openai]
```

## Get your Nexus API key

Create or sign in to the Nexus platform and copy your `nexus_api_key`:

* [Nexus platform](https://app.trynexus.io)

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`.

```python theme={null}
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

```python theme={null}
from nexus_library.nexus_core import NexusClient
from nexus_library.langchain import LangHandler

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

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

## Add OpenAI Agents SDK tracing

```python theme={null}
import asyncio
import os
from agents import Agent, Runner, set_trace_processors
from nexus_library.nexus_core import NexusClient
from nexus_library.openai import NexusOpenAITracingProcessor

nexus_client = NexusClient(api_key=os.environ["NEXUS_API_KEY"])
dev_mode = os.getenv("NEXUS_DEV_MODE", "false").lower() == "true"
tracing_processor = NexusOpenAITracingProcessor(nexus_client, dev_mode=dev_mode)

set_trace_processors([tracing_processor])

async def main():
    agent = Agent(name="my-agent", instructions="You are a helpful assistant.")
    result = await Runner.run(agent, "Hello!")
    print(result.final_output)

asyncio.run(main())
```

Set `NEXUS_DEV_MODE=true` locally to disable external triggers. Set it to `false` (or omit it) in production.

## 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

<CardGroup cols={2}>
  <Card title="Manual tracing guide" icon="route" href="/guides/manual-tracing">
    Deep dive into span nesting and flush semantics.
  </Card>

  <Card title="LangChain guide" icon="brain" href="/guides/langchain">
    Understand callback lifecycle and event categories.
  </Card>

  <Card title="OpenAI Agents SDK guide" icon="robot" href="/guides/openai">
    Trace OpenAI agents with NexusOpenAITracingProcessor.
  </Card>

  <Card title="Configuration" icon="sliders" href="/guides/configuration">
    Set DB URLs and trigger endpoints safely.
  </Card>

  <Card title="Python reference" icon="book" href="/api-reference/python-client">
    Review method-level behavior for `NexusClient`.
  </Card>
</CardGroup>

<Warning>
  `nexus_key` should be your Nexus platform `nexus_api_key`. Keep it secret and load it from environment variables in production.
</Warning>
