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

# Gemini 风格

> Gemini generateContent 风格（原生字段结构）

## Base URL

* `https://api.qhaigc.net`
* `https://api-hk.qhaigc.net`

## Endpoint

`POST /v1beta/models/{model}:generateContent`

示例模型：`gemini-2.5-pro`、`gemini-2.5-flash`

## 鉴权与请求头

| Header                                 | 是否必填 | 说明         |
| :------------------------------------- | :--- | :--------- |
| `Authorization: Bearer <YOUR_API_KEY>` | 是    | 启航 API Key |
| `Content-Type: application/json`       | 是    | JSON 请求体   |

## 请求体格式（Gemini 原生）

| 字段                 | 类型     | 必填 | 说明                                      |
| :----------------- | :----- | :- | :-------------------------------------- |
| `contents`         | array  | 是  | 对话内容，包含 `role` 与 `parts`                |
| `generationConfig` | object | 否  | 生成参数（如 `temperature`、`maxOutputTokens`） |
| `safetySettings`   | array  | 否  | 安全策略                                    |
| `tools`            | array  | 否  | 工具定义                                    |

## 请求示例

```bash theme={null}
curl --location --request POST 'https://api.qhaigc.net/v1beta/models/gemini-2.5-pro:generateContent' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "请用简洁中文解释 RAG 的工作流程"
        }
      ]
    }
  ],
  "generationConfig": {
    "temperature": 0.4,
    "maxOutputTokens": 512
  }
}'
```

## 响应结构示例

```json theme={null}
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "RAG 的流程通常分为检索、增强、生成三步..."
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 18,
    "candidatesTokenCount": 76,
    "totalTokenCount": 94
  }
}
```

## 官方格式参考

* [Gemini API - Generate content](https://ai.google.dev/gemini-api/docs/text-generation)
* [Gemini API Reference - generateContent](https://ai.google.dev/api/generate-content)

## 相关页面

* [OpenAI 风格](/docs/api-reference/chat/openai-style)
* [Claude 风格](/docs/api-reference/chat/claude-style)


## OpenAPI

````yaml POST /v1beta/models/{model}:generateContent
openapi: 3.1.0
info:
  title: 启航 AI API
  version: 1.0.0
  description: 启航 AI API 文档，支持绘图、语音生成、视频生成、音乐生成等多种 AIGC 接口。
servers:
  - url: https://api.qhaigc.net
    description: 生产服务器
security:
  - bearerAuth: []
paths:
  /v1beta/models/{model}:generateContent:
    post:
      tags:
        - 聊天模型
      summary: Gemini 风格生成
      description: 使用 Gemini generateContent 风格进行对话
      parameters:
        - name: model
          in: path
          required: true
          schema:
            type: string
          description: 模型名称，如 gemini-2.5-pro
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                contents:
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - user
                          - model
                      parts:
                        type: array
                        items:
                          type: object
                          properties:
                            text:
                              type: string
                    required:
                      - role
                      - parts
                generationConfig:
                  type: object
                  properties:
                    temperature:
                      type: number
                    maxOutputTokens:
                      type: integer
                safetySettings:
                  type: array
                  items:
                    type: object
                tools:
                  type: array
                  items:
                    type: object
              required:
                - contents
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                type: object
                properties:
                  candidates:
                    type: array
                    items:
                      type: object
                      properties:
                        content:
                          type: object
                          properties:
                            role:
                              type: string
                            parts:
                              type: array
                              items:
                                type: object
                                properties:
                                  text:
                                    type: string
                        finishReason:
                          type: string
                  usageMetadata:
                    type: object
                    properties:
                      promptTokenCount:
                        type: integer
                      candidatesTokenCount:
                        type: integer
                      totalTokenCount:
                        type: integer
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````