> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# Gemini ネイティブ

POST https://direct.beatapi.io/v1beta/models/{model}:generateContent
Content-Type: application/json

1 つの BeatAPI キーで、Gemini generateContent リクエストから Gemini 4 Argon、Gemini 3.8 Flash、Gemini 3.1 Pro を呼び出せます。- `POST /v1beta/models/{model}:generateContent` で、現行の Gemini モデルすべてを呼び出せます。ストリーミングは `:streamGenerateContent?alt=sse` を使います。
- テキストと画像の入力、テキスト出力、ストリーミング、関数呼び出し、思考に対応しています。
- キーは `x-goog-api-key` ヘッダー、または Bearer トークンで送ります。
- モデル ID は URL に入れ、リクエストボディには入れません。テキストリクエストの base URL には `https://direct.beatapi.io` を推奨します。Cloudflare の 100 秒制限を受けないため、長時間のノンストリーミングリクエストが途中で切れません。`https://api.beatapi.io` も使え、ネットワークから `direct.beatapi.io` に届かない場合の代替になります。キー、モデル、価格はどちらも同じです。画像・動画 API は `https://api.beatapi.io` のみを使います。POST/v1beta/models/{model}:generateContent試してみるこのエンドポイントをテスト画面で開きます。BeatAPI の API キーを入力して送信してください。実際に呼び出され、ご自身の残高から課金されます。## モデル次の ID のいずれかを、URL の `{model}` の位置に入れます。| モデル ID                   | コンテキスト（トークン） | 最大出力（トークン） | 位置づけ                                                          | 入力、USD / 100 万トークン | 出力、USD / 100 万トークン |
| ------------------------ | ------------ | ---------- | ------------------------------------------------------------- | ------------------ | ------------------ |
| `gemini-4-argon`         | —            | 1,000,000  | Google Gemini 4 のフラッグシップモデル。最大 100 万トークンの出力に対応                | \$1.00             | \$5.00             |
| `gemini-3.8-flash`       | —            | —          | Google で最も高性能な Flash モデル。長時間のソフトウェア開発、自律型エージェント、複雑な企業ワークフロー向け | \$0.375            | \$1.875            |
| `gemini-3.1-pro-preview` | 1,048,576    | 65,536     | 推論を重視した Gemini プレビュー。エージェントによるコーディングと複雑な問題解決向け                | \$1.00             | \$6.00             |- 価格は基本ティアで、割引適用後です。長文コンテキストのティア、キャッシュ入力価格、キャッシュ書き込み価格はこの表に含まれません。[価格表](https://beatapi.io/pricing)を参照してください。
- `—` はカタログが数値を公開していないことを示します。このファミリーの旧 ID は引き続き使え、[旧モデル](/text-api/legacy-models)にまとめています。## クイックスタートキーは `BEATAPI_API_KEY` に置き、ブラウザーのコードには入れないでください。モデル ID は URL に入るため、ボディに `model` フィールドはありません。以下はリクエスト例であり、実際のモデル出力の記録ではありません。回答は `candidates[0].content.parts[0].text` から読み取り、続けて `candidates[0].finishReason` と `usageMetadata` を確認します。HTTP 200 だけでは回答がタスクを満たす証拠にならないため、内容はアプリケーション側で検証してください。テキストリクエストは直接結果を返すので、`/v1/tasks` をポーリングする必要はありません。```bash title="cURL"
curl --request POST \
  --url https://direct.beatapi.io/v1beta/models/gemini-3.8-flash:generateContent \
  --header "x-goog-api-key: $BEATAPI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Design a resilient webhook retry strategy for a payments API."
        }
      ]
    }
  ]
}'
``````python title="Python"
import os
import requests

