Back to blog
Technical guide·May 25, 2026·7 min read

Build a Spanish RAG chatbot with Claude — a practical guide for LATAM and Spain

A complete stack for Spanish RAG: text-embedding-3-large (called directly from OpenAI — Kunavo does not provide embeddings) + pgvector + Claude Sonnet 4.6 + prompt caching. ~$0.007 per query across both providers. Regional variants (voseo, tuteo, ustedeo), Spanish tokens (1.3–1.5x more than English), hallucination prevention, and real monthly costs for 100 to 10,000 queries per day.

Build a Spanish-language RAG chatbot that accurately answers questions about your knowledge base — a practical guide for product teams in Spain and Latin America. We cover model selection, handling regional Spanish variants, cost per query, and how to prevent hallucinations.

The basic stack

  1. Embed documents with text-embedding-3-large, called directly through OpenAI —— Kunavo does not serve embeddings, only the generation step
  2. Vector search (pgvector, Pinecone, or Qdrant)
  3. Response generation with Claude Sonnet 4.6 + prompt caching
  4. Fallback to Gemini 2.5 Flash for high load / minimum costs

Basic snippet

responder.py
from openai import OpenAI

client = OpenAI(
    api_key="sk-kn-...",
    base_url="https://api.kunavo.com/v1",
)

def responder(pregunta: str, contexto: list[str]) -> str:
    """Responde en español usando contexto recuperado de la base de conocimiento."""
    resp = client.chat.completions.create(
        model="claude-sonnet-4-6",
        messages=[
            {
                "role": "system",
                "content": [
                    {
                        "type": "text",
                        "text": (
                            "Eres un asistente que responde en español neutro, "
                            "claro y conciso, basándote exclusivamente en el "
                            "contexto proporcionado. Si la respuesta no está en "
                            "el contexto, di 'No tengo esa información' en lugar "
                            "de inventar."
                        ),
                        "cache_control": {"type": "ephemeral"},
                    },
                ],
            },
            {
                "role": "user",
                "content": (
                    f"## Contexto\n{chr(10).join(contexto)}\n\n"
                    f"## Pregunta\n{pregunta}"
                ),
            },
        ],
        max_tokens=600,
    )
    return resp.choices[0].message.content

Cost per query: approximately $0.004 (less than half a euro cent) with caching enabled. Without caching, around $0.01. The difference makes it worthwhile to configure cache_control correctly.

Neutral Spanish vs. regional variants

If your product serves users in Spain and Latin America at the same time, you have three options:

  • Neutral Spanish (recommended by default): Ask the model to use “usted/ustedes” formally and avoid regionalisms. It works in all countries but sounds slightly impersonal
  • Country detection + specific prompt: Use the IP or user settings to choose between “voseo” (Argentina, Uruguay), “tuteo” (Spain, Mexico), and “ustedeo” (Colombia, certain regions). Pass the dialect in the system prompt
  • One model per market: Only if you have dedicated teams and high volume in each region. For most, this is overkill

Claude Sonnet 4.6 and Gemini 2.5 Pro understand all variants; the output follows the prompt’s style. A line such as “Respond in Rioplatense Spanish (voseo, e.g., ‘vos podés’)” is enough.

Tokens in Spanish

Spanish uses approximately 1.3-1.5x more tokens than English for the same content (because of longer endings and articles). Adjust your input and output budgets accordingly. A 5K-token context in English becomes ~6.5K in Spanish.

Anti-hallucination — what actually works

  • Explicit system prompt: “If the answer is not in the context, say ‘I don’t have that information.’” The model follows this more in neutral Spanish than in other languages; we don’t know why
  • Cite the source: Ask it to return the ID of the document each claim came from. If the ID is made up, you know it hallucinated
  • Limit the output: max_tokens=300 greatly reduces the temptation to invent filler
  • Adversarial tests: 50 questions from your dataset marked as “unanswerable with the current context.” Your chatbot must reject all of them

Estimated monthly cost (Spanish)

  • 100 queries/day: ~$11/month with caching
  • 1,000 queries/day: ~$110/month
  • 10,000 queries/day: ~$1,100/month

If you reach 10,000+ and need to cut costs further, switch simple queries to Gemini 2.5 Flash (4 to 10 times cheaper) and reserve Sonnet 4.6 for complex ones. The tiering pattern is described in cost optimization guide.

Payments from Spain and Latin America

Stripe processes the payment according to the country: Pix (Brazil), international cards, Apple Pay, Google Pay, and Link. Prices are in USD, and Stripe may display the amount in your local currency; its rate includes a 2–4% conversion fee paid by the buyer, while paying in USD avoids it (Stripe Adaptive Pricing documentation, read on 2026-10-03). Bizum, PayPal, OXXO, and Mercado Pago are not available, nor is Pay by Bank: Kunavo Checkout offers it only to buyers in the United Kingdom, Ireland, and Finland, and in France and Germany Stripe still has it in private preview (Stripe Pay by Bank documentation, read on 2026-10-03). Minimum top-up $10 USD. The balance does not expire.

Support and documentation

Spanish-language support at contact@kunavo.com within 24 business hours. Full technical documentation at /docs/quickstart; complete prompt caching guide at prompt caching deep dive.

Ready? Sign up for free, top up from $10, and pay only for what you use to build a first working prototype.