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

# gemini-4-argon

> 使用文本和多模态输入、结构化 Schema、函数及内置工具生成 Gemini 4 Argon 响应。

Gemini 4 Argon 通过一个 `generateContent` 端点提供文本推理、多模态理解、结构化输出、函数调用和内置工具能力。选择对应能力查看请求和响应结构。

<Tabs sync={false}>
  <Tab title="文本与思考">
    ## 生成内容

    `POST /v1beta/models/gemini-4-argon:generateContent`

    <div className="kling-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url 'https://www.anyfast.ai/v1beta/models/gemini-4-argon:generateContent?key=YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "contents": [{
            "role": "user",
            "parts": [{
              "text": "审查这个重试方案，找出竞态条件并给出安全的实现计划。"
            }]
          }],
          "generationConfig": {
            "thinkingConfig": {"thinkingLevel": "medium"},
            "maxOutputTokens": 2048
          }
        }'
      ```
    </div>

    ## 鉴权和请求头

    <ParamField query="key" type="string" required>AnyFast API Key。</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>请求媒体类型。</ParamField>

    ## 请求体

    <ParamField body="contents" type="object[]" required>对话历史和当前用户请求。最后一项必须是非空的 `user` 轮次。</ParamField>
    <ParamField body="contents[].role" type="string" default="user">对话角色：`user` 或 `model`。请求不能以 `model` 轮次结尾。</ParamField>
    <ParamField body="contents[].parts" type="object[]" required>当前轮次的内容片段。</ParamField>
    <ParamField body="contents[].parts[].text" type="string" required>文本提示词或对话内容。</ParamField>
    <ParamField body="generationConfig.thinkingConfig.thinkingLevel" type="string" default="medium">思考等级：`low`、`medium` 或 `high`。</ParamField>
    <ParamField body="generationConfig.maxOutputTokens" type="integer">同步请求的最大生成 Token 数，取值为 1 至 32,768。</ParamField>

    ## 成功响应

    <div className="kling-api-example-panel">
      ```json 200 theme={null}
      {
        "candidates": [{
          "content": {
            "parts": [{"text": "该设计在超时处理和重试调度之间存在竞态条件……"}],
            "role": "model"
          },
          "finishReason": "STOP",
          "index": 0,
          "safetyRatings": []
        }],
        "usageMetadata": {
          "promptTokenCount": 18,
          "candidatesTokenCount": 121,
          "thoughtsTokenCount": 86,
          "totalTokenCount": 225,
          "trafficType": "ON_DEMAND"
        },
        "modelVersion": "gemini-4-argon",
        "responseId": "response-example-001"
      }
      ```
    </div>

    <ResponseField name="candidates" type="object[]">生成的候选结果。</ResponseField>
    <ResponseField name="candidates[].content" type="object">模型响应轮次。</ResponseField>
    <ResponseField name="candidates[].content.parts[].text" type="string">生成的文本。</ResponseField>
    <ResponseField name="candidates[].finishReason" type="string">停止生成的原因，例如 `STOP`、`MAX_TOKENS` 或 `SAFETY`。</ResponseField>
    <ResponseField name="candidates[].safetyRatings" type="object[]">对候选结果进行安全评估时返回的安全评级。</ResponseField>
    <ResponseField name="usageMetadata" type="object">输入、输出、推理、工具、缓存和总 Token 用量。</ResponseField>
    <ResponseField name="modelVersion" type="string">生成响应的模型版本。</ResponseField>
    <ResponseField name="responseId" type="string">响应 ID。</ResponseField>
  </Tab>

  <Tab title="多模态理解">
    ## 生成内容

    `POST /v1beta/models/gemini-4-argon:generateContent`

    <div className="kling-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url 'https://www.anyfast.ai/v1beta/models/gemini-4-argon:generateContent?key=YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "contents": [{
            "role": "user",
            "parts": [
              {"text": "概述这个架构，并找出最可能的性能瓶颈。"},
              {
                "fileData": {
                  "mimeType": "image/png",
                  "fileUri": "https://example.com/architecture.png"
                }
              }
            ]
          }]
        }'
      ```
    </div>

    ## 鉴权和请求头

    <ParamField query="key" type="string" required>AnyFast API Key。</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>请求媒体类型。</ParamField>

    ## 请求体

    <ParamField body="contents" type="object[]" required>包含文本和媒体的对话轮次。</ParamField>
    <ParamField body="contents[].role" type="string" default="user">对话角色：`user` 或 `model`。</ParamField>
    <ParamField body="contents[].parts" type="object[]" required>一个或多个文本或媒体片段。</ParamField>
    <ParamField body="contents[].parts[].text" type="string">针对媒体的指令或问题。</ParamField>
    <ParamField body="contents[].parts[].inlineData" type="object">内联图片、音频、视频或文档数据。</ParamField>
    <ParamField body="contents[].parts[].inlineData.mimeType" type="string" required>媒体 MIME 类型，例如 `image/jpeg`、`audio/mpeg`、`video/mp4` 或 `application/pdf`。</ParamField>
    <ParamField body="contents[].parts[].inlineData.data" type="string" required>Base64 编码的媒体数据。</ParamField>
    <ParamField body="contents[].parts[].fileData" type="object">通过 URI 提供的媒体或文档。</ParamField>
    <ParamField body="contents[].parts[].fileData.mimeType" type="string" required>媒体 MIME 类型。</ParamField>
    <ParamField body="contents[].parts[].fileData.fileUri" type="string" required>可访问的媒体或文档 URI。</ParamField>

    ## 成功响应

    <div className="kling-api-example-panel">
      ```json 200 theme={null}
      {
        "candidates": [{
          "content": {
            "parts": [{"text": "该图展示了使用消息队列的工作节点层，数据库连接池最可能成为瓶颈……"}],
            "role": "model"
          },
          "finishReason": "STOP",
          "index": 0
        }],
        "usageMetadata": {
          "promptTokenCount": 846,
          "candidatesTokenCount": 94,
          "totalTokenCount": 940,
          "promptTokensDetails": [
            {"modality": "TEXT", "tokenCount": 18},
            {"modality": "IMAGE", "tokenCount": 828}
          ]
        },
        "modelVersion": "gemini-4-argon",
        "responseId": "response-example-002"
      }
      ```
    </div>

    <ResponseField name="candidates[].content.parts[].text" type="string">对所传媒体的文本分析。</ResponseField>
    <ResponseField name="candidates[].finishReason" type="string">停止生成的原因。</ResponseField>
    <ResponseField name="usageMetadata.promptTokensDetails" type="object[]">按模态统计的输入 Token 数。</ResponseField>
    <ResponseField name="usageMetadata.candidatesTokensDetails" type="object[]">返回时按模态统计的输出 Token 数。</ResponseField>
    <ResponseField name="modelVersion" type="string">生成响应的模型版本。</ResponseField>
    <ResponseField name="responseId" type="string">响应 ID。</ResponseField>
  </Tab>

  <Tab title="结构化输出">
    ## 生成内容

    `POST /v1beta/models/gemini-4-argon:generateContent`

    <div className="kling-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url 'https://www.anyfast.ai/v1beta/models/gemini-4-argon:generateContent?key=YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "contents": [{
            "role": "user",
            "parts": [{"text": "提取服务名、严重级别和建议操作：checkout-api 请求超时，需要立即回滚。"}]
          }],
          "generationConfig": {
            "responseMimeType": "application/json",
            "responseSchema": {
              "type": "object",
              "properties": {
                "service": {"type": "string"},
                "severity": {"type": "string"},
                "action": {"type": "string"}
              },
              "required": ["service", "severity", "action"]
            }
          }
        }'
      ```
    </div>

    ## 鉴权和请求头

    <ParamField query="key" type="string" required>AnyFast API Key。</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>请求媒体类型。</ParamField>

    ## 请求体

    <ParamField body="contents" type="object[]" required>包含抽取或生成指令的对话轮次。</ParamField>
    <ParamField body="contents[].parts[].text" type="string" required>指令和源文本。</ParamField>
    <ParamField body="generationConfig.responseMimeType" type="string" required>JSON 结构化输出使用 `application/json`；单个枚举值使用 `text/x.enum`。</ParamField>
    <ParamField body="generationConfig.responseSchema" type="object" required>约束生成 JSON 的 Schema。请显式定义属性和必填字段。</ParamField>

    ## 成功响应

    <div className="kling-api-example-panel">
      ```json 200 theme={null}
      {
        "candidates": [{
          "content": {
            "parts": [{
              "text": "{\"service\":\"checkout-api\",\"severity\":\"critical\",\"action\":\"rollback\"}"
            }],
            "role": "model"
          },
          "finishReason": "STOP",
          "index": 0
        }],
        "usageMetadata": {
          "promptTokenCount": 27,
          "candidatesTokenCount": 24,
          "totalTokenCount": 51
        },
        "modelVersion": "gemini-4-argon",
        "responseId": "response-example-003"
      }
      ```
    </div>

    <ResponseField name="candidates[].content.parts[].text" type="string">以文本形式返回且符合所请求 Schema 的 JSON。</ResponseField>
    <ResponseField name="candidates[].finishReason" type="string">停止生成的原因。</ResponseField>
    <ResponseField name="usageMetadata" type="object">当前请求的 Token 用量。</ResponseField>
    <ResponseField name="modelVersion" type="string">生成响应的模型版本。</ResponseField>
    <ResponseField name="responseId" type="string">响应 ID。</ResponseField>
  </Tab>

  <Tab title="函数调用">
    ## 生成函数调用

    `POST /v1beta/models/gemini-4-argon:generateContent`

    <div className="kling-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url 'https://www.anyfast.ai/v1beta/models/gemini-4-argon:generateContent?key=YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "contents": [{
            "role": "user",
            "parts": [{"text": "检查 checkout-api 的部署状态。"}]
          }],
          "tools": [{
            "functionDeclarations": [{
              "name": "get_deployment_status",
              "description": "返回指定服务当前的部署状态。",
              "parameters": {
                "type": "object",
                "properties": {"service": {"type": "string"}},
                "required": ["service"]
              }
            }]
          }],
          "toolConfig": {
            "functionCallingConfig": {
              "mode": "ANY",
              "allowedFunctionNames": ["get_deployment_status"]
            }
          }
        }'
      ```
    </div>

    ## 鉴权和请求头

    <ParamField query="key" type="string" required>AnyFast API Key。</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>请求媒体类型。</ParamField>

    ## 请求体

    <ParamField body="contents" type="object[]" required>包含用户请求的对话轮次；后续步骤还应包含之前的模型调用和函数结果。</ParamField>
    <ParamField body="tools[].functionDeclarations" type="object[]" required>提供给模型的函数。</ParamField>
    <ParamField body="tools[].functionDeclarations[].name" type="string" required>函数名称。</ParamField>
    <ParamField body="tools[].functionDeclarations[].description" type="string">说明模型何时以及如何使用函数。</ParamField>
    <ParamField body="tools[].functionDeclarations[].parameters" type="object">函数参数的 JSON Schema。</ParamField>
    <ParamField body="toolConfig.functionCallingConfig.mode" type="string" default="AUTO">`AUTO`、`ANY`、`NONE` 或 `VALIDATED`。</ParamField>
    <ParamField body="toolConfig.functionCallingConfig.allowedFunctionNames" type="string[]">允许模型调用的已声明函数子集。</ParamField>
    <ParamField body="contents[].parts[].functionResponse.name" type="string" required>返回工具结果时对应的函数名称。</ParamField>
    <ParamField body="contents[].parts[].functionResponse.id" type="string">模型返回的调用 ID。</ParamField>
    <ParamField body="contents[].parts[].functionResponse.response" type="object">结构化函数结果。</ParamField>
    <ParamField body="contents[].parts[].thoughtSignature" type="string">模型返回的不透明签名，后续请求必须原样保留。</ParamField>

    ## 函数调用响应

    <div className="kling-api-example-panel">
      ```json 200 theme={null}
      {
        "candidates": [{
          "content": {
            "parts": [{
              "functionCall": {
                "id": "call-example-001",
                "name": "get_deployment_status",
                "args": {"service": "checkout-api"}
              },
              "thoughtSignature": "opaque-signature-placeholder"
            }],
            "role": "model"
          },
          "finishReason": "STOP",
          "index": 0
        }],
        "usageMetadata": {
          "promptTokenCount": 86,
          "candidatesTokenCount": 18,
          "toolUsePromptTokenCount": 64,
          "totalTokenCount": 168
        },
        "modelVersion": "gemini-4-argon",
        "responseId": "response-example-004"
      }
      ```
    </div>

    <ResponseField name="candidates[].content.parts[].functionCall" type="object">模型请求调用的函数。</ResponseField>
    <ResponseField name="candidates[].content.parts[].functionCall.id" type="string">用于关联所返回函数结果的调用 ID。</ResponseField>
    <ResponseField name="candidates[].content.parts[].functionCall.name" type="string">函数名称。</ResponseField>
    <ResponseField name="candidates[].content.parts[].functionCall.args" type="object">模型生成的函数参数。</ResponseField>
    <ResponseField name="candidates[].content.parts[].thoughtSignature" type="string">回传模型轮次时必须保留的不透明签名。</ResponseField>
    <ResponseField name="usageMetadata.toolUsePromptTokenCount" type="integer">返回该指标时，工具上下文使用的 Token 数。</ResponseField>
    <ResponseField name="responseId" type="string">响应 ID。</ResponseField>
  </Tab>

  <Tab title="内置工具">
    ## 生成有依据的内容

    `POST /v1beta/models/gemini-4-argon:generateContent`

    <div className="kling-api-example-panel">
      ```bash cURL theme={null}
      curl --request POST \
        --url 'https://www.anyfast.ai/v1beta/models/gemini-4-argon:generateContent?key=YOUR_API_KEY' \
        --header 'Content-Type: application/json' \
        --data '{
          "contents": [{
            "role": "user",
            "parts": [{"text": "查找最新的 Gemini API 稳定模型，并给出来源。"}]
          }],
          "tools": [{"googleSearch": {}}]
        }'
      ```
    </div>

    ## 鉴权和请求头

    <ParamField query="key" type="string" required>AnyFast API Key。</ParamField>
    <ParamField header="Content-Type" type="string" default="application/json" required>请求媒体类型。</ParamField>

    ## 请求体

    <ParamField body="contents" type="object[]" required>包含工具辅助请求的对话轮次。</ParamField>
    <ParamField body="tools[].googleSearch" type="object">使用实时 Google 搜索结果为响应提供依据。</ParamField>
    <ParamField body="tools[].googleMaps" type="object">使用 Google 地图数据为位置相关回答提供依据。</ParamField>
    <ParamField body="tools[].urlContext" type="object">读取和分析提示词中给出的 URL。</ParamField>
    <ParamField body="tools[].codeExecution" type="object">允许模型执行代码。</ParamField>
    <ParamField body="tools[].computerUse" type="object">允许模型提出 Computer Use 操作。此工具处于预览阶段。</ParamField>
    <ParamField body="tools[].computerUse.environment" type="string">Computer Use 环境，例如 `ENVIRONMENT_BROWSER`。</ParamField>

    ## 依据响应

    <div className="kling-api-example-panel">
      ```json 200 theme={null}
      {
        "candidates": [{
          "content": {
            "parts": [{"text": "Gemini 4 Argon 是最新的稳定版 Flash 模型……"}],
            "role": "model"
          },
          "finishReason": "STOP",
          "groundingMetadata": {
            "webSearchQueries": ["latest stable Gemini API model"],
            "searchEntryPoint": {
              "renderedContent": "<style>...</style><div>...</div>"
            },
            "groundingChunks": [{
              "web": {
                "uri": "https://ai.google.dev/gemini-api/docs/models",
                "title": "Gemini models"
              }
            }],
            "groundingSupports": [{
              "segment": {"startIndex": 0, "endIndex": 56, "text": "Gemini 4 Argon 是最新的稳定版 Flash 模型"},
              "groundingChunkIndices": [0]
            }]
          }
        }],
        "usageMetadata": {
          "promptTokenCount": 15,
          "candidatesTokenCount": 58,
          "toolUsePromptTokenCount": 43,
          "totalTokenCount": 116
        },
        "modelVersion": "gemini-4-argon",
        "responseId": "response-example-005"
      }
      ```
    </div>

    <ResponseField name="candidates[].content.parts" type="object[]">文本、可执行代码、代码结果或其他返回片段。</ResponseField>
    <ResponseField name="candidates[].groundingMetadata.webSearchQueries" type="string[]">返回依据元数据时，为检索发起的搜索查询。</ResponseField>
    <ResponseField name="candidates[].groundingMetadata.searchEntryPoint.renderedContent" type="string">返回时，由 Google 提供的搜索建议界面 HTML 和 CSS。</ResponseField>
    <ResponseField name="candidates[].groundingMetadata.groundingChunks" type="object[]">响应返回的网页或地图来源。</ResponseField>
    <ResponseField name="candidates[].groundingMetadata.groundingSupports" type="object[]">返回时，建立生成文本片段与依据来源的对应关系。</ResponseField>
    <ResponseField name="candidates[].content.parts[].executableCode" type="object">启用 `codeExecution` 且模型选择执行代码时返回的代码。</ResponseField>
    <ResponseField name="candidates[].content.parts[].codeExecutionResult" type="object">代码执行后返回的执行状态和输出。</ResponseField>
    <ResponseField name="usageMetadata.toolUsePromptTokenCount" type="integer">返回该指标时，工具上下文使用的 Token 数。</ResponseField>
    <ResponseField name="responseId" type="string">响应 ID。</ResponseField>
  </Tab>
