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 run 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. 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:
Shell
Python

3. Data Processing and Chunking

We will RAG over Paul Graham’s 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 multilingual-e5-large-instruct 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:
Rerank models like Mxbai-Rerank-Large-V2 are only available with dedicated model inference. You can bring up a dedicated endpoint to use reranking in your applications.
Python

6. Call Generative Model

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!