> ## 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.

# Adapters Overview

> How LangChat's provider and adapter system works.

## Architecture

LangChat uses a **hexagonal architecture** (Ports and Adapters). This separates the core chatbot logic from the specific tools it uses:

```
langchat.providers        ← public API (what you use)
      │
langchat.adapters         ← implementations (OpenAI, Pinecone, Supabase, Flashrank)
      │
langchat.core             ← business logic (engine, sessions, chains)
```

You always interact with `langchat.providers`. The adapters are implementation details.

***

## Available providers

| Provider    | Import               | Replaces                                      |
| ----------- | -------------------- | --------------------------------------------- |
| `OpenAI`    | `langchat.providers` | `langchat.adapters.llm.OpenAIAdapter`         |
| `Anthropic` | `langchat.providers` | `langchat.adapters.llm.AnthropicAdapter`      |
| `Gemini`    | `langchat.providers` | `langchat.adapters.llm.GeminiAdapter`         |
| `Mistral`   | `langchat.providers` | `langchat.adapters.llm.MistralAdapter`        |
| `Cohere`    | `langchat.providers` | `langchat.adapters.llm.CohereAdapter`         |
| `Ollama`    | `langchat.providers` | `langchat.adapters.llm.OllamaAdapter`         |
| `Pinecone`  | `langchat.providers` | `langchat.adapters.vector_db.PineconeAdapter` |
| `Supabase`  | `langchat.providers` | `langchat.adapters.database.SupabaseAdapter`  |

***

## Import patterns

```python theme={null}
# Recommended — use providers
from langchat.providers import OpenAI, Pinecone, Supabase

# All at once via the module
import langchat.providers as providers
llm = providers.OpenAI("gpt-4o-mini")
```

***

## Environment variable convention

Every provider follows the same pattern:

1. Check for explicit `api_key` parameter
2. Fall back to a named environment variable
3. Raise `ValueError` with the exact variable name if neither is set

```python theme={null}
# These are equivalent:
llm = OpenAI("gpt-4o-mini", api_key="sk-...")         # explicit
llm = OpenAI("gpt-4o-mini")                           # reads OPENAI_API_KEY

# If OPENAI_API_KEY is not set and no api_key is passed:
# ValueError: OpenAI API key is required. Set OPENAI_API_KEY environment variable
#             or pass api_key parameter.
```

***

## Detailed reference

<CardGroup cols={2}>
  <Card title="OpenAI" icon="robot" href="/adapters/openai-service">
    LLM provider with multi-key rotation
  </Card>

  <Card title="Pinecone" icon="database" href="/adapters/pinecone-adapter">
    Vector database with OpenAI embeddings
  </Card>

  <Card title="Supabase" icon="table" href="/adapters/supabase-adapter">
    Postgres history and metrics storage
  </Card>

  <Card title="Flashrank" icon="ranking-star" href="/adapters/flashrank-reranker">
    Cross-encoder reranker for better search results
  </Card>
</CardGroup>
