> ## Documentation Index
> Fetch the complete documentation index at: https://docs-vip.apigo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# /v1beta/models/{model}:generateContent

> Generates synchronous text or multimodal output with Gemini.

用于 Gemini 的同步文本生成、结构化输出和 parts 结构接入。

* 官方常见鉴权方式是 `x-goog-api-key: {API_KEY}`，也支持以查询参数携带 API Key
* `parts` 结构和 OpenAI / Claude 都不同，需要单独映射
* `systemInstruction`、`generationConfig`、`tools` 和 `safetySettings` 都在这个请求模型里配置
* 如果你需要事件流式输出，请改走 `/v1beta/models/{model}:streamGenerateContent`


## OpenAPI

````yaml POST /v1beta/models/{model}:generateContent
openapi: 3.1.0
info:
  title: OpenAPI Plant Store
  description: >-
    A sample API that uses a plant store as an example to demonstrate features
    in the OpenAPI specification
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api-vip.apigo.ai
security:
  - bearerAuth: []
paths:
  /v1beta/models/{model}:generateContent:
    post:
      summary: Gemini generateContent
      description: 使用 Gemini 生成同步文本或多模态输出。
      parameters:
        - name: model
          in: path
          description: Gemini model name.
          required: true
          schema:
            type: string
            example: gemini-2.5-pro
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GeminiGenerateContentRequest'
            example:
              contents:
                - role: user
                  parts:
                    - text: 请总结这段内容
      responses:
        '200':
          description: Successful Gemini content response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeminiGenerateContentResponse'
              example:
                candidates:
                  - content:
                      role: model
                      parts:
                        - text: 这里是总结结果。
                    finishReason: STOP
                usageMetadata:
                  promptTokenCount: 24
                  candidatesTokenCount: 36
                  totalTokenCount: 60
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - googleApiKey: []
components:
  schemas:
    GeminiGenerateContentRequest:
      type: object
      required:
        - contents
      properties:
        contents:
          type: array
          items:
            $ref: '#/components/schemas/GeminiContent'
        systemInstruction:
          $ref: '#/components/schemas/GeminiContent'
        generationConfig:
          $ref: '#/components/schemas/GeminiGenerationConfig'
        safetySettings:
          type: array
          items:
            $ref: '#/components/schemas/GeminiSafetySetting'
        tools:
          type: array
          items:
            type: object
            additionalProperties: true
    GeminiGenerateContentResponse:
      type: object
      properties:
        candidates:
          type: array
          items:
            $ref: '#/components/schemas/GeminiCandidate'
        usageMetadata:
          $ref: '#/components/schemas/GeminiUsageMetadata'
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
    GeminiContent:
      type: object
      properties:
        role:
          type: string
        parts:
          type: array
          items:
            $ref: '#/components/schemas/GeminiPart'
    GeminiGenerationConfig:
      type: object
      properties:
        temperature:
          type: number
          example: 0.7
        topP:
          type: number
        maxOutputTokens:
          type: integer
        responseMimeType:
          type: string
    GeminiSafetySetting:
      type: object
      properties:
        category:
          type: string
        threshold:
          type: string
    GeminiCandidate:
      type: object
      properties:
        content:
          $ref: '#/components/schemas/GeminiContent'
        finishReason:
          type: string
        safetyRatings:
          type: array
          items:
            $ref: '#/components/schemas/GeminiSafetyRating'
    GeminiUsageMetadata:
      type: object
      properties:
        promptTokenCount:
          type: integer
        candidatesTokenCount:
          type: integer
        totalTokenCount:
          type: integer
    GeminiPart:
      type: object
      properties:
        text:
          type: string
        inlineData:
          $ref: '#/components/schemas/GeminiInlineData'
        fileData:
          $ref: '#/components/schemas/GeminiFileData'
    GeminiSafetyRating:
      type: object
      properties:
        category:
          type: string
        probability:
          type: string
    GeminiInlineData:
      type: object
      properties:
        mimeType:
          type: string
        data:
          type: string
    GeminiFileData:
      type: object
      properties:
        mimeType:
          type: string
        fileUri:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
    googleApiKey:
      type: apiKey
      in: header
      name: x-goog-api-key

````