> For the complete documentation index, see [llms.txt](https://docs.flashback.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flashback.tech/guides/explore-use-cases/ai-llm/rag-knowledge-assistant-over-multi-cloud-storage.md).

# RAG knowledge assistant over multi-cloud storage

## The Problem

Documentation and internal knowledge are spread across buckets/providers and updated by many teams. Centralizing everything first can delay AI feature delivery.

## The Flashgate Pattern

Use Flashgate to unify access:

* Cloud documents are accessed via repository storage endpoints.
* AI generation runs via repository OpenAI-compatible endpoints.
* One control plane handles keys, observability, and policies.

This allows phased RAG adoption without a single-provider lock-in.

## Prerequisites

* Storage resources connected in Flashgate (S3/GCS/Azure-compatible).
* AI LLM provider connected in Flashgate.
* Repository configured with both storage and AI resources.
* Chunking/indexing pipeline in your application stack.

References:

* [Cloud Storage use cases](/guides/explore-use-cases/explore-use-cases.md)
* [Build a Repository](/guides/setup-the-cloud-and-ai-gateway/start-with-cloud-storage-1.md)

## Architecture flow

1. **Ingest** documents from storage buckets through Flashgate endpoint.
2. **Chunk + embed** each segment (embedding model/service of your choice).
3. **Index** vectors in your search backend (pgvector, OpenSearch, Pinecone, etc.).
4. **Retrieve** top-k chunks at query time.
5. **Generate** final answer via Flashgate AI endpoint with retrieved context.

## Minimal implementation snippets

### 1) Read files from storage endpoint (Python, S3-compatible)

```python
import boto3
from botocore.client import Config

s3 = boto3.client(
    "s3",
    endpoint_url="https://s3-us-east-1-aws.flashback.tech",
    aws_access_key_id="FB_KEY_ID",
    aws_secret_access_key="FB_KEY_SECRET",
    config=Config(signature_version="s3v4")
)

obj = s3.get_object(Bucket="knowledge-bucket", Key="handbook/security.md")
content = obj["Body"].read().decode("utf-8")
```

### 2) Build answer with retrieved chunks (Node.js)

```ts
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: process.env.FB_OPENAI_BASE_URL,
  apiKey: process.env.FB_API_KEY_SECRET
});

export async function answer(question: string, chunks: string[]) {
  const context = chunks.join("\n\n---\n\n");

  const res = await client.chat.completions.create({
    model: "gpt-4.1-mini",
    temperature: 0,
    messages: [
      { role: "system", content: "Answer only using provided context. If unknown, say unknown." },
      { role: "user", content: `Question: ${question}\n\nContext:\n${context}` }
    ]
  });

  return res.choices[0].message.content;
}
```

## Operational recommendations

* Version your chunking strategy and re-index process.
* Add metadata filters (workspace, doc type, language, confidentiality).
* Log retrieval scores and prompt/response latency separately.
* Apply AI policy rules to reduce prompt injection and sensitive output risks.

## Expected outcome

A portable RAG stack where storage and generation are decoupled from any single cloud provider, while still exposed through stable Flashgate APIs.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flashback.tech/guides/explore-use-cases/ai-llm/rag-knowledge-assistant-over-multi-cloud-storage.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
