હોમ / માર્ગદર્શિકાઓ / RAG માટે મફત LLM API

RAG માટે મફત LLM API

Retrieval-augmented generation (RAG) ને બે APIs જોઈએ છે: સંબંધિત લખાણ શોધવા માટે એક embedding મૉડેલ, અને જવાબ લખવા માટે એક chat મૉડેલ. બંને મફત ટિયર પર ઉપલબ્ધ છે. FreeLLMAPI 44 મફત embedding મૉડેલો અને 478 મફત chat મૉડેલો માટે એક OpenAI-compatible key આપે છે, providers વચ્ચે failover સાથે. આ માર્ગદર્શિકા દરેક પગલા માટે મફત મૉડેલો અને સંપૂર્ણ Python pipeline બતાવે છે.

કોડ, મૉડેલ નામ અને લાઇવ કૅટલૉગ લેબલ અંગ્રેજીમાં બતાવવામાં આવે છે.

મફત ટિયર પર RAG pipeline

પગલુંAPIમફત ટિયરની ચિંતા
1. દસ્તાવેજોને chunks માં વિભાજિત કરોકોઈ નહીં (સ્થાનિક કોડ)કોઈ નહીં
2. દરેક chunk ને embed કરો/v1/embeddingsશરૂઆતમાં ઘણી વિનંતીઓ. કેટલાક મફત embedding ટિયર પ્રતિ મિનિટ 10 વિનંતીઓ આપે છે.
3. પ્રશ્નને embed કરો/v1/embeddingsદરેક પ્રશ્ન દીઠ એક વિનંતી
4. ટોચના chunks શોધોકોઈ નહીં (સ્થાનિક vector search)કોઈ નહીં
5. chunks ને rerank કરો (વૈકલ્પિક)/v1/chat/completionsદરેક પ્રશ્ન દીઠ એક વધારાની chat વિનંતી
6. જવાબ લખો/v1/chat/completionsમોટા prompts. પ્રતિ મિનિટ tokens ની મર્યાદા લાગુ પડે છે.

પગલું 2 સૌથી મોંઘું પગલું છે. તે દરેક દસ્તાવેજ માટે એક વાર કરો. vectors સાચવો, અને પછી ફક્ત નવા અથવા બદલાયેલા દસ્તાવેજોને embed કરો.

FreeLLMAPI અને Python packages ઇન્સ્ટૉલ કરો

curl -fsSL https://freellmapi.co/install.sh | bash

python3 -m pip install -U openai numpy
export FREELLMAPI_API_KEY=<unified-key>

મફત embedding મૉડેલ પસંદ કરો

એક embedding family પસંદ કરો અને તેને આખા index માટે રાખો. બે મૉડેલોના vectors સુસંગત નથી. FreeLLMAPI મિશ્ર vectors સામે તમારું રક્ષણ કરે છે: embedding failover ક્યારેય મૉડેલ બદલતું નથી. તે ફક્ત એ જ family ની સેવા આપતા providers વચ્ચે જાય છે.