</Tabs>

## 通用可选请求字段

<ParamField body="systemInstruction" type="object">仅包含文本的系统指令，内部使用 `parts` 数组。</ParamField>
<ParamField body="generationConfig.stopSequences" type="string[]">遇到后停止生成的字符串，最多五个。</ParamField>
<ParamField body="safetySettings" type="object[]">按危害类别设置的安全阈值。</ParamField>
<ParamField body="safetySettings[].category" type="string">支持的类别，例如 `HARM_CATEGORY_HATE_SPEECH` 或 `HARM_CATEGORY_DANGEROUS_CONTENT`。</ParamField>
<ParamField body="safetySettings[].threshold" type="string">拦截阈值，例如 `BLOCK_MEDIUM_AND_ABOVE`、`BLOCK_ONLY_HIGH` 或 `BLOCK_NONE`。</ParamField>

## 错误响应

<ResponseField name="error.code" type="integer">与 HTTP 状态兼容的错误码。</ResponseField>
<ResponseField name="error.message" type="string">可读的错误说明。</ResponseField>
<ResponseField name="error.status" type="string">规范化错误状态。</ResponseField>

<Info>
  `400` 通常表示最后一个对话轮次无效、思考等级或工具不受支持，或者函数响应不完整；`401` 表示 API Key 无效；`429` 表示触发限流。
</Info>

<script src="/public/feedback.js" />


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.