Skip to main content
Version: 2.0

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

  1. Log in to the Vectara Console.
  2. Navigate to Authorization, API Keys.
  3. Copy your Personal API key.

Set the API key as an environment variable:

export VECTARA_API_KEY="your_api_key_here"
caution

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.

Upload files instead

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"

Learn more about file uploads →

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:

  1. Created a corpus to store documents
  2. Indexed a document with searchable text
  3. Queried your data with natural language
  4. 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.