New to Kestra?
Use blueprints to kickstart your first workflows.
Build a RAG pipeline with Kestra and OpenAI. Ingest documents into a KV-backed vector store, chunk them, and answer questions grounded in retrieved context.
Build a Retrieval-Augmented Generation (RAG) pipeline that ingests documents from public URLs into a vector store, then answers natural language questions grounded in the indexed content. RAG stops large language models from hallucinating by constraining every answer to retrieved source text, so teams get accurate, citable responses over their own documentation, runbooks, and knowledge bases. This blueprint runs entirely on Kestra's native AI plugin and the Kestra KV Store, with OpenAI handling embeddings and generation, so you get a working RAG system with zero external vector database to operate.
ingest_documents (io.kestra.plugin.ai.rag.IngestDocument) fetches the document URLs supplied via the document_urls input, splits them with a RECURSIVE splitter (maxSegmentSizeInChars: 1000, maxOverlapSizeInChars: 200), embeds each chunk with OpenAI text-embedding-3-small, and writes vectors to a io.kestra.plugin.ai.embeddings.KestraKVStore. With drop: true, the index is rebuilt on every run to keep the knowledge base current.answer_question (io.kestra.plugin.ai.agent.AIAgent) takes the question input as its prompt. Its EmbeddingStoreRetriever runs a semantic similarity search over the same KV store, returning up to maxResults: 5 chunks above minScore: 0.6. A systemMessage instructs the model to answer only from retrieved context, and gpt-4o generates the grounded response.log_answer (io.kestra.plugin.core.log.Log) prints outputs.answer_question.textOutput to the run logs.maxResults and minScore.A bare LLM SDK script has no scheduler, no retry semantics, and no execution history. With Kestra you can attach event triggers to re-ingest documents the moment source files change, add per-task retries to ride out transient OpenAI rate limits, and inspect full inputs, outputs, and lineage for every run from the UI. The pipeline is declarative YAML, versioned in Git, so the ingestion and retrieval configuration is reviewable and reproducible rather than buried in application code. OpenAI itself ships no orchestration layer: Kestra fills that gap with triggers, backfills, and observability around the embedding and generation calls.
text-embedding-3-small and gpt-4o.OPENAI_API_KEY: OpenAI API key used for both embeddings and chat completion.OPENAI_API_KEY secret to your Kestra instance.document_urls and question, or supply your own.log_answer task output.KestraKVStore for a production vector store (Qdrant, Elasticsearch, Pinecone) via the embeddings configuration.maxSegmentSizeInChars, maxOverlapSizeInChars, maxResults, and minScore for your corpus.