# Your LangGraph setup
graph = StateGraph(...)
compiled_graph = graph.compile()

opik_tracer = OpikTracer()
result = compiled_graph.invoke(
    input_data,
    config={"callbacks": [opik_tracer]}
)
```

<Tip>
  For detailed LangGraph integration examples, see the 

  [LangGraph Integration guide](/integrations/langgraph)

  .
</Tip>

## Advanced usage

The `OpikTracer` object has a `flush` method that can be used to make sure that all traces are logged to the Opik platform before you exit a script. This method will return once all traces have been logged or if the timeout is reach, whichever comes first.

```python
from opik.integrations.langchain import OpikTracer

opik_tracer = OpikTracer()
opik_tracer.flush()
```

## Important notes

1. **Asynchronous streaming**: If you are using asynchronous streaming mode (calling `.astream()` method), the `input` field in the trace UI may be empty due to a LangChain limitation for this mode. However, you can find the input data inside the nested spans of this chain.

2. **Streaming with cost tracking**: If you are planning to use streaming with LLM calls and want to calculate LLM call tokens/cost, you need to explicitly set `stream_usage=True`: