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

# crewai.Client

> Crewai client implementation for API interactions and model integration.

[View module source on GitHub](https://github.com/maximhq/maxim-py/blob/main/maxim/logger/crewai/client.py)

#### get\_log\_level

```python theme={null}
def get_log_level(debug: bool) -> int
```

Set logging level based on debug flag.
debug=False: Only WARNING and ERROR logs
debug=True: INFO and DEBUG logs

## [MaximUsageCallback](/sdk/python/references/logger/crewai/client)

```python theme={null}
class MaximUsageCallback()
```

[Maxim](/sdk/python/references/maxim) usage callback.

This class represents a usage callback.

#### \_\_init\_\_

```python theme={null}
def __init__(generation_id: str)
```

Initialize a usage callback.

#### log\_success\_event

```python theme={null}
def log_success_event(kwargs, response_obj, start_time, end_time)
```

Log a success event.

**Arguments**:

| Name           | Description          |
| -------------- | -------------------- |
| `kwargs`       | The kwargs.          |
| `response_obj` | The response object. |
| `start_time`   | The start time.      |
| `end_time`     | The end time.        |

#### make\_handle\_non\_streaming\_wrapper

```python theme={null}
def make_handle_non_streaming_wrapper(original_method)
```

Make a handle non streaming wrapper.

This function wraps the original method to capture usage.

#### instrument\_crewai

```python theme={null}
def instrument_crewai(maxim_logger: Logger, debug: bool = False)
```

Patches CrewAI's core components (Crew, Agent, Task, Flow, LLM) to add comprehensive logging and tracing.

This wrapper enhances CrewAI with:

* Detailed operation tracing for Crew, Flow, and Task executions
* Token usage tracking for LLM calls
* [Tool](/sdk/python/references/models/prompt) execution monitoring
* [Span](/sdk/python/references/logger/components/span)-based operation tracking
* [Error](/sdk/python/references/models/prompt) handling and reporting

The patching is done by wrapping key methods like:

* Crew\.kickoff
* Agent.execute\_task
* Task.execute\_sync
* LLM.call and \_handle\_non\_streaming\_response
* [Tool](/sdk/python/references/models/prompt).\_run methods

**Arguments**:

| Name           | Type                                             | Description                                                                                                                                      |
| -------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `maxim_logger` | *[Logger](/sdk/python/references/logger/logger)* | A [Maxim](/sdk/python/references/maxim) [Logger](/sdk/python/references/logger/logger) instance for handling the tracing and logging operations. |
| `debug`        | *bool*                                           | If True, show INFO and DEBUG logs. If False, show only WARNING and ERROR logs.                                                                   |