response = requests.post(
    "https://direct.beatapi.io/v1beta/models/gemini-3.8-flash:generateContent",
    headers={"x-goog-api-key": os.environ["BEATAPI_API_KEY"]},
    json={
      "contents": [
        {
          "role": "user",
          "parts": [
            {
              "text": "Design a resilient webhook retry strategy for a payments API."
            }
          ]
        }
      ]
    },
    timeout=120,
)
response.raise_for_status()
print(response.json()["candidates"][0]["content"]["parts"][0]["text"])
``````javascript title="JavaScript"
const response = await fetch("https://direct.beatapi.io/v1beta/models/gemini-3.8-flash:generateContent", {
  method: "POST",
  headers: {
    "x-goog-api-key": process.env.BEATAPI_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "Design a resilient webhook retry strategy for a payments API."
          }
        ]
      }
    ]
  }),
});
if (!response.ok) throw new Error(await response.text());
const data = await response.json();
console.log(data.candidates[0].content.parts[0].text);
```## エンドポイントと認証`POST https://direct.beatapi.io/v1beta/models/{model}:generateContent`x-goog-api-key
string
必須BeatAPI のキーを `x-goog-api-key` ヘッダーで送ります。`Authorization: Bearer <BEATAPI_API_KEY>` も使えます。ストリーミングは `POST /v1beta/models/{model}:streamGenerateContent?alt=sse` を呼びます。キーは `x-goog-api-key` ヘッダー、または `Authorization: Bearer <key>` で送ります。どちらでも動きます。`:countTokens` は使えず、`404` が返ります。## リクエストパラメーター以上が有効なフィールドです。それ以外の Gemini フィールドはリクエストに含めても受け付けられますが、効果はありません：`generationConfig.thinkingConfig`、`generationConfig.responseMimeType`、`generationConfig.responseSchema`、`generationConfig.seed`、`safetySettings`、`toolConfig`、`cachedContent`。これらに頼らないでください。contents
object[]
必須会話の内容で、古いターンから順に並べます。各項目は `role`（`user` または `model`）と `parts` を持ちます。part は `text`、`inlineData`（`mimeType` と base64 の `data`）、`fileData`（`mimeType` と `fileUri`）、`functionCall`、`functionResponse` のいずれかです。- 現行の Gemini モデルはすべて画像入力に対応しています。`inlineData` か、画像 URL を持つ `fileData` を使ってください。それ以外のメディアは、ファイル形式を先にテストしてから使ってください。
- `contents` が空または欠けていると `400 bad_request` になります。**例**```json
[
  {
    "role": "user",
    "parts": [
      { "text": "What is in this image?" },
      { "inlineData": { "mimeType": "image/png", "data": "<base64>" } }
    ]
  }
]
```systemInstruction
object
任意システムプロンプト。`{ "parts": [{ "text": "..." }] }` の形で渡します。使われるのは `text` の part だけです。**例**```json
{
  "parts": [{ "text": "Answer in one short paragraph." }]
}
```generationConfig
object
任意生成オプション。次のサブフィールドが有効です：`maxOutputTokens`、`temperature`、`topP`、`topK`、`stopSequences`、`candidateCount`。**例**```json
{
  "temperature": 0.7,
  "topP": 0.95,
  "maxOutputTokens": 2048,
  "stopSequences": ["END"]
}
```generationConfig.maxOutputTokens
integer
任意生成するトークン数の上限。思考も含みます。- 受け付ける最大値は 1,073,741,823 で、これを超えると `400 bad_request` です。上の表にあるモデルの最大出力以下にしてください。
- Gemini モデルは既定で思考し、思考トークンは出力として課金され、この上限に含まれます。値が小さいと思考で使い切られ、回答が空のまま `finishReason` が `"MAX_TOKENS"` になります。短い回答でも、少なくとも 1,000 トークンは確保してください。
- `maxOutputTokens` はリクエストに必要な残高の見積もりにも使われます。実際の出力が短くても、極端に大きな値は `402 insufficient_credits` で拒否されることがあります。必要な分だけ指定してください。generationConfig.temperature
number
任意サンプリング温度。generationConfig.topP
number
任意ニュークリアスサンプリング。`0` は無視されます。generationConfig.topK
integer
任意Top-K サンプリング。`0` は無視されます。generationConfig.stopSequences
string[]
任意この文字列が出たら生成を止めます。使われるのは最大 4 個までです。generationConfig.candidateCount
integer
任意返す候補の数。複数の候補が必要な場合以外は設定しないでください。tools
object[]
任意モデルが呼び出せる関数宣言。`[{ "functionDeclarations": [...] }]` の形で渡します。各宣言は `name`、`description`、`parameters`（JSON Schema）を持ちます。呼び出しは `functionCall` part として返ります。関数を実行したら、次の `user` ターンで `functionResponse` part として結果を返してください。- 使われるのは `functionDeclarations` だけです。`googleSearch` や `codeExecution` などの組み込みツールは無視されます。**例**```json
[
  {
    "functionDeclarations": [
      {
        "name": "get_weather",
        "description": "Get the current weather for a city.",
        "parameters": {
          "type": "object",
          "properties": { "city": { "type": "string" } },
          "required": ["city"]
        }
      }
    ]
  }
]
```## レスポンスストリーミングなしの呼び出しは JSON オブジェクトを 1 つ返します。以下は省略した例です。```json
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "Retry with exponential backoff and jitter, and make every handler idempotent."
          }
        ]
      },
      "finishReason": "STOP",
      "index": 0
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 19,
    "candidatesTokenCount": 16,
    "totalTokenCount": 120,
    "thoughtsTokenCount": 85
  }
}
```### レスポンスのフィールド| フィールド                                       | 型         | 説明                                                                                                 |
| ------------------------------------------- | --------- | -------------------------------------------------------------------------------------------------- |
| `candidates[].content.parts[].text`         | `string`  | 回答テキスト。                                                                                            |
| `candidates[].content.parts[].functionCall` | `object`  | ツール呼び出し。`name` と `args` を持ちます。                                                                     |
| `candidates[].finishReason`                 | `string`  | `STOP` は回答が完結した、またはツールを呼んだこと、`MAX_TOKENS` は `maxOutputTokens` に達したこと、`SAFETY` は回答がフィルターされたことを示します。 |
| `usageMetadata.promptTokenCount`            | `integer` | 入力トークン数。                                                                                           |
| `usageMetadata.candidatesTokenCount`        | `integer` | 表示される回答の出力トークン数。                                                                                   |
| `usageMetadata.thoughtsTokenCount`          | `integer` | 思考トークン数。出力として課金されます。思考テキスト自体は返りません。                                                                |
| `usageMetadata.totalTokenCount`             | `integer` | この呼び出しの全トークン数。                                                                                     |## ストリーミング`:streamGenerateContent?alt=sse` を呼びます。各イベントは `data: {...}` の 1 行で、中身は `candidates` オブジェクトです。形はストリーミングなしの回答と同じです。- 最後のイベントに `finishReason`（例：`"STOP"`）が入ります。
- レスポンスは `text/event-stream` です。モデルを呼ぶ前に起きた失敗は、ストリームイベントではなく、HTTP ステータス付きの通常の JSON エラーで返されます。
- 明示的なタイムアウトを設定し、ストリーミングレスポンスを安全に再接続してください。```text
data: {"candidates":[{"content":{"role":"model","parts":[{"text":"Retry"}]},"index":0}]}

