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

# LangChain

> Give a LangChain agent Octen search APIs and Extract.

For AI agents: [docs.octen.ai/integrations/langchain.md](https://docs.octen.ai/integrations/langchain.md)

The `langchain-octen` package provides the ready-made tools listed in [Tools](#tools).

> [card] [Get API Key](https://octen.ai/platform/api-keys)
>
> Create a key from the API Platform.

> [card] [PyPI](https://pypi.org/project/langchain-octen/)
>
> The `langchain-octen` package.

> [card] [GitHub](https://github.com/Octen-Team/langchain-octen)
>
> View the source and changelog.

## Install

Requires Python 3.11+.

```bash theme={null}
pip install langchain-octen langchain langchain-openai
```

## Quick Start

Set your Octen and OpenAI API keys:

```bash theme={null}
export OCTEN_API_KEY="your-api-key"
export OPENAI_API_KEY="your-openai-api-key"
```

Run an agent that answers with Octen Web Search:

```python theme={null}
from langchain.agents import create_agent
from langchain_octen import OctenSearchResults
from langchain_openai import ChatOpenAI

agent = create_agent(
    model=ChatOpenAI(model="gpt-5.4"),
    tools=[OctenSearchResults(max_results=5)],
    system_prompt="Answer with current information from the web and cite the URLs you used.",
)

result = agent.invoke(
    {"messages": [{"role": "user", "content": "What is the latest stable release of Python?"}]}
)
print(result["messages"][-1].content)
```

## Tools

| Class | Octen API | Returns |
| - | - | - |
| `OctenSearchResults` | [Web Search](https://docs.octen.ai/api-reference/search.md) | Ranked pages with relevant `highlight`, plus `full_content` with `full_content_enabled=True` |
| `OctenSearchPremier` | [Web Search Premier](https://docs.octen.ai/api-reference/search-premier.md) | Ranked pages with relevant `highlight`, from deeper retrieval and reranking |
| `OctenBroadSearch` | [Broad Search](https://docs.octen.ai/api-reference/broad-search.md) | Ranked results grouped per generated sub-query |
| `OctenNewsSearch` | [News Search](https://docs.octen.ai/api-reference/news-search.md) | Ranked articles plus storylines in `subjects` |
| `OctenBusinessSearch` | [Business Search](https://docs.octen.ai/api-reference/business-search.md) | Company and person cards plus ranked sources |
| `OctenPulseSearch` | [Pulse Search](https://docs.octen.ai/api-reference/pulse-search.md) | Predicted titles and URLs, plus page content with `mode="standard"` (default `lite`) |
| `OctenPlaceSearch` | [Place Search](https://docs.octen.ai/api-reference/place-search.md) | Place cards with address, coordinates, phone, opening hours, and rating |
| `OctenImageSearch` | [Image Search](https://docs.octen.ai/api-reference/image-search.md) | Ranked images with source page, dimensions, and thumbnail |
| `OctenDesignSearch` | [Design Search](https://docs.octen.ai/api-reference/design-search.md) | Design screenshots with their design values, plus ranked web results |
| `OctenExtract` | [Extract](https://docs.octen.ai/api-reference/extract.md) | Clean content of each URL, or relevant `highlights` when the model passes a `query` |

## Use Auto Search

Skip the tool loop and let Octen run the searches server-side with [Auto Search](https://docs.octen.ai/capabilities/auto-search.md). Point the model at the Octen base URL and enable the built-in `octen_search` tool. Your Octen API key is the only key you need:

```python theme={null}
import os

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="openai/gpt-5.4",
    base_url="https://api.octen.ai/v1",
    api_key=os.environ["OCTEN_API_KEY"],
    extra_body={"tools": [{"type": "octen_search"}]},
)
print(llm.invoke("What happened in AI this week?").content)
```

Pass the tool in `extra_body`: `bind_tools` rejects `octen_search`.

***

Last modified on November 24, 2026


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