You can also use the /v1beta/ route prefix instead of /gemini/v1beta/:
curl "https://api.znapai.com/v1beta/models/gemini-embedding-2:embedContent" \ -H "x-goog-api-key: $ZnapAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"content": {"parts": [{"text": "What is the meaning of life?"}]}}'
[!NOTE]
You can also authenticate using the ?key=$ZnapAI_API_KEY query parameter instead of the header if required by your integration. Both prefix routes support both auth styles.
gemini-embedding-2 does not accept a task_type field. Instead, prefix the task instruction directly into the text you embed.Retrieval use cases (asymmetric format)
Use case
Query structure
Document structure
Search query
task: search result | query: {content}
title: {title} | text: {content} (use title: none if no title)
Question answering
task: question answering | query: {content}
title: {title} | text: {content}
Fact checking
task: fact checking | query: {content}
title: {title} | text: {content}
Code retrieval
task: code retrieval | query: {content}
title: {title} | text: {content}
Single-input use cases (symmetric format) — use the same prefix for query and document.
Use case
Input structure
Classification
task: classification | query: {content}
Clustering
task: clustering | query: {content}
Semantic similarity
task: sentence similarity | query: {content}
Example structure query:
curl "https://api.znapai.com/gemini/v1beta/models/gemini-embedding-2:embedContent" \ -H "x-goog-api-key: $ZnapAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"content": {"parts": [{"text": "task: search result | query: what is the meaning of life"}]}}'
output_dimensionality truncates the output vector. Both models default to 3072 dimensions. Recommended values: 768, 1536, 3072.
[!NOTE]
gemini-embedding-2 auto-normalizes truncated dimensions (e.g. 768, 1536) so cosine similarity works correctly out of the box. gemini-embedding-001 requires you to manually L2-normalize non-3072-dim vectors client-side.