data: {"candidates":[{"content":{"role":"model","parts":[{"text":" with backoff"}]},"finishReason":"STOP","index":0}],"usageMetadata":{"promptTokenCount":19,"candidatesTokenCount":16,"totalTokenCount":120,"thoughtsTokenCount":85}}
```## エラー| エラーまたは症状                                           | 原因                                                          | 対処                                                                  |
| -------------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------- |
| `400`：`contents` が必要                               | `contents` が空または欠けています。                                     | `contents` に少なくとも 1 ターン入れてください。                                     |
| `400`：`maxOutputTokens` が無効                        | `generationConfig.maxOutputTokens` が 1,073,741,823 を超えています。 | 必要な値まで下げてください。                                                      |
| `402 insufficient_credits`                         | 残高がリクエストの価格を下回っています。`maxOutputTokens` が非常に大きいことが多い原因です。     | チャージするか、`maxOutputTokens` を下げてください。                                 |
| `403 forbidden`                                    | アカウントが無料クレジットで、モデルが無料リストにない、またはモデルがキーのグループの範囲外です。           | チャージする、無料モデルを使う、またはグループがそのモデルに届くキーを使ってください。                         |
| `404 not_found`                                    | モデル ID が存在しない、このキーで有効になっていない、または `:countTokens` を呼びました。     | `GET /v1/models` で有効なモデルを確認してください。                                  |
| `429 rate_limit_exceeded`                          | アカウントまたは無料モデルの上限に達しました。                                     | `Retry-After` だけ待ってから再試行してください。                                     |
| `200` だが `finishReason: "MAX_TOKENS"` で `text` がない | 回答を書く前に、思考が `maxOutputTokens` を使い切りました。                     | `generationConfig.maxOutputTokens` を上げてください。短い回答でも 1,000 以上を目安にします。 |### HTTP エラー早見表Gemini ネイティブのエンドポイントのエラーは `{"error": {"message", "type": "beatapi_error", "code"}}` の 1 形式だけで、コードは `error.code`、request id は `message` の末尾にあり、`retryable` はありません。詳しくは[エラー](/errors#text-endpoints)を参照してください。| HTTP ステータス | エラーコード                                                   | 対応                                                             |
| ---------- | -------------------------------------------------------- | -------------------------------------------------------------- |
| 400        | `bad_request`、`content_policy_violation`                 | リクエストか入力を直してください。そのまま再送しないでください。                               |
| 401        | `missing_api_key`、`invalid_api_key`                      | キーを確認してください。再試行しないでください。                                       |
| 402        | `insufficient_credits`                                   | チャージするか、キーの上限を上げてください。`max_tokens` が非常に大きい場合も発生します。            |
| 403        | `forbidden`                                              | モデルがキーのグループまたは IP 許可リストの範囲外、または無料クレジットでは呼べないモデルです。             |
| 404        | `not_found`                                              | モデルが存在しません。`GET /v1/models` で有効なモデルを確認してください。                  |
| 429        | `rate_limit_exceeded`                                    | `Retry-After` または `retry_after_seconds` だけ待ち、バックオフして再試行してください。 |
| 500        | `internal_error`、`temporary_error`                       | バックオフして 1～2 回再試行してください。                                        |
| 503        | `model_unavailable`、`upstream_timeout`、`temporary_error` | バックオフして再試行するか、別のモデルを使ってください。                                   |全エラーコード表と再試行ポリシーは[エラー](/errors#text-endpoints)を参照してください。## 注意事項- Gemini モデルは Chat Completions、Responses、Anthropic Messages でも呼び出せます。Gemini のほかのページを参照してください。
- 思考トークンは出力トークンとして課金されます。回答だけでなく、思考と回答の両方に足りる出力枠を確保してください。
- キーは信頼できるサーバーだけに置き、レスポンスのリクエスト ID を記録し、再試行は `429`、`500`、`503` に限ってください。

Reference: https://docs.beatapi.io/api-reference/text-api/gemini-native

## Authentication

- `Authorization` header (bearer token, required) — Send your API key as `Authorization: Bearer <BEATAPI_API_KEY>`.

## Servers

- `https://direct.beatapi.io` (Direct, default)
- `https://api.beatapi.io` (API)

