Skip to main content
In this Quickstart you’ll learn how to build a RAG workflow using Together AI in 6 quick steps that can be ran in under 5 minutes! We will leverage the embedding, reranking and inference endpoints.

1. Register for an account

First, register for an account to get an API key. New accounts come with $1 to get started. Once you’ve registered, set your account’s API key to an environment variable named TOGETHER_API_KEY:
Shell

2. Install your preferred library

Together provides an official library for Python:
Python
Python

3. Data Processing and Chunking

We will RAG over Paul Grahams latest essay titled Founder Mode. The code below will scrape and load the essay into memory.
Python
Chunk the essay:
Python

4. Generate Vector Index and Perform Retrieval

We will now use bge-large-en-v1.5 to embed the augmented chunks above into a vector index.
Python
The function below will help us perform vector search:
Python
We now have a way to retrieve from the vector index given a query.

5. Rerank To Improve Quality

We will use a reranker model to improve retrieved chunk relevance quality:
Python

6. Call Generative Model - Llama 405b

We will pass the final 3 concatenated chunks into an LLM to get our final answer.
Python
If you want to learn more about how to best use open models refer to our docs here!