મૉડેલપ્રદાતાપરિમાણોમહત્તમ ઇનપુટમફત મર્યાદા
Gemini Embedding
gemini-embedding-001
Google AI Studio30722048100 rpm · 1K req/day
SEA-LION E5 Embedding 600M
aisingapore/SEA-LION-E5-Embedding-600M
SEA-LION10248192free · 10 rpm
SEA-LION ModernBERT Embedding 300M
aisingapore/SEA-LION-ModernBERT-Embedding-300M
SEA-LION10248192free · 10 rpm
SEA-LION ModernBERT Embedding 600M
aisingapore/SEA-LION-ModernBERT-Embedding-600M
SEA-LION10248192free · 10 rpm
BGE-M3
@cf/baai/bge-m3
Cloudflare Workers AI1024819210K neurons/day (shared)
EmbeddingGemma 300M
@cf/google/embeddinggemma-300m
Cloudflare Workers AI768204810K neurons/day (shared)
Qwen3 Embedding 0.6B
@cf/qwen/qwen3-embedding-0.6b
Cloudflare Workers AI1024819210K neurons/day (shared)
Cohere Embed v4
embed-v4.0
Cohere15361280001K calls/mo (shared w/ chat)
Gemini Embedding 2
gemini-embedding-2
Google AI Studio30728192free-tier rate limited
Nemotron 3 Embed 1B
nvidia/nemotron-3-embed-1b
NVIDIA NIM20484096~40 rpm
PLaMo Embedding 1B (CF)
@cf/pfnet/plamo-embedding-1b
Cloudflare Workers AI2048409610K neurons/day (shared)
BGE Small EN v1.5 (CF)
@cf/baai/bge-small-en-v1.5
Cloudflare Workers AI38451210K neurons/day (shared)
BGE Base EN v1.5 (CF)
@cf/baai/bge-base-en-v1.5
Cloudflare Workers AI76851210K neurons/day (shared)
BGE Large EN v1.5 (CF)
@cf/baai/bge-large-en-v1.5
Cloudflare Workers AI102451210K neurons/day (shared)
Mistral Embed
mistral-embed
Mistral10248192free mode · monthly cap (shared)
Codestral Embed
codestral-embed
Mistral15368192free mode · monthly cap (shared)
Llama Text Embed v2 (Pinecone)
llama-text-embed-v2
Pinecone102420485M tokens/mo per model
Multilingual E5 Large (Pinecone)
multilingual-e5-large
Pinecone10245075M tokens/mo per model
OpenAI: Text Embedding 3 Small (ElectronHub)
text-embedding-3-small
ElectronHub15368192$0.25/week shared free credits
OpenAI: Text Embedding 3 Large (ElectronHub)
text-embedding-3-large
ElectronHub30728192$0.25/week shared free credits
Nemotron 3 Embed 8B (Inferbase)
nvidia-nemotron-3-embed-8b
Inferbase409681925,000 requests/month; 100 requests and $0.50 usage/day shared
Qwen 3 Embedding 0.6B (Inferbase)
qwen3-embedding-0-6b
Inferbase102481925,000 requests/month; 100 requests and $0.50 usage/day shared
Qwen 3 Embedding 4B (Inferbase)
qwen3-embedding-4b
Inferbase256081925,000 requests/month; 100 requests and $0.50 usage/day shared
Qwen 3 Embedding 8B (Inferbase)
qwen3-embedding-8b
Inferbase409681925,000 requests/month; 100 requests and $0.50 usage/day shared
Nemotron 3.5 Embed 1B (openrouter)
nvidia/nemotron-3.5-embed-1b:free
OpenRouter204832768Zero-priced routes; standard no-purchase free quota is 50 requests/day shared.
Nemotron 3.5 Embed 8B (openrouter)
nvidia/nemotron-3.5-embed-8b:free
OpenRouter409632768Zero-priced routes; standard no-purchase free quota is 50 requests/day shared.
Nemotron 3.5 Embed 1B (nvidia)
nvidia/nemotron-3.5-embed-1b
NVIDIA NIM204832768Free NVIDIA-hosted API prototyping; not a fixed monthly credit allocation or unrestricted production offer.
Nemotron 3.5 Embed 1B (inferbase)
nvidia-nemotron-3-5-embed-1b
Inferbase204881925,000 requests/month; managed chat, embeddings and rerank share 100 requests and $0.50 of model usage/day; no card.
Nemotron 3.5 Embed 8B (inferbase)
nvidia-nemotron-3-5-embed-8b
Inferbase409681925,000 requests/month; managed chat, embeddings and rerank share 100 requests and $0.50 of model usage/day; no card.
Nemotron 3.5 Embed 8B (NVIDIA)
nvidia/nemotron-3.5-embed-8b
NVIDIA NIM409632768Free NVIDIA-hosted API prototyping; development/testing only, not unrestricted production hosting or a fixed monthly credit allocation.
BGE-M3 (SEA-LION)
BAAI/bge-m3
SEA-LION10248192free · 10 rpm
Cohere Embed English v3
embed-english-v3.0
Cohere10245121K calls/mo (shared w/ chat)
Qwen3 Embedding 8B (OVH)
Qwen3-Embedding-8B
OVH AI Endpoints409632768free · anonymous 2 req/min per IP
BGE-M3 (OVH)
bge-m3
OVH AI Endpoints10248192free · anonymous 2 req/min per IP
BGE Multilingual Gemma2 (OVH)
bge-multilingual-gemma2
OVH AI Endpoints35848192free · anonymous 2 req/min per IP
Google: Gemini Embedding 2 (ElectronHub)
gemini-embedding-2
ElectronHub30728192$0.25/week shared free credits
Google: Gemini Embedding 001 (ElectronHub)
gemini-embedding-001
ElectronHub30722048$0.25/week shared free credits
OpenAI: Text Embedding Ada 002 (ElectronHub)
text-embedding-ada-002
ElectronHub15368192$0.25/week shared free credits
Cohere Embed English Light v3
embed-english-light-v3.0
Cohere3845121K calls/mo (shared w/ chat)
Cohere Embed Multilingual v3
embed-multilingual-v3.0
Cohere10245121K calls/mo (shared w/ chat)
Cohere Embed Multilingual Light v3
embed-multilingual-light-v3.0
Cohere3845121K calls/mo (shared w/ chat)
Cohere Embed v5.0-fast
embed-v5.0-fast
Cohere20481280001,000 API calls/month shared trial/evaluation key; production is paid
Cohere Embed v5.0-pro
embed-v5.0-pro
Cohere20481280001,000 API calls/month shared trial/evaluation key; production is paid
ELLM BGE M3 (JamAI)
ellm/BAAI/bge-m3
JamAI Base102481924M ELLM embedding tokens/month shared per organization

