LangDB Embedder
Generate embeddings through a LangDB project endpoint.
LangDBEmbedder routes OpenAI-compatible embedding requests through the project selected by LANGDB_PROJECT_ID.
from os import environ
from agno.knowledge.embedder.langdb import LangDBEmbedder
project_id = environ["LANGDB_PROJECT_ID"]
embedder = LangDBEmbedder(
base_url=f"https://api.langdb.ai/{project_id}/v1",
)
embedding = embedder.get_embedding(
"The quick brown fox jumps over the lazy dog."
)
print(f"First values: {embedding[:5]}")
print(f"Dimensions: {len(embedding)}")The default model is text-embedding-ada-002 with 1536 dimensions. Pass id and dimensions together when selecting another model.
Agno constructs the legacy api.us-east-1.langdb.ai host when base_url is omitted. LangDB's current API guide uses api.langdb.ai. Pass base_url as shown above.
Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateConfigure the project
export LANGDB_API_KEY=your_langdb_api_key_here
export LANGDB_PROJECT_ID=your_langdb_project_id_hereInstall dependencies
uv pip install -U agno openaiRun the example
python langdb_embedder.py