> ## Documentation Index
> Fetch the complete documentation index at: https://www.getmaxim.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Prompt Retrieval Testing

> Retrieval quality directly impacts the quality of output from your AI application. While testing prompts, Maxim allows you to connect your RAG pipeline via a simple API endpoint and evaluates the retrieved context for every run. Context specific evaluators for precision, recall and relevance make it easy to see where retrieval quality is low.

## Fetch retrieved context while running prompts

To mimic the real output that your users would see when sending a query, it is necessary to consider what context is being retrieved and fed to the LLM. To make this easier in Maxim's playground, we allow you to attach the Context Source and fetch the relevant chunks. Follow the steps given below to use context in the prompt playground.

<Steps>
  <Step title="Create a Context Source">
    Create a new [Context Source](/library/context-sources#bring-your-rag-via-an-api-endpoint) in the Library of type API.

    <img src="https://mintcdn.com/maximai/YdQNCf1tftKyYOR4/images/docs/evaluate/how-to/evaluate-prompts/rag-quality/create-context-source.png?fit=max&auto=format&n=YdQNCf1tftKyYOR4&q=85&s=0b97919fc19bbcce08abe1771f7bed98" alt="Create context source" width="1084" height="800" data-path="images/docs/evaluate/how-to/evaluate-prompts/rag-quality/create-context-source.png" />
  </Step>

  <Step title="Configure your RAG endpoint">
    Set up the API endpoint of your RAG pipeline that provides the response of the final chunks for any given input.

    <img src="https://mintcdn.com/maximai/YdQNCf1tftKyYOR4/images/docs/evaluate/how-to/evaluate-prompts/rag-quality/api-endpoint.png?fit=max&auto=format&n=YdQNCf1tftKyYOR4&q=85&s=da9045f3d51738c0ed0d9eae0d54ca9b" alt="RAG API endpoint" width="1498" height="638" data-path="images/docs/evaluate/how-to/evaluate-prompts/rag-quality/api-endpoint.png" />
  </Step>

  <Step title="Add context variable to your prompt">
    Reference a variable `{{context}}` in  your prompt to provide instructions on using this dynamic data.

    <img src="https://mintcdn.com/maximai/YdQNCf1tftKyYOR4/images/docs/evaluate/how-to/evaluate-prompts/rag-quality/prompt-with-context-variable.png?fit=max&auto=format&n=YdQNCf1tftKyYOR4&q=85&s=3c92dc2e7bf5aebad5adf326f89c57bf" alt="Variable usage" width="1384" height="544" data-path="images/docs/evaluate/how-to/evaluate-prompts/rag-quality/prompt-with-context-variable.png" />
  </Step>

  <Step title="Link the Context Source">
    Connect the Context Source as the dynamic value of the context variable in the variables table.

    <img src="https://mintcdn.com/maximai/YdQNCf1tftKyYOR4/images/docs/evaluate/how-to/evaluate-prompts/rag-quality/dynamic-context-link.png?fit=max&auto=format&n=YdQNCf1tftKyYOR4&q=85&s=de7c953f475f61f3029ab6bc887664ed" alt="Variable linking" width="916" height="886" data-path="images/docs/evaluate/how-to/evaluate-prompts/rag-quality/dynamic-context-link.png" />
  </Step>

  <Step title="Test with real-time retrieval">
    Run your prompt to see the retrieved context that is fetched for that input.

    <img src="https://mintcdn.com/maximai/YdQNCf1tftKyYOR4/images/docs/evaluate/how-to/evaluate-prompts/rag-quality/retrieved-context.png?fit=max&auto=format&n=YdQNCf1tftKyYOR4&q=85&s=be94b6ff509082af450b1dd1c60e5fbc" alt="Retrieved context" width="1388" height="1276" data-path="images/docs/evaluate/how-to/evaluate-prompts/rag-quality/retrieved-context.png" />
  </Step>
</Steps>

# Next steps

[Evaluate Retrieval Quality](/offline-evals/via-ui/prompts/retrieval) - check how to evaluate retrieval quality.
