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

# LangChain

This package integrates the **AI Search API** with **LangChain**.\
You can use semantic search, conversational models, and AI agents in your LangChain projects with just one package.

👉 To start, create an account and get your API key:

* [Sign Up](https://app.aisearchapi.io/join)
* [Log In](https://app.aisearchapi.io/login)
* [Dashboard](https://app.aisearchapi.io/dashboard)

***

# Features

* 🔑 **One Package Setup** – `pip install langchain-aisearchapi` and you’re ready
* 🤖 **LLM Interface** – Use AI Search API as a LangChain LLM
* 💬 **Chat Model** – Build conversational agents with memory
* 🛠️ **Tools for Agents** – Add AI Search directly into LangChain workflows
* 📚 **Prebuilt Chains** – Research, Q\&A, fact-checking out of the box

***

# Installation

Install from PyPI:

```bash theme={null}
pip install langchain-aisearchapi
```

That’s it — no extra setup needed.

***

# Quick Start

## 1. Basic LLM Usage

```python theme={null}
from langchain_aisearchapi import AISearchLLM

llm = AISearchLLM(api_key="your-key")
response = llm("Explain semantic search in simple terms")
print(response)
```

## 2. Conversational Chat

```python theme={null}
from langchain_aisearchapi import AISearchChat
from langchain.schema import HumanMessage

chat = AISearchChat(api_key="your-key")

messages = [
    HumanMessage(content="What is LangChain?"),
    HumanMessage(content="Why do developers use it?")
]

response = chat(messages)
print(response.content)
```

## 3. AI Search as a Tool in Agents

```python theme={null}
from langchain_aisearchapi import AISearchTool, AISearchLLM
from langchain.agents import initialize_agent, AgentType

search_tool = AISearchTool(api_key="your-key")
llm = AISearchLLM(api_key="your-key")

agent = initialize_agent(
    tools=[search_tool],
    llm=llm,
    agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
    verbose=True
)

result = agent.run("Find the latest SpaceX launch details")
print(result)
```

## 4. Research Assistant

```python theme={null}
from langchain_aisearchapi import create_research_chain

research = create_research_chain(api_key="your-key")
result = research.run("Breakthroughs in AI search technology 2024")
print(result)
```

***

# Components

| Component                 | Description               | Use Case                      |
| ------------------------- | ------------------------- | ----------------------------- |
| `AISearchLLM`             | AI Search API as an LLM   | Completions, text generation  |
| `AISearchChat`            | Chat model with context   | Conversational AI, assistants |
| `AISearchTool`            | Search as LangChain tool  | Agents, workflows             |
| `create_research_chain()` | Ready-made research chain | Research and reporting        |

***

# Troubleshooting

* ❌ **No API key?** → [Sign up](https://app.aisearchapi.io/join) or log in.
* 🔑 **Key issues?** → Check your [dashboard](https://app.aisearchapi.io/dashboard).
* ⏳ **Rate limited?** → Use retry logic (e.g. with `tenacity`).

***

# Resources

* [AI Search API Homepage](https://aisearchapi.io)
* [Sign Up](https://app.aisearchapi.io/join) / [Log In](https://app.aisearchapi.io/login) / [Dashboard](https://app.aisearchapi.io/dashboard)
* [PyPI Package](https://pypi.org/project/langchain-aisearchapi)
* [Blog](https://aisearchapi.io/blog)

***

# Start Now

Install the package, get your API key, and build powerful LangChain apps with the AI Search API:

```bash theme={null}
pip install langchain-aisearchapi
```

👉 [Join now](https://app.aisearchapi.io/join) to claim your free API key and start building!

***
