openapi: 3.1.0 info: title: Google Gemini Embeddings Utility 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: Utility description: Token counting and other helpers paths: /v1beta/models/{model}:countTokens: post: tags: - Utility summary: Count tokens for a prompt operationId: countTokens parameters: - $ref: '#/components/parameters/Model' requestBody: required: true content: application/json: schema: type: object properties: contents: type: array items: $ref: '#/components/schemas/Content' responses: '200': description: Token count content: application/json: schema: type: object properties: totalTokens: type: integer components: schemas: Content: type: object properties: role: type: string enum: - user - model - system parts: type: array items: $ref: '#/components/schemas/Part' 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 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