Embeddings

Create Embeddings

Generate vector embeddings with an OpenAI-compatible response format.

Models: google/gemini-embedding-2 supports text, image, audio, and video. cohere/embed-v4.0 supports text and one image. OpenAI and Qwen embedding models are text-only.

Input: Pass a string, an array of up to 32 strings, or supported multimodal content parts (text, image_url, input_audio, video_url) in the input field.

Retrieval roles: Use task_type with Gemini text input; it is converted to the model's recommended prompt instruction. Use input_type (query or document) with Cohere.

Billing: Gemini task instructions count toward prompt token usage. Cohere image requests expose one combined usage count, so text accompanying an image is billed at the image-input rate.

Gemini migration: google/gemini-embedding-2 uses the GA embedding space. Do not mix preview-era and GA vectors; re-embed stored google/gemini-embedding-2 data before comparing it with new results.

Dimensions: Defaults are model-specific. Qwen supports up to 4096; Gemini and OpenAI large up to 3072; OpenAI small up to 1536; Cohere supports 256, 512, 1024, or 1536.

post/v1/embeddings

Request

  • Base URL: https://gen.pollinations.ai
  • URL: https://gen.pollinations.ai/v1/embeddings
  • Auth: HTTP bearer

Request body

modelstring

Embedding model to use

dimensionsinteger

Output embedding dimensions (128-4096). Model-specific limits apply; Cohere supports 256, 512, 1024, or 1536.

task_type'SEMANTIC_SIMILARITY' | 'CLASSIFICATION' | 'CLUSTERING' | 'RETRIEVAL_DOCUMENT' | 'RETRIEVAL_QUERY' | 'CODE_RETRIEVAL_QUERY' | 'QUESTION_ANSWERING' | 'FACT_VERIFICATION'

Gemini text-specific task hint, converted to the model's recommended prompt instruction

input_type'query' | 'document'

Cohere-specific input role for retrieval. Use document when indexing and query when searching.

encoding_format'float' | 'base64'

Output encoding for the embedding vector. base64 packs Float32 little-endian like OpenAI.

Example request

{
  "model": "google/gemini-embedding-2",
  "input": {
    "image_url": {
      "url": "https://example.com/image.jpg"
    }
  },
  "dimensions": 768,
  "task_type": "RETRIEVAL_QUERY",
  "input_type": "query",
  "encoding_format": "float"
}

Response

Success

object'list' required
modelstring required

Changes

No recorded changes to this operation across all 1 revision of this API.