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

# Clear Context

> Clear a previously attached context and optionally flush pending traces.

## Returns

This method returns `None`.

## Example

```python theme={"system"}
clear_context(trace_context)
```

## Parameters

<ResponseField name="token" type="object" required>
  The context token returned by `set_context()`.
</ResponseField>

<ResponseField name="flush" type="bool" optional>
  If `True` (default), export any pending traces associated with the current inference result to the telemetry exporter before detaching the context.
</ResponseField>

<Note>
  Always use `clear_context()` in a `finally` block to ensure proper cleanup, even if an exception occurs.
</Note>