FreeLLMAPI કૅટલૉગનો લાઇવ ડેટા (સંસ્કરણ 2026.12.04.516bad, તપાસ્યું 2026-12-04). મફત મર્યાદાઓ વારંવાર બદલાય છે. કૅટલૉગ દરરોજ તપાસવામાં આવે છે.

  • એક family માટે ઘણા providers: bge-m3 જેવી family એક કરતાં વધુ provider પર મફત છે. ત્યારે failover ને જવા માટે જગ્યા હોય છે.
  • મહત્તમ input: મહત્તમ input કરતાં લાંબા chunks કાપવામાં આવે છે અથવા નકારવામાં આવે છે. chunks ને આ મૂલ્ય કરતાં નાના બનાવો.
  • ભાષાઓ: અંગ્રેજી સિવાયના લખાણ માટે, bge-m3 જેવી બહુભાષી family વાપરો. નામમાં -en- ધરાવતી family અંગ્રેજી માટે છે.
  • માપ (dimensions): મોટા vectors વધુ storage વાપરે છે. નાના index માટે, આ સમસ્યા નથી.

Python માં સંપૂર્ણ RAG કોડ

સ્ક્રિપ્ટ લખાણ ફાઇલોને chunks માં વિભાજિત કરે છે, તેમને batches માં embed કરે છે અને NumPy વડે vectors સાચવે છે. પછી તે ટોચના chunks વડે પ્રશ્નનો જવાબ આપે છે અને સ્રોતો આપે છે. જ્યારે મર્યાદા વિનંતીને રોકે ત્યારે તે ફરી પ્રયાસ કરે છે.

rag.py

import json
import os
import pathlib
import time

import numpy as np
import openai
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:3001/v1",
    api_key=os.environ["FREELLMAPI_API_KEY"],
    max_retries=3,
    timeout=90,
)
EMBED_MODEL = "bge-m3"   # keep one family for the whole index
CHAT_MODEL = "auto"      # or a long-context profile: auto:<profile>
INDEX = pathlib.Path("index")

def with_retry(fn, *args, **kwargs):
    for attempt in range(6):
        try:
            return fn(*args, **kwargs)
        except openai.RateLimitError as err:
            header = err.response.headers.get("retry-after", "")
            time.sleep(min(int(header) if header.isdigit() else 2 ** attempt, 120))
    raise RuntimeError("Rate limited on every provider")

def chunk(text: str, size: int = 1500, overlap: int = 200) -> list[str]:
    step = size - overlap
    return [text[i:i + size] for i in range(0, max(len(text), 1), step)]

