POST
javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 const axios = require('axios'); const api_key = "YOUR API-KEY"; const url = "https://api.segmind.com/v1/gemini-embedding-001"; const data = { "input": "Segmind provides fast and affordable AI model inference APIs for image, video, audio, and text generation.", "task_type": "RETRIEVAL_DOCUMENT" }; (async function() { try { const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } }); console.log(response.data); } catch (error) { console.error('Error:', error.response.data); } })();
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


inputstr *

Text to embed; max 2,048 tokens. Use a sentence or paragraph that represents the content you want to index or compare.


task_typeenum:str ( default: RETRIEVAL_DOCUMENT )

Optimizes the embedding for a specific downstream task. Use RETRIEVAL_DOCUMENT for indexing, RETRIEVAL_QUERY for search queries, SEMANTIC_SIMILARITY for comparisons.

Allowed values:


output_dimensionalityint ( default: 1 )

Truncates the output vector to this size via MRL. Recommended values: 768 (compact), 1536 (balanced), 3072 (full quality).

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

Gemini Embedding 001 — Text Embedding Model

What is Gemini Embedding 001?

Gemini Embedding 001 is Google's production-grade text embedding model, now generally available via the Gemini API and on Segmind. It converts text into high-dimensional numerical vectors that capture deep semantic meaning — enabling machines to understand what text means, not just what it says.

Trained with Matryoshka Representation Learning (MRL), the model outputs 3072-dimensional embeddings by default, but you can truncate them to 768 or 1536 dimensions with minimal quality loss. It supports over 100 languages and accepts inputs up to 2,048 tokens, making it one of the most versatile embedding models available today.

Gemini Embedding 001 holds the #1 ranking on the MTEB Multilingual leaderboard with a mean score of 68.32 — outperforming the second-best model by +5.09 points.

Key Features

  • 3072-dimensional embeddings with MRL-based truncation to 768 or 1536 dims
  • 100+ language support — one model for global applications
  • 8 task types — optimize embeddings for retrieval, classification, clustering, similarity, Q&A, and more
  • 2,048-token input limit — handles long documents and paragraphs
  • Synchronous response — no polling needed, results arrive immediately
  • MTEB #1 — top-ranked multilingual embedding model as of 2025

Best Use Cases

Retrieval-Augmented Generation (RAG): Gemini Embedding 001 consistently retrieves the correct answer over 81% of the time in RAG benchmarks — a 3.6% improvement over competing models. Use RETRIEVAL_DOCUMENT to index your knowledge base and RETRIEVAL_QUERY at query time.

Semantic Search: Move beyond keyword matching. Embed user queries and document corpora to surface contextually relevant results even when exact terms differ. Works across science, legal, finance, and code domains.

Clustering and Classification: Group similar documents or classify text by topic, sentiment, or category. The model's high-dimensional, semantically rich embeddings produce tight clusters with minimal noise.

Multilingual Applications: A single embedding model handles 100+ languages without language-specific fine-tuning. Build cross-lingual search or document matching pipelines with one endpoint.

Anomaly Detection: Compare embedding distributions across your data to surface outliers or detect semantic drift over time.

Prompt Tips and Output Quality

  • Always set task_type explicitly — the right task type improves search relevance by 10–30%. Use RETRIEVAL_DOCUMENT for corpus indexing and RETRIEVAL_QUERY for live search terms.
  • For storage-constrained applications, set output_dimensionality to 768 or 1536. MRL training preserves most semantic information even at lower dimensions.
  • Keep inputs under 2,048 tokens. For long documents, chunk text into overlapping passages of ~512 tokens for best retrieval performance.
  • The model is synchronous — expect low-latency responses suitable for real-time applications.

FAQs

What is the difference between RETRIEVAL_DOCUMENT and RETRIEVAL_QUERY? Use RETRIEVAL_DOCUMENT when embedding content you are indexing (e.g. knowledge base articles). Use RETRIEVAL_QUERY when embedding the user's search query at runtime. Using the correct task type for each role materially improves recall.

Can I reduce embedding size to save storage? Yes. Set output_dimensionality to 768 or 1536. Gemini Embedding 001 is trained via MRL, which preserves the most semantically important information in the leading dimensions — truncation causes only minor quality loss.

How many languages does it support? Gemini Embedding 001 supports over 100 languages natively. No language-specific configuration is required.

Is this model suitable for real-time search? Yes. The API responds synchronously with very low latency, making it well-suited for live autocomplete, real-time document retrieval, and interactive chatbots.

What is the max input length? 2,048 tokens. For longer documents, split into overlapping chunks before embedding.

How does it compare to OpenAI text-embedding-3-large? Gemini Embedding 001 outperforms text-embedding-3-large on MTEB Multilingual benchmarks, ranking #1 overall with a mean score of 68.32 across diverse tasks including retrieval, classification, and clustering.