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

# 中转 GenerateContent（Gemini 规范）

> 接口说明：兼容 Gemini :generateContent 规范的非流式聚合中转接口；Gemini SDK 默认携带 x-goog-api-key 头。



## OpenAPI

````yaml /openapi/zh/aitoearn.openapi.json post /api/ai/v1beta/models/{model}:generateContent
openapi: 3.0.1
info:
  title: AiToEarn 开放平台 API
  description: AiToEarn 开放平台 API，支持在中国站与国际站之间切换调试。业务是否成功以响应体 code === 0 为准。
  version: 1.0.0
  contact: {}
servers:
  - url: https://aitoearn.cn
    description: 中国站
  - url: https://aitoearn.ai
    description: 国际站
security: []
tags:
  - name: AI 服务
  - name: AI 服务/视频生成
  - name: AI 服务/图像生成
  - name: AI 服务/模型中转
  - name: 渠道管理
  - name: 渠道管理/账号
  - name: 渠道管理/内容发布
  - name: 渠道管理/平台
  - name: 渠道管理/互动
  - name: 渠道管理/作品
  - name: 渠道管理/账号分组
  - name: 渠道管理/授权
  - name: 资源管理
paths:
  /api/ai/v1beta/models/{model}:generateContent:
    post:
      tags:
        - AI 服务/模型中转
      summary: 中转 GenerateContent（Gemini 规范）
      description: >-
        接口说明：兼容 Gemini :generateContent 规范的非流式聚合中转接口；Gemini SDK 默认携带
        x-goog-api-key 头。
      operationId: RelayController_geminiGenerateContent
      parameters:
        - name: model
          in: path
          description: ''
          required: true
          example: ''
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  description: Gemini 模型名称
                contents:
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - user
                          - model
                        description: 消息角色，用于区分不同消息来源
                      parts:
                        type: array
                        items:
                          anyOf:
                            - type: object
                              properties:
                                text:
                                  type: string
                                  description: 文本片段
                              required:
                                - text
                            - type: object
                              properties:
                                inlineData:
                                  type: object
                                  properties:
                                    mimeType:
                                      type: string
                                      description: 内嵌媒体类型
                                    data:
                                      type: string
                                      description: 媒体原始数据
                                  required:
                                    - mimeType
                                    - data
                                  description: 随请求直接传入的内嵌媒体字节数据
                              required:
                                - inlineData
                            - type: object
                              properties:
                                fileData:
                                  type: object
                                  properties:
                                    mimeType:
                                      type: string
                                      description: 文件来源数据的媒体类型
                                    fileUri:
                                      type: string
                                      description: 文件或媒体资源 URI
                                  required:
                                    - fileUri
                                  description: 通过 URI 引用的文件媒体数据
                              required:
                                - fileData
                        description: 单条消息中的有序内容片段列表
                    required:
                      - parts
                  description: 内容列表
                config:
                  $ref: '#/components/schemas/ModelProxyConfigVo'
              required:
                - model
                - contents
            examples: {}
        required: true
      responses:
        '200':
          description: 第三方协议原生响应或 SSE 数据。不使用 AiToEarn 通用响应包裹。
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                description: 第三方协议原生响应，不使用 AiToEarn 通用响应包裹。
              examples:
                success:
                  summary: 第三方协议原生成功响应
                  value:
                    id: RelayController_geminiGenerateContent_example
                    object: response
            text/event-stream:
              schema:
                type: string
                description: SSE 流式响应。
      deprecated: false
      security:
        - apikey-header-x-goog-api-key: []
components:
  schemas:
    ModelProxyConfigVo:
      description: 生成配置
      type: object
      properties:
        temperature:
          type: number
          description: 控制输出随机性，值越高越发散，值越低越稳定
        topP:
          type: number
          description: 核采样参数，限制抽样时考虑的 token 最大累积概率。
        topK:
          type: number
          description: Top-K 采样参数，限制抽样时考虑的最高概率 token 数量
        candidateCount:
          type: number
          description: 需要返回的候选回答数量
        maxOutputTokens:
          type: number
          description: 候选回答的最大输出 token 数
        responseLogprobs:
          type: boolean
          description: 是否返回 token 对数概率信息
        logprobs:
          type: number
          description: 每个解码步骤返回的高概率候选 token 数，仅在 `responseLogprobs=true` 时生效
        presencePenalty:
          type: number
          description: 存在惩罚，用于降低或提高已出现 token 的再次出现倾向
        frequencyPenalty:
          type: number
          description: 频次惩罚，根据 token 已出现次数抑制或鼓励重复
        seed:
          type: number
          description: 解码随机种子，用于提高输出可复现性
        responseMimeType:
          type: string
          description: 期望的响应类型
        responseJsonSchema:
          description: JSON 输出结构约束，通常配合 `responseMimeType=application/json` 使用
      additionalProperties: true
  securitySchemes:
    apikey-header-x-goog-api-key:
      type: apiKey
      in: header
      name: x-goog-api-key
      description: Gemini SDK 兼容接口使用的 API Key header。

````