## Request

### Path parameters

- `model` (enum, required)
  - Allowed values: `gemini-4-argon`, `gemini-3.8-flash`, `gemini-3.1-pro-preview`

### Body (application/json)

This endpoint expects an object.

- `contents` (list of V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaContentsItems, required) — 会話の内容で、古いターンから順に並べます。各項目は `role`（`user` または `model`）と `parts` を持ちます。part は `text`、`inlineData`（`mimeType` と base64 の `data`）、`fileData`（`mimeType` と `fileUri`）、`functionCall`、`functionResponse` のいずれかです。 現行の Gemini モデルはすべて画像入力に対応しています。`inlineData` か、画像 URL を持つ `fileData` を使ってください。それ以外のメディアは、ファイル形式を先にテストしてから使ってください。 `contents` が空または欠けていると `400 bad_request` になります。
- `systemInstruction` (V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaSystemInstruction, optional) — システムプロンプト。`{ "parts": [{ "text": "..." }] }` の形で渡します。使われるのは `text` の part だけです。
- `generationConfig` (V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaGenerationConfig, optional) — 生成オプション。次のサブフィールドが有効です：`maxOutputTokens`、`temperature`、`topP`、`topK`、`stopSequences`、`candidateCount`。
- `tools` (list of V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaToolsItems, optional) — モデルが呼び出せる関数宣言。`[{ "functionDeclarations": [...] }]` の形で渡します。各宣言は `name`、`description`、`parameters`（JSON Schema）を持ちます。呼び出しは `functionCall` part として返ります。関数を実行したら、次の `user` ターンで `functionResponse` part として結果を返してください。 使われるのは `functionDeclarations` だけです。`googleSearch` や `codeExecution` などの組み込みツールは無視されます。

