Skip to main content
Version: 2.0

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 with permission to create corpora, index documents, and run queries (sign up free, 30-day trial).
  • A Personal API key (you copy it in step 1).
  • For the curl tab: curl 7.76 or later (--fail-with-body requires it).
  • For the Python tab: Python 3.7 or later and the SDK (pip install vectara). Run the snippets sequentially in the same interpreter session or combine them, in order, into one .py file.
  • For the TypeScript tab: Node.js 18 or later, plus tsx and the Node.js type definitions (npm install --save-dev tsx @types/node). Save each snippet as a separate .mts file and run it with npx tsx <filename>.mts.

What you will build

Step 1: Get your API key

  1. Log in to the Vectara Console.
  2. Under Access, select API keys.
  3. Open Personal API key and copy your key.

Set the API key as an environment variable so the examples below can read it:

export VECTARA_API_KEY="your_api_key_here"
caution

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. These examples authenticate with the x-api-key header. Vectara also supports OAuth 2.0.

note

These examples use the fixed corpus key quickstart-corpus and document ID doc-1. If you rerun the quickstart, skip this step to reuse the existing corpus or choose a different key and update the later examples. Before repeating step 3, delete the existing document or choose a different document ID.

CREATE A CORPUS

Code example with multiple language options.
1

Example response (IDs and fields may vary):

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

Example response (fields may vary):

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, 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

Example response (generated text, scores, and fields may vary):

RESPONSE WITH NUMERIC CITATIONS

Code example with json syntax.
1

Notice:

  • Numeric citations ([1], [2]) reference the corresponding search results.
  • Search results show the matched text snippets and their relevance score.
  • Factual consistency score indicates how well the answer is grounded in the sources. Scoring is enabled by default; set generation.enable_factual_consistency_score to false to disable it. The platform also omits the score when FCS input limits are exceeded or the summary language is unsupported; check the response warnings for the specific condition.

What you just built

In about five 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 a foundation for Vectara RAG applications, 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 vectara package and run the same flow in Python with a full validation script.

Next steps