Gemini Embeddings API

Create embeddings for text

OpenAPI Specification

gemini-embeddings-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Google Gemini Embeddings API
  description: 'REST API for Google Gemini generative AI models. Supports text generation,

    chat, multimodal input, embeddings, file management, token counting,

    and batch operations. Authenticated with an API key from Google AI Studio.

    '
  version: v1beta
  contact:
    name: Gemini API Documentation
    url: https://ai.google.dev/api
servers:
- url: https://generativelanguage.googleapis.com
  description: Production
security:
- apiKeyQuery: []
- apiKeyHeader: []
tags:
- name: Embeddings
  description: Create embeddings for text
paths:
  /v1beta/models/{model}:embedContent:
    post:
      tags:
      - Embeddings
      summary: Embed content
      operationId: embedContent
      parameters:
      - $ref: '#/components/parameters/Model'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbedContentRequest'
      responses:
        '200':
          description: Embedding result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbedContentResponse'
  /v1beta/models/{model}:batchEmbedContents:
    post:
      tags:
      - Embeddings
      summary: Batch embed contents
      operationId: batchEmbedContents
      parameters:
      - $ref: '#/components/parameters/Model'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                requests:
                  type: array
                  items:
                    $ref: '#/components/schemas/EmbedContentRequest'
      responses:
        '200':
          description: Batched embeddings
          content:
            application/json:
              schema:
                type: object
                properties:
                  embeddings:
                    type: array
                    items:
                      $ref: '#/components/schemas/ContentEmbedding'
components:
  schemas:
    ContentEmbedding:
      type: object
      properties:
        values:
          type: array
          items:
            type: number
    Part:
      type: object
      properties:
        text:
          type: string
        inlineData:
          type: object
          properties:
            mimeType:
              type: string
            data:
              type: string
              format: byte
        fileData:
          type: object
          properties:
            mimeType:
              type: string
            fileUri:
              type: string
    EmbedContentResponse:
      type: object
      properties:
        embedding:
          $ref: '#/components/schemas/ContentEmbedding'
    EmbedContentRequest:
      type: object
      required:
      - content
      properties:
        content:
          $ref: '#/components/schemas/Content'
        taskType:
          type: string
        title:
          type: string
        outputDimensionality:
          type: integer
    Content:
      type: object
      properties:
        role:
          type: string
          enum:
          - user
          - model
          - system
        parts:
          type: array
          items:
            $ref: '#/components/schemas/Part'
  parameters:
    Model:
      name: model
      in: path
      required: true
      description: Model identifier (e.g. "gemini-1.5-pro")
      schema:
        type: string
  securitySchemes:
    apiKeyQuery:
      type: apiKey
      in: query
      name: key
      description: Gemini API key from Google AI Studio
    apiKeyHeader:
      type: apiKey
      in: header
      name: x-goog-api-key
      description: Gemini API key passed via header