Developer quickstart
Build your first RAG application with Vectara in 5 minutes. You'll upload a d ocument, query it, and get AI-generated answers with citations.
Before you begin, you need:
- A Vectara account (sign up free - 30-day trial)
- An API key (created in step 1)
What you will build
Follow this workflow to create your first RAG application:
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:
export VECTARA_API_KEY="your_api_key_here"
Keep your API key secure. Don't 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 API call:
CREATE CORPUS
Code example with bash syntax.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 your first document. We'll create a simple structured document:
UPLOAD DOCUMENT
Code example with bash syntax.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, etc.) without structuring them:
curl -X POST https://api.vectara.io/v2/corpora/quickstart-corpus/upload \
-H "x-api-key: $VECTARA_API_KEY" \
-F "file=@document.pdf"
Step 4: Query your data
Now query your document and get an AI-generated answer with citations:
QUERY WITH RAG
Code example with bash syntax.1
Response:
RESPONSE WITH CITATIONS
Code example with json syntax.1
Notice:
- Citations (
[1],[2]) link answers to source documents - Search results show the matched text snippets
- Factual consistency score (0.95) indicates high accuracy
Done! You just built a working RAG application in 4 API calls.
What you just built
In less than 5 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 complex AI agents.
Next steps
Upload real documents
Upload a PDF, Word doc, or text file:
UPLOAD A FILE
Code example with bash syntax.1
Learn more:
Build with agents
Transform your RAG application into an intelligent agent:
CREATE AN AGENT
Code example with bash syntax.1
Learn more:
Improve search quality
Add a reranker to improve relevance:
QUERY WITH RERANKER
Code example with bash syntax.1
Learn more:
Full example script
Copy this complete script to test everything at once:
COMPLETE QUICKSTART SCRIPT
Code example with bash syntax.1
Save as vectara-quickstart.sh, make it executable with chmod +x vectara-quickstart.sh, and run it!
Want more examples? See API Recipes.