Skip to content

RAG Pipelines Integration

Build retrieval-augmented generation and semantic search pipelines on Amazon Bedrock through stdapi.ai's OpenAI-compatible embeddings and Cohere-compatible reranking—one deployment serving every stage of the pipeline.

About Retrieval-Augmented Generation

A RAG pipeline grounds a model's answer in your own documents instead of its training data: a retriever finds candidate passages by vector similarity, an optional reranker reorders them by relevance to the actual question, and a chat model answers from the reordered context.

What a RAG pipeline needs from its backend:

  • Embeddings - Vectorize documents and queries into the same space
  • Reranking - Reorder retrieved candidates by relevance before they reach the model
  • Generation - Answer from the retrieved context with a chat-capable model

stdapi.ai serves all three from Amazon Bedrock through standard, unmodified client libraries.

Why RAG + stdapi.ai?

  • Two Dialects, One Deployment
    Point your embedder and chat model at the OpenAI-compatible /v1 route, and your reranker at the Cohere-compatible /cohere route—no separate services to run.

  • Bedrock Embedding and Rerank Models
    Amazon Titan, Cohere Embed, and Cohere Rerank, served through the SDKs your RAG framework already uses.

  • Enterprise Data Privacy
    Documents, queries, and embeddings never leave your AWS account.

  • Pay-Per-Use Pricing
    No per-query fees or vector-database markup. Pay only Amazon Bedrock rates for the embed, rerank, and generation calls you make.

%%{init: {'flowchart': {'htmlLabels': true}} }%%
flowchart LR
  rag["Your RAG Framework\n(Haystack, LlamaIndex, ...)"] --> stdapi["<img src='../styles/logo.svg' style='height:64px;width:auto;vertical-align:middle;' /> stdapi.ai"]
  stdapi --> bedrock["<img src='../styles/logo_amazon_bedrock.svg' style='height:64px;width:auto;vertical-align:middle;' /> Amazon Bedrock"]

Prerequisites

What You'll Need

  • stdapi.ai deployed - See deployment guide or run locally with Docker
  • Your stdapi.ai URL - e.g., https://api.example.com
  • Your API key - From Terraform output or configuration
  • A vector store - stdapi.ai serves embeddings and reranking; the vectors themselves live in your framework's own store (in-memory, pgvector, Qdrant, and others all work)

Configuration

Every RAG framework that speaks the OpenAI and Cohere SDKs follows the same pattern: the embedder and the generator take the OpenAI-compatible /v1 base URL, and the reranker takes the Cohere-compatible /cohere base URL.

Embeddings

Point your framework's OpenAI-compatible embedder at /v1 with an embeddings-capable model.

Haystack

from haystack.components.embedders import OpenAIDocumentEmbedder, OpenAITextEmbedder
from haystack.utils import Secret

document_embedder = OpenAIDocumentEmbedder(
    api_key=Secret.from_env_var("STDAPI_API_KEY"),
    model="amazon.titan-embed-text-v2:0",
    api_base_url="https://YOUR_STDAPI_URL/v1",
)
text_embedder = OpenAITextEmbedder(
    api_key=Secret.from_env_var("STDAPI_API_KEY"),
    model="amazon.titan-embed-text-v2:0",
    api_base_url="https://YOUR_STDAPI_URL/v1",
)

Embed your corpus with OpenAIDocumentEmbedder and each incoming query with OpenAITextEmbedder, using the same model for both so the vectors share a space. See Embeddings API for supported models.

Reranking

Point your framework's Cohere-compatible reranker at /cohere, not the full rerank path—the Cohere client appends the operation itself.

Haystack

from haystack_integrations.components.rankers.cohere import CohereRanker
from haystack.utils import Secret

ranker = CohereRanker(
    api_key=Secret.from_env_var("STDAPI_API_KEY"),
    model="cohere.rerank-v3-5:0",
    api_base_url="https://YOUR_STDAPI_URL/cohere",
    top_k=3,
)

Requires the cohere-haystack integration package alongside haystack-ai. Give the ranker the retriever's full candidate set—every retrieved document, not just the top few—so it has something to reorder rather than merely confirm. See Cohere Rerank API for supported models.

Regional availability

Amazon Bedrock serves reranking from a subset of regions only. Keep at least one of them in AWS_BEDROCK_REGIONS; stdapi.ai fails over to it automatically.

Generation

Point your framework's OpenAI-compatible chat generator at /v1, answering from the reranked context.

Haystack

from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.utils import Secret

generator = OpenAIChatGenerator(
    api_key=Secret.from_env_var("STDAPI_API_KEY"),
    model="anthropic.claude-haiku-4-5-20251001-v1:0",
    api_base_url="https://YOUR_STDAPI_URL/v1",
)

Any text/chat-capable model works here; it never needs to match the embedding or reranking model. See Chat Completions API for supported models.

Other Frameworks

The same two-route pattern—OpenAI-compatible /v1 for embedding and generation, Cohere-compatible /cohere for reranking—applies to any framework built on those SDKs, including LlamaIndex, RAGFlow, and LightRAG. Set the base URL and API key on the framework's OpenAI and Cohere client configuration; the vector store itself (pgvector, Qdrant, or an in-memory store) is unaffected and stores whatever the embedder returns.

n8n cannot rerank through stdapi.ai

n8n's Cohere Reranker node has no base URL field—see n8n Integration: Known Limitations for a workaround.


Next Steps