## Response

### 200

ストリーミングなしの呼び出しは JSON オブジェクトを 1 つ返します。以下は省略した例です。

- `candidates` (list of V1BetaModelsModelGenerateContentPostResponsesContentApplicationJsonSchemaCandidatesItems, optional)
- `usageMetadata` (V1BetaModelsModelGenerateContentPostResponsesContentApplicationJsonSchemaUsageMetadata, optional)

## Errors

### 400 Bad Request Error

`bad_request`、`content_policy_violation` リクエストか入力を直してください。そのまま再送しないでください。 Gemini ネイティブのエンドポイントのエラーは `{"error": {"message", "type": "beatapi_error", "code"}}` の 1 形式だけで、コードは `error.code`、request id は `message` の末尾にあり、`retryable` はありません。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 401 Unauthorized Error

`missing_api_key`、`invalid_api_key` キーを確認してください。再試行しないでください。 Gemini ネイティブのエンドポイントのエラーは `{"error": {"message", "type": "beatapi_error", "code"}}` の 1 形式だけで、コードは `error.code`、request id は `message` の末尾にあり、`retryable` はありません。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 402 Payment Required Error

`insufficient_credits` チャージするか、キーの上限を上げてください。`max_tokens` が非常に大きい場合も発生します。 Gemini ネイティブのエンドポイントのエラーは `{"error": {"message", "type": "beatapi_error", "code"}}` の 1 形式だけで、コードは `error.code`、request id は `message` の末尾にあり、`retryable` はありません。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 403 Forbidden Error

`forbidden` モデルがキーのグループまたは IP 許可リストの範囲外、または無料クレジットでは呼べないモデルです。 Gemini ネイティブのエンドポイントのエラーは `{"error": {"message", "type": "beatapi_error", "code"}}` の 1 形式だけで、コードは `error.code`、request id は `message` の末尾にあり、`retryable` はありません。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 404 Not Found Error

`not_found` モデルが存在しません。`GET /v1/models` で有効なモデルを確認してください。 Gemini ネイティブのエンドポイントのエラーは `{"error": {"message", "type": "beatapi_error", "code"}}` の 1 形式だけで、コードは `error.code`、request id は `message` の末尾にあり、`retryable` はありません。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 429 Too Many Requests Error

`rate_limit_exceeded` `Retry-After` または `retry_after_seconds` だけ待ち、バックオフして再試行してください。 Gemini ネイティブのエンドポイントのエラーは `{"error": {"message", "type": "beatapi_error", "code"}}` の 1 形式だけで、コードは `error.code`、request id は `message` の末尾にあり、`retryable` はありません。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 500 Internal Server Error

`internal_error`、`temporary_error` バックオフして 1～2 回再試行してください。 Gemini ネイティブのエンドポイントのエラーは `{"error": {"message", "type": "beatapi_error", "code"}}` の 1 形式だけで、コードは `error.code`、request id は `message` の末尾にあり、`retryable` はありません。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

