Quickstart
Build your first RAG application with Vectara in about five minutes. You create a corpus, upload a document, run a query, and get an AI-generated answer with citations. Choose your language with the tabs in each code block: curl, the Python SDK, or TypeScript with fetch.
Before you begin, you need:
- A Vectara account (sign up free, 30-day trial).
- An API key (you create one in step 1).
- For the Python tab: Python 3.7 or later and the SDK (
pip install vectara). - For the TypeScript tab: Node.js 18 or later, which includes a global
fetch.
What you will build
Step 1: Get your API key
- Log in to the Vectara Console.
- Navigate to Authorization, API Keys.
- Copy your Personal API key.
Set the API key as an environment variable so the examples below can read it:
export VECTARA_API_KEY="your_api_key_here"
Keep your API key secure. Do not commit it to version control or share it publicly.
Step 2: Create a corpus
A corpus is a container for your documents. Create one with a single call. Vectara authenticates every request with the x-api-key header.
CREATE A CORPUS
Code example with multiple language options.1
Expected response:
RESPONSE
Code example with json syntax.1
You now have a corpus ready to store documents.
Step 3: Upload a document
Upload a structured document with one or more sections of text. Vectara indexes the text so you can search it.
UPLOAD A DOCUMENT
Code example with multiple language options.1
Expected response:
RESPONSE
Code example with json syntax.1
Your document is now indexed and searchable.
You can also upload files directly (PDF, Word, PowerPoint, and more) without structuring them. See Data ingestion and the Upload File API.
Step 4: Query your data
Query your document and get an AI-generated answer with citations. The generation block uses the mockingbird-2.0 preset to write the answer from the retrieved results.
QUERY WITH RAG
Code example with multiple language options.1
Response:
RESPONSE WITH CITATIONS
Code example with json syntax.1
Notice:
- Citations (
[1],[2]) link the answer to source documents. - Search results show the matched text snippets and their relevance
score. - Factual consistency score indicates how well the answer is grounded in the sources.
What you just built
In about five minutes, you:
- Created a corpus to store documents.
- Indexed a document with searchable text.
- Queried your data with natural language.
- Got an AI-generated answer with citations.
This is the foundation of every Vectara application, from simple Q&A to multi-tool agents.
Choose your next quickstart
This page covers the core retrieval and generation flow. Continue with the path that matches what you are building:
- Build an agent - Create an agent that follows instructions, uses tools such as web search, and maintains conversation context.
- Automate ingestion with pipelines - Pull data from a source such as S3 on a schedule and process each record with an agent.
- Tune search and retrieval - Query sample data in the Console and refine relevance with hybrid search and reranking.
- Use the Python SDK - Install the
vectarapackage and run the same flow in Python with a full validation script.
Next steps
- Data ingestion - Upload PDFs, Word documents, and other files.
- Reranking - Improve relevance with rerankers.
- REST API reference - Full endpoint, request, and response documentation.
- Getting started - Pick a guided path by role and goal.