def embed(texts: list[str], batch: int = 32) -> np.ndarray:
    out = []
    for i in range(0, len(texts), batch):
        resp = with_retry(client.embeddings.create, model=EMBED_MODEL, input=texts[i:i + batch])
        out.extend(d.embedding for d in resp.data)
    vecs = np.array(out, dtype=np.float32)
    return vecs / np.linalg.norm(vecs, axis=1, keepdims=True)

def build(folder: str) -> None:
    chunks = []
    for path in sorted(pathlib.Path(folder).rglob("*.md")):
        for part in chunk(path.read_text(encoding="utf-8")):
            if part.strip():
                chunks.append({"source": str(path), "text": part})
    INDEX.mkdir(exist_ok=True)
    np.save(INDEX / "vectors.npy", embed([c["text"] for c in chunks]))
    (INDEX / "chunks.json").write_text(json.dumps(chunks))

def answer(question: str, k: int = 5) -> str:
    vecs = np.load(INDEX / "vectors.npy")
    chunks = json.loads((INDEX / "chunks.json").read_text())
    q = embed([question])[0]
    top = np.argsort(vecs @ q)[::-1][:k]
    context = "\n\n".join(f"[{n + 1}] ({chunks[i]['source']})\n{chunks[i]['text']}" for n, i in enumerate(top))
    resp = with_retry(
        client.chat.completions.create,
        model=CHAT_MODEL,
        temperature=0,
        messages=[
            {"role": "system", "content": "Answer only from the sources. Cite them as [1], [2]. If the sources do not answer, say so."},
            {"role": "user", "content": f"Sources:\n{context}\n\nQuestion: {question}"},
        ],
    )
    return resp.choices[0].message.content

if __name__ == "__main__":
    if not (INDEX / "vectors.npy").exists():
        build("docs")
    print(answer("How do I rotate the API keys?"))

થોડા હજાર કરતાં વધુ chunks માટે, NumPy શોધને vector database થી બદલો. embedding અને chat કૉલ એ જ રહે છે.

વપરાશકર્તાઓ ઘણી વાર એ જ પ્રશ્ન ફરી પૂછે છે. FreeLLMAPI પાસે એકસરખી વિનંતીઓ માટે opt-in response cache છે. cache hit કોઈ provider quota વાપરતો નથી. X-FreeLLM-Cache: on અથવા off header વડે એક વિનંતી માટે cache ચાલુ કે બંધ કરી શકાય છે. temperature=0 વાપરો, જેથી એ જ પ્રશ્ન એ જ વિનંતી આપે.

rerank પગલું ઉમેરો

Vector search સમાન લખાણ શોધે છે, પરંતુ ટોચનો chunk હંમેશાં શ્રેષ્ઠ જવાબ હોતો નથી. rerank પગલું ઉમેદવારોને ફરીથી ક્રમ આપે છે. FreeLLMAPI દસ્તાવેજો સમર્પિત rerank endpoint વર્ણવતા નથી. તમે reranker તરીકે ઝડપી chat મૉડેલ વાપરી શકો છો. 15 ઉમેદવારો મેળવો અને શ્રેષ્ઠ 5 રાખો.

auto:fast સાથે LLM rerank

def rerank(question: str, candidates: list[str], keep: int = 5) -> list[int]:
    listing = "\n".join(f"{n}: {c[:400]}" for n, c in enumerate(candidates))
    resp = with_retry(
        client.chat.completions.create,
        model="auto:fast",
        temperature=0,
        messages=[{
            "role": "user",
            "content": (
                f"Question: {question}\n\nPassages:\n{listing}\n\n"
                f"Return the numbers of the {keep} most useful passages, best first, "
                "as a JSON list of integers. Return only the list."
            ),
        }],
    )
    try:
        ids = json.loads(resp.choices[0].message.content.strip())
        return [i for i in ids if isinstance(i, int) and 0 <= i < len(candidates)][:keep]
    except (json.JSONDecodeError, AttributeError):
        return list(range(min(keep, len(candidates))))  # fall back to vector order


# Use it in answer(): take 15 candidates, keep the best 5
# top = np.argsort(vecs @ q)[::-1][:15]
# best = rerank(question, [chunks[i]["text"] for i in top])
# top = [top[i] for i in best]