### 503 Service Unavailable Error

`model_unavailable`、`upstream_timeout`、`temporary_error` バックオフして再試行するか、別のモデルを使ってください。 Gemini ネイティブのエンドポイントのエラーは `{"error": {"message", "type": "beatapi_error", "code"}}` の 1 形式だけで、コードは `error.code`、request id は `message` の末尾にあり、`retryable` はありません。詳しくは[エラー](/errors#text-endpoints)を参照してください。

- `map from string to any`

## Types

### V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaContentsItems

- `parts` (list of V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaContentsItemsPartsItems, required)
- `role` (string, optional)

### V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaSystemInstruction

システムプロンプト。`{ "parts": [{ "text": "..." }] }` の形で渡します。使われるのは `text` の part だけです。

### V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaGenerationConfig

生成オプション。次のサブフィールドが有効です：`maxOutputTokens`、`temperature`、`topP`、`topK`、`stopSequences`、`candidateCount`。

- `maxOutputTokens` (integer, optional) — 生成するトークン数の上限。思考も含みます。 受け付ける最大値は 1,073,741,823 で、これを超えると `400 bad_request` です。上の表にあるモデルの最大出力以下にしてください。 Gemini モデルは既定で思考し、思考トークンは出力として課金され、この上限に含まれます。値が小さいと思考で使い切られ、回答が空のまま `finishReason` が `"MAX_TOKENS"` になります。短い回答でも、少なくとも 1,000 トークンは確保してください。 `maxOutputTokens` はリクエストに必要な残高の見積もりにも使われます。実際の出力が短くても、極端に大きな値は `402 insufficient_credits` で拒否されることがあります。必要な分だけ指定してください。
- `temperature` (double, optional) — サンプリング温度。
- `topP` (double, optional) — ニュークリアスサンプリング。`0` は無視されます。
- `topK` (integer, optional) — Top-K サンプリング。`0` は無視されます。
- `stopSequences` (list of string, optional) — この文字列が出たら生成を止めます。使われるのは最大 4 個までです。
- `candidateCount` (integer, optional) — 返す候補の数。複数の候補が必要な場合以外は設定しないでください。

### V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaToolsItems

### V1BetaModelsModelGenerateContentPostResponsesContentApplicationJsonSchemaCandidatesItems

- `content` (V1BetaModelsModelGenerateContentPostResponsesContentApplicationJsonSchemaCandidatesItemsContent, optional)
- `finishReason` (string, optional) — `STOP` は回答が完結した、またはツールを呼んだこと、`MAX_TOKENS` は `maxOutputTokens` に達したこと、`SAFETY` は回答がフィルターされたことを示します。

### V1BetaModelsModelGenerateContentPostResponsesContentApplicationJsonSchemaUsageMetadata

- `promptTokenCount` (integer, optional) — 入力トークン数。
- `candidatesTokenCount` (integer, optional) — 表示される回答の出力トークン数。
- `thoughtsTokenCount` (integer, optional) — 思考トークン数。出力として課金されます。思考テキスト自体は返りません。
- `totalTokenCount` (integer, optional) — この呼び出しの全トークン数。

### V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaContentsItemsPartsItems

- `text` (string, optional)
- `inlineData` (V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaContentsItemsPartsItemsInlineData, optional)
- `fileData` (V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaContentsItemsPartsItemsFileData, optional)
- `functionCall` (V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaContentsItemsPartsItemsFunctionCall, optional)
- `functionResponse` (V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaContentsItemsPartsItemsFunctionResponse, optional)

### V1BetaModelsModelGenerateContentPostResponsesContentApplicationJsonSchemaCandidatesItemsContent

- `parts` (list of V1BetaModelsModelGenerateContentPostResponsesContentApplicationJsonSchemaCandidatesItemsContentPartsItems, optional)

### V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaContentsItemsPartsItemsInlineData

- `mimeType` (string, optional)
- `data` (string, optional)

### V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaContentsItemsPartsItemsFileData

- `mimeType` (string, optional)
- `fileUri` (string, optional)

### V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaContentsItemsPartsItemsFunctionCall

### V1BetaModelsModelGenerateContentPostRequestBodyContentApplicationJsonSchemaContentsItemsPartsItemsFunctionResponse

### V1BetaModelsModelGenerateContentPostResponsesContentApplicationJsonSchemaCandidatesItemsContentPartsItems

- `text` (string, optional) — 回答テキスト。
- `functionCall` (V1BetaModelsModelGenerateContentPostResponsesContentApplicationJsonSchemaCandidatesItemsContentPartsItemsFunctionCall, optional) — ツール呼び出し。`name` と `args` を持ちます。

### V1BetaModelsModelGenerateContentPostResponsesContentApplicationJsonSchemaCandidatesItemsContentPartsItemsFunctionCall

ツール呼び出し。`name` と `args` を持ちます。

## Examples

**Request**

```json
{
  "contents": [
    {
      "parts": [
        {
          "text": "Design a resilient webhook retry strategy for a payments API."
        }
      ],
      "role": "user"
    }
  ]
}
```

**Response**

```json
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "Retry with exponential backoff and jitter, and make every handler idempotent."
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP",
      "index": 0
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 19,
    "candidatesTokenCount": 16,
    "thoughtsTokenCount": 85,
    "totalTokenCount": 120
  }
}
```

**SDK Code**

```python クイックスタート
import requests

url = "https://direct.beatapi.io/v1beta/models/gemini-3.8-flash:generateContent"

payload = { "contents": [
        {
            "parts": [{ "text": "Design a resilient webhook retry strategy for a payments API." }],
            "role": "user"
        }
    ] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript クイックスタート
const url = 'https://direct.beatapi.io/v1beta/models/gemini-3.8-flash:generateContent';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"contents":[{"parts":[{"text":"Design a resilient webhook retry strategy for a payments API."}],"role":"user"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go クイックスタート
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://direct.beatapi.io/v1beta/models/gemini-3.8-flash:generateContent"

	payload := strings.NewReader("{\n  \"contents\": [\n    {\n      \"parts\": [\n        {\n          \"text\": \"Design a resilient webhook retry strategy for a payments API.\"\n        }\n      ],\n      \"role\": \"user\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby クイックスタート
require 'uri'
require 'net/http'

url = URI("https://direct.beatapi.io/v1beta/models/gemini-3.8-flash:generateContent")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"contents\": [\n    {\n      \"parts\": [\n        {\n          \"text\": \"Design a resilient webhook retry strategy for a payments API.\"\n        }\n      ],\n      \"role\": \"user\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java クイックスタート
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://direct.beatapi.io/v1beta/models/gemini-3.8-flash:generateContent")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"contents\": [\n    {\n      \"parts\": [\n        {\n          \"text\": \"Design a resilient webhook retry strategy for a payments API.\"\n        }\n      ],\n      \"role\": \"user\"\n    }\n  ]\n}")
  .asString();
```

```php クイックスタート
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://direct.beatapi.io/v1beta/models/gemini-3.8-flash:generateContent', [
  'body' => '{
  "contents": [
    {
      "parts": [
        {
          "text": "Design a resilient webhook retry strategy for a payments API."
        }
      ],
      "role": "user"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp クイックスタート
using RestSharp;

var client = new RestClient("https://direct.beatapi.io/v1beta/models/gemini-3.8-flash:generateContent");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"contents\": [\n    {\n      \"parts\": [\n        {\n          \"text\": \"Design a resilient webhook retry strategy for a payments API.\"\n        }\n      ],\n      \"role\": \"user\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift クイックスタート
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["contents": [
    [
      "parts": [["text": "Design a resilient webhook retry strategy for a payments API."]],
      "role": "user"
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://direct.beatapi.io/v1beta/models/gemini-3.8-flash:generateContent")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```