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

# Quick Start

> Build your first RAG chatbot in under 5 minutes.

## Install

```bash theme={null}
pip install langchat
```

<Note>
  Requires **Python 3.9 or higher**.
</Note>

## Set environment variables

All providers read credentials from the environment automatically. Create a `.env` file:

```bash theme={null}
OPENAI_API_KEY=sk-...
PINECONE_API_KEY=pcsk-...
PINECONE_INDEX=my-index
SUPABASE_URL=https://xxxx.supabase.co
SUPABASE_KEY=eyJhbGc...
```

## Your first chatbot

```python theme={null}
import asyncio
from langchat import LangChat
from langchat.providers import OpenAI, Pinecone, Supabase

async def main():
    lc = LangChat(
        llm=OpenAI("gpt-4o-mini"),      # reads OPENAI_API_KEY
        vector_db=Pinecone("my-index"), # reads PINECONE_API_KEY
        db=Supabase(),                  # reads SUPABASE_URL + SUPABASE_KEY
    )

    response = await lc.chat(
        query="What can you help me with?",
        user_id="alice",
    )

    print(response)        # prints response text
    print(response.text)   # same — explicit access
    print(response.status) # "success" or "error"

asyncio.run(main())
```

## Sync alternative

Don't want `async`? Use the sync wrapper:

```python theme={null}
from langchat import LangChat
from langchat.providers import OpenAI, Pinecone, Supabase

lc = LangChat(
    llm=OpenAI("gpt-4o-mini"),
    vector_db=Pinecone("my-index"),
    db=Supabase(),
)

response = lc.chat_sync(query="Hello!", user_id="alice")
print(response)
```

## What LangChat does automatically

When you call `chat()`:

1. Reformulates the question as a standalone query (resolves "it", "that", etc.)
2. Searches your Pinecone index for relevant context
3. Reranks results with Flashrank for better precision
4. Calls the LLM with context + conversation history
5. Saves the exchange to Supabase
6. Returns a typed `ChatResponse` object

No configuration needed for any of this — it all works out of the box.

## What you get back

`chat()` returns a [`ChatResponse`](/api-reference/langchat-config) dataclass:

| Field           | Type                   | Description                               |
| --------------- | ---------------------- | ----------------------------------------- |
| `text`          | `str`                  | The AI's response                         |
| `status`        | `"success" \| "error"` | Whether the call succeeded                |
| `user_id`       | `str`                  | Echo of the user ID you passed            |
| `platform`      | `str`                  | Platform namespace (default: `"default"`) |
| `response_time` | `float`                | Latency in seconds                        |
| `timestamp`     | `str`                  | ISO 8601 UTC timestamp                    |
| `error`         | `str \| None`          | Error message if `status == "error"`      |

```python theme={null}
response = await lc.chat(query="Hello", user_id="alice")

if response:                        # True when status == "success"
    print(response.text)
    print(f"Answered in {response.response_time:.2f}s")
else:
    print(f"Error: {response.error}")
```

## Launch as an API server

One line to expose a full REST API with a built-in chat UI:

```python theme={null}
from langchat.api import create_app
from langchat.providers import OpenAI, Pinecone, Supabase
import uvicorn

app = create_app(
    llm=OpenAI("gpt-4o-mini"),
    vector_db=Pinecone("my-index"),
    db=Supabase(),
)

uvicorn.run(app, host="0.0.0.0", port=8000)
```

Open `http://localhost:8000/frontend` to use the built-in chat interface.

## Next steps

<CardGroup cols={2}>
  <Card title="Installation" icon="download" href="/installation">
    Virtual environments, uv, and dependency setup
  </Card>

  <Card title="Configuration" icon="gear" href="/guides/configuration">
    All providers and configuration options
  </Card>

  <Card title="Document Indexing" icon="database" href="/guides/document-indexing">
    Load PDFs, CSVs, and other documents into Pinecone
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/langchat">
    Complete method and parameter reference
  </Card>
</CardGroup>