rerank પગલું પ્રશ્ન દીઠ એક chat વિનંતી ઉમેરે છે. જો તમારી મફત મર્યાદા કડક હોય, તો તેને છોડો. સારું chunking ઘણી વાર rerank પગલા કરતાં વધુ મદદ કરે છે.

લાંબો context: retrieval ક્યારે જરૂરી નથી

આજે, 56 મફત મૉડેલ offers માં 10 લાખ tokens કે તેથી વધુનો context window છે. જો તમારા દસ્તાવેજો નાના હોય, તો તમે બધા prompt માં મોકલી શકો છો અને vector index છોડી શકો છો. આ સરળ છે, પરંતુ દરેક પ્રશ્ન ત્યારે ઘણા tokens મોકલે છે.

સૌથી મોટા context window ધરાવતા મફત મૉડેલો
મૉડેલમફત ઉપલબ્ધસંદર્ભમફત મર્યાદા (શ્રેષ્ઠ ઑફર)સાધનોવિઝન
OpenAI: GPT-6 LunaElectronHub1.1M$0.25/week shared free creditsનાના
GLM 5.3Router9, UnoRouter1M1 વિનંતી/મિનિટ
1 req/min per model
હાના
Gemini 3.8 FlashGoogle AI Studio1MRecurring provider quotaહાહા
Gemini 3.7 FlashGoogle AI Studio1M10 વિનંતી/મિનિટ
20 વિનંતી/દિવસ
250,000 ટોકન/મિનિટ
~3M
હાહા
DeepSeek V4 FlashAMD Radeon Cloud, BazaarLink, ElectronHub1M10 વિનંતી/મિનિટ
50 વિનંતી/દિવસ
Shared rate limit
હાના
DeepSeek V4 Flash 0731ElectronHub, Router91M10,000 credits/month (~$1), shared; account-anniversary resetનાના
Gemini 3.6 FlashGoogle AI Studio1M10 વિનંતી/મિનિટ
20 વિનંતી/દિવસ
250,000 ટોકન/મિનિટ
~3M
હાહા
GLM 5.2Router91M10,000 credits/month (~$1), shared; account-anniversary resetનાના
Gemini 3.5 FlashGoogle AI Studio1M10 વિનંતી/મિનિટ
20 વિનંતી/દિવસ
250,000 ટોકન/મિનિટ
~3M
હાહા
DeepSeek V4 ProRouter91M10,000 credits/month (~$1), shared; account-anniversary resetનાના

મેળ ખાતા 35 મફત મૉડેલમાંથી 10 બતાવ્યા. બધા મૉડેલ જુઓ.

FreeLLMAPI કૅટલૉગનો લાઇવ ડેટા (સંસ્કરણ 2026.12.04.516bad, તપાસ્યું 2026-12-04). મફત મર્યાદાઓ વારંવાર બદલાય છે. કૅટલૉગ દરરોજ તપાસવામાં આવે છે.

  • લાંબો context વાપરો થોડા દસ્તાવેજો માટે, પૂરા લખાણની જરૂર હોય તેવા પ્રશ્નો માટે, અથવા એક જ report માટે.
  • Retrieval વાપરો ઘણા દસ્તાવેજો માટે, વારંવારના પ્રશ્નો માટે, અથવા જ્યારે મફત પ્રતિ મિનિટ tokens ની મર્યાદા ઓછી હોય.
  • બંનેને જોડો: 20 કે તેથી વધુ chunks મેળવો અને તેમને લાંબા-context મૉડેલ પર મોકલો.

ઓછી પ્રતિ મિનિટ tokens મર્યાદાવાળા provider પર મોટો prompt નિષ્ફળ જઈ શકે છે. ત્યારે FreeLLMAPI આગલા provider નો પ્રયાસ કરે છે. કયા મૉડેલો મોટા prompts મેળવે તે નિયંત્રિત કરવા, ફક્ત લાંબા-context મૉડેલો ધરાવતો fallback chain profile બનાવો. તેને auto:<profile> તરીકે વાપરો.

