Documentation Index
Fetch the complete documentation index at: https://docs.definable.ai/llms.txt
Use this file to discover all available pages before exploring further.
Create an agent that retrieves relevant information from a knowledge base before answering.
Create the agent
from definable.agent import Agent
from definable.knowledge import Knowledge
from definable.vectordb import InMemoryVectorDB
knowledge = Knowledge(vector_db=InMemoryVectorDB())
knowledge.add("Definable supports 10 LLM providers: OpenAI, Anthropic, Google, DeepSeek, Mistral, Moonshot, xAI, Perplexity, Ollama, and OpenRouter.")
knowledge.add("Agents can use tools, knowledge, memory, middleware, and tracing.")
knowledge.add("The @tool decorator converts Python functions into agent-callable tools.")
agent = Agent(
model="gpt-4o",
knowledge=knowledge,
instructions="Answer questions using the provided knowledge base. Cite specific facts.",
)
output = agent.run("What LLM providers does Definable support?")
print(output.content)
Export your API key
export OPENAI_API_KEY=sk-***
Run
python agent_knowledge.py
The agent retrieves the most relevant documents and uses them to answer accurately.
You can also use path shorthand to load an entire directory:agent = Agent(model="gpt-4o", knowledge="./docs/")
This auto-configures InMemoryVectorDB + OpenAIEmbedder + RecursiveChunker and loads all supported files from the directory.