Skip to main content

Requirements

RequirementVersion
Python3.9 or higher
PineconeAccount with an index created
SupabaseEmpty project (tables created automatically)
LLM providerOpenAI, Anthropic, Gemini, Mistral, Cohere, or local Ollama

Install LangChat

pip install langchat
uv is a fast Python package manager that replaces pip and venv.
curl -LsSf https://astral.sh/uv/install.sh | sh

Virtual environment

uv venv
source .venv/bin/activate      # macOS / Linux
.venv\Scripts\activate         # Windows
uv pip install langchat

Environment variables

Create a .env file in your project root. All providers read credentials automatically — you never pass keys directly in code.
.env
# ─── LLM providers (add whichever you use) ───────────────────────
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GEMINI_API_KEY=AIza...          # also accepted: GOOGLE_API_KEY
MISTRAL_API_KEY=...
COHERE_API_KEY=...
# Ollama needs no key — runs locally

# ─── Vector database ─────────────────────────────────────────────
PINECONE_API_KEY=pcsk-...

# ─── History database ────────────────────────────────────────────
SUPABASE_URL=https://xxxx.supabase.co
SUPABASE_KEY=eyJhbGc...         # also accepted: SUPABASE_SERVICE_ROLE_KEY

# ─── Embeddings (required for document indexing) ─────────────────
# Reuses OPENAI_API_KEY — no extra variable needed
Load .env in your script with one line:
from langchat import LangChat
LangChat.load_env()
Or use python-dotenv:
from dotenv import load_dotenv
load_dotenv()
Add .env to your .gitignore. Never commit API keys.

Pinecone setup

You need a Pinecone index before LangChat can store or retrieve documents.
  1. Sign up at pinecone.io
  2. Create a Serverless index with these settings:
    • Dimensions: 3072 for text-embedding-3-large (default) or 1536 for text-embedding-3-small
    • Metric: cosine
  3. Add PINECONE_API_KEY to your .env

Supabase setup

LangChat creates its tables automatically — you just need a project.
  1. Create a project at supabase.com
  2. Copy Project URL and anon key (or service_role key for server-side usage)
  3. Add SUPABASE_URL and SUPABASE_KEY to your .env
On first run, LangChat creates:
  • chat_history — stores conversation messages
  • request_metrics — stores latency and error data

Verify installation

import langchat
print(langchat.__version__)

Next steps