મર્યાદાઓ અને સમસ્યાનિવારણ

સમસ્યાકારણઉકેલ
Ingestion 429 પર અટકે છેembedding family બધા providers પર તેની મર્યાદા પર છેમોટા batches વાપરો, Retry-After ની રાહ જુઓ, ભાગોમાં ingest કરો
ફેરફાર પછી ખરાબ પરિણામોindex માં બે families ના vectors છેએક family વડે બધા chunks ફરીથી embed કરો
input લંબાઈ વિશે ભૂલએક chunk family ની મહત્તમ input કરતાં લાંબો છેનાના chunks વાપરો
જવાબ સ્રોતોને અવગણે છેમૉડેલ પોતાના જ્ઞાનમાંથી જવાબ આપે છેtemperature=0 અને કડક system prompt વાપરો
જવાબ પર context લંબાઈની ભૂલઘણા બધા અથવા ખૂબ લાંબા chunksk ઘટાડો, અથવા લાંબા-context profile વાપરો
જવાબોની શૈલી બદલાય છેરાઉટરે અલગ મૉડેલ પસંદ કર્યુંX-Session-Id header મોકલો, અથવા મૉડેલ પિન કરો

મફત ટિયરમાં કોઈ SLA નથી. સૌથી મજબૂત મૉડેલો પહેલાં તેમની દૈનિક મર્યાદા સુધી પહોંચે છે, અને ઘણી મર્યાદાઓ મધ્યરાત્રિ UTC એ રીસેટ થાય છે. તમારી pipeline ને એ જ મૉડેલો સાથે પરીક્ષણ કરો જે તમારી chain ખરેખર વાપરશે.

આ બધાનો ઉપયોગ એક જ કી દ્વારા કરો. FreeLLMAPI એક ઓપન-સોર્સ, સ્વ-હોસ્ટેડ રાઉટર છે. તે આ બધા મફત ટાયરને એક OpenAI સાથે સુસંગત એન્ડપોઇન્ટ પાછળ મૂકે છે અને જ્યારે એક મૉડેલની રેટ મર્યાદા આવે ત્યારે બીજા પર આપમેળે સ્વિચ કરે છે. કૅટલૉગ બ્રાઉઝ કરો અથવા લાઇવ જાઓ.

વારંવાર પૂછાતા પ્રશ્નો

શું RAG માટે મફત API છે?

હા. ઘણા providers પાસે મફત embedding અને chat ટિયર છે. FreeLLMAPI બંનેની સેવા એક OpenAI-compatible key વડે આપે છે, providers વચ્ચે failover સાથે.

RAG માટે કયું મફત embedding મૉડેલ શ્રેષ્ઠ છે?

એવી family પસંદ કરો જે ઘણા providers પર મફત હોય અને તમારી ભાષાઓને બંધબેસે. બહુભાષી લખાણ માટે, bge-m3 એક સામાન્ય પસંદગી છે. આખા index માટે એક family રાખો.

શું મફત rerank API છે?

FreeLLMAPI દસ્તાવેજો rerank endpoint વર્ણવતા નથી. આ પૃષ્ઠ પર બતાવ્યા પ્રમાણે તમે ઝડપી chat મૉડેલ વડે rerank કરી શકો છો, અથવા rerank પગલું છોડી શકો છો.

જો મફત મૉડેલમાં 10 લાખ tokens નો context હોય તો શું મને RAG ની જરૂર છે?

થોડા નાના દસ્તાવેજો માટે નહીં. ઘણા દસ્તાવેજો અથવા વારંવારના પ્રશ્નો માટે, retrieval દરેક વિનંતી માટે ઓછા tokens મોકલે છે અને મફત મર્યાદાઓમાં રહે છે.

શું હું પછીથી embedding મૉડેલ બદલી શકું?

હા, પરંતુ તમારે બધા chunks ફરીથી embed કરવા પડશે. બે મૉડેલોના vectors સુસંગત નથી, તેથી તેમને એક index માં ભેળવશો નહીં.

સંબંધિત માર્ગદર્શિકાઓ

સ્રોતો

બધી માર્ગદર્શિકાઓ · બધા મફત મૉડેલ જુઓ