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

# 生成 Gemini 兼容内容

> Gemini 兼容的 generateContent 接口。路径中的 model 是 APIAny.AI 公开模型 ID。



## OpenAPI

````yaml /zh/openapi.json post /v1beta/models/{model}:generateContent
openapi: 3.1.0
info:
  title: APIAny.AI 公开 API
  version: 1.0.0
  description: APIAny.AI 模型聚合、异步媒体任务、对话生成、积分查询和任务查询的公开 API。
servers:
  - url: https://apiany.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Models
    description: 公开模型目录。
  - name: Chat
    description: 文本生成和对话兼容接口。
  - name: Images
    description: 图片生成和图片编辑接口。
  - name: Videos
    description: 视频生成接口。
  - name: Moderation
    description: Image safety and moderation endpoints.
  - name: Tasks
    description: 异步任务查询。
  - name: Account
    description: 账户与积分查询。
  - name: Free APIs
    description: Free utility APIs protected by API key rate limits.
paths:
  /v1beta/models/{model}:generateContent:
    post:
      tags:
        - Chat
      summary: 生成 Gemini 兼容内容
      description: Gemini 兼容的 generateContent 接口。路径中的 model 是 APIAny.AI 公开模型 ID。
      operationId: generateGeminiContent
      parameters:
        - name: model
          in: path
          required: true
          schema:
            type: string
          example: gemini-3.5-flash
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GeminiGenerateContentRequest'
      responses:
        '200':
          description: Gemini 兼容响应。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeminiGenerateContentResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    GeminiGenerateContentRequest:
      type: object
      properties:
        contents:
          type: array
          items:
            type: object
            properties:
              role:
                type: string
              parts:
                type: array
                items:
                  type: object
                  additionalProperties: true
            required:
              - parts
        generationConfig:
          type: object
          description: >-
            生成配置。另外：调用 :streamGenerateContent（而非 :generateContent）可获得 Gemini SSE
            流。
          properties:
            temperature:
              type: number
              minimum: 0
              maximum: 2
            topP:
              type: number
            topK:
              type: integer
            maxOutputTokens:
              type: integer
            stopSequences:
              type: array
              items:
                type: string
            responseMimeType:
              type: string
              description: 如 'application/json' 用于结构化输出。
            responseSchema:
              type: object
              additionalProperties: true
              description: 结构化输出的 JSON Schema（配合 responseMimeType application/json）。
            responseModalities:
              type: array
              items:
                type: string
              description: 含 'IMAGE' 时返回图片生成结果。
          additionalProperties: true
        tools:
          type: array
          description: 含 functionDeclarations 的工具声明。
          items:
            type: object
            additionalProperties: true
        systemInstruction:
          type: object
          additionalProperties: true
          description: '系统指令，Gemini Content 对象（{ parts: [{ text }] }）。'
      required:
        - contents
    GeminiGenerateContentResponse:
      type: object
      properties:
        candidates:
          type: array
          items:
            type: object
            additionalProperties: true
        usageMetadata:
          type: object
          additionalProperties: true
      required:
        - candidates
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              enum:
                - invalid_request
                - auth_error
                - rate_limit
                - insufficient_quota
                - content_policy
                - timeout
                - network_error
                - service_error
                - billable_error
                - unknown
            message:
              type: string
            param:
              type:
                - string
                - 'null'
            code:
              type:
                - string
                - 'null'
          required:
            - type
            - message
      required:
        - error
  responses:
    BadRequest:
      description: 请求参数无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: 缺少 API Key 或 API Key 无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key

````