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

# NL Layer

> Understanding the AI and natural language processing capabilities of PandasAI

## How does PandasAI NL Layer work?

The Natural Language Layer uses generative AI to transform natural language queries into production-ready code generated by LLMs.
When you use the [`.chat`](/v3/chat-and-output) method on a dataframe, PandasAI passes to the LLM the question, the table headers, and 5-10 rows of the Dataframe.
It then instructs the LLM to generate the most relevant code, whether Python or SQL. The code is then executed locally.
There are different output formats supported by PandasAI, which can be found [here](/v3/chat-and-output#available-output-formats).

## Configure the NL Layer

PandasAI allows you to configure the NL Layer with the `config.set()` method.

Example:

```python theme={null}
import pandasai as pai
from pandasai_litellm.litellm import LiteLLM

# Initialize LiteLLM with your OpenAI model
llm = LiteLLM(model="gpt-4.1-mini", api_key="YOUR_OPENAI_API_KEY")

pai.config.set({
   "llm": llm,
   "save_logs": True,
   "verbose": False,
   "max_retries": 3
})
```

### Parameters

#### llm

* **Description**: The LLM to use. You can pass an instance of an LLM or the name of an LLM. See [supported LLMs](/v3/large-language-models) for setup instructions and configuration options.

#### save\_logs

* **Type**: `bool`
* **Default**: `True`
* **Description**: Whether to save the logs of the LLM. You will find the logs in the `pandasai.log` file in the root of your project.

#### verbose

* **Type**: `bool`
* **Default**: `False`
* **Description**: Whether to print the logs in the console as PandasAI is executed.

#### max\_retries

* **Type**: `int`
* **Default**: `3`
* **Description**: The maximum number of retries to use when using the error correction framework. You can use this setting to override the default number of retries.
