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

# LangChain

*This page is in English: the LangChain integration targets developers worldwide. The rest of this documentation is in French.*

[`langchain-lexio`](https://pypi.org/project/langchain-lexio/) packages the Lexio API as [LangChain](https://docs.langchain.com) tools. An agent built with it answers questions such as "which vans are free from 14 to 16 December, and how much?" or "which rentals start tomorrow?", and can prepare a priced quote if you allow it.

## Install

```bash theme={null}
pip install -U langchain-lexio
export LEXIO_API_KEY="lck_..."
```

Use an internal key, created in Lexio under **Settings › Developer › API tokens** ([Authentication](https://docs.lexio.rent/authentification.md)): partner keys cannot read the fleet or the customers. The API is part of the Business plan, and there is no sandbox: point the agent at a dedicated organization while you test.

## Tools

| Tool | Operation | Scope | Writes? |
| - | - | - | - |
| `lexio_search_vehicles` | [`GET /vehicles`](https://docs.lexio.rent/api-reference/flotte/list-vehicles) | `vehicles.read` | no |
| `lexio_check_availability` | [`GET /availability`](https://docs.lexio.rent/api-reference/offre/list-availability) | `offers.read` | no |
| `lexio_list_rentals` | [`GET /rentals`](https://docs.lexio.rent/api-reference/locations/list-rentals) | `rentals.read` | no |
| `lexio_get_rental` | [`GET /rentals/{rentalId}`](https://docs.lexio.rent/api-reference/locations/get-rental) | `rentals.read` | no |
| `lexio_find_customer` | [`GET /customers`](https://docs.lexio.rent/api-reference/clients/list-customers) | `customers.read` | no |
| `lexio_list_categories` | [`GET /categories`](https://docs.lexio.rent/api-reference/catalogue/list-categories) | `catalog.read` | no |
| `lexio_create_quote` | [`POST /quotes`](https://docs.lexio.rent/api-reference/offre/create-quote) | `quotes.write` | quote only |

`LexioToolkit()` returns the six read-only tools. `LexioToolkit(allow_quotes=True)` adds `lexio_create_quote`: a quote fixes the price of one vehicle for one period and books nothing. No tool creates, changes or cancels a rental, a payment or a customer. Give the key only the scopes of the tools you use.

## Build an agent

```python theme={null}
from langchain.agents import create_agent
from langchain_lexio import LexioToolkit

agent = create_agent(
    "anthropic:claude-sonnet-5-5",
    tools=LexioToolkit(allow_quotes=True).get_tools(),
    system_prompt=(
        "You help the counter staff of a car rental agency. "
        "Dates are the agency's local time, without offset."
    ),
)

result = agent.invoke(
    {"messages": [{"role": "user", "content": "Which vans are free from 14 to 16 December, and how much?"}]}
)
print(result["messages"][-1].content)
```

## What the model must know

* **Local time.** `start_at` and `end_at` are the agency's local time without offset (`2026-12-14T09:00:00`), as everywhere in the API ([Amounts, VAT and dates](https://docs.lexio.rent/montants-et-tva.md)).
* **Indicative prices.** `lexio_check_availability` returns the price with the default mileage package, excess and deposit. Only a quote fixes it.
* **Small outputs.** Lists are capped by `max_results` (20 by default) and trimmed to the useful fields; `lexio_get_rental` returns the full rental.
* **Errors.** API errors are raised as typed exceptions carrying the Lexio `code` and `requestId` ([Errors](https://docs.lexio.rent/erreurs.md)). Rate limits are those of the key ([Limits](https://docs.lexio.rent/limites.md)).
* **Cancelled rentals.** Without a `status` filter, `lexio_list_rentals` includes cancelled rentals.

## Without LangChain

* Claude or ChatGPT connect to Lexio without code through the [MCP server](https://docs.lexio.rent/mcp.md).
* [`lexio-rent`](https://github.com/lexio-rent-git/lexio-python) is the plain Python client these tools use.

Source code: [github.com/lexio-rent-git/langchain-lexio](https://github.com/lexio-rent-git/langchain-lexio) (MIT).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.