Why gemini-embedding-001 Hits 429 RESOURCE_EXHAUSTED Faster Than Expected
Unlike OpenAI (2,048 texts per call), Vertex AI caps gemini-embedding-001 online requests at 250 texts and 20,000 summed tokens per call on several regional endpoints, and default LangChain/LlamaIndex wrappers often default to batch_size = 10 or 1, multiplying RPC request rate by 25x..250x until regional quota trips.
Immediate Python Fix: 250-Item embed_content Packing + Jittered Retry
import random, time
from google import genai
from google.genai import types
client = genai.Client()
def embed_gemini_batches(chunks: list[str], batch_size: int = 100):
for i in range(0, len(chunks), batch_size):
batch = chunks[i : i + batch_size]
for attempt in range(6):
try:
return client.models.embed_content(
model="gemini-embedding-001",
contents=batch,
config=types.EmbedContentConfig(
task_type="RETRIEVAL_DOCUMENT",
output_dimensionality=1536,
),
)
except Exception as exc:
if "429" not in str(exc) or attempt == 5:
raise
time.sleep((2 ** attempt) + random.uniform(0.1, 0.9))
High-Throughput GPU Embeddings Without Regional Quota Lotteries
Voxell Forge serves Turbo (1024d, $0 forever) and Pro (2560d, $0.25/1M tokens, up to 5,000 RPM on Scale) over a drop-in OpenAI-compatible API, or deploys inside your GCP/AWS VPC on 1x 24 GB GPU ($9,995/yr Dev) with zero external rate limits.