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

# Gemini の基本的なチャットの例

> `generateContent` を使用した基本的な Gemini チャットの例。

## 推奨エンドポイント

* [ジェミニ /v1beta/models/{model}:generateContent](/ja/api-reference/endpoints/gemini/text)

## 最低限のお願い

```json theme={null}
{
  "model": "gemini-2.5-flash",
  "systemInstruction": {
    "parts": [{ "text": "You are a concise assistant." }]
  },
  "contents": [
    {
      "role": "user",
      "parts": [{ "text": "Summarize ApiGo in three sentences." }]
    }
  ]
}
```

## cURLの例

```bash theme={null}
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "systemInstruction": {
      "parts": [{ "text": "You are a concise assistant." }]
    },
    "contents": [
      {
        "role": "user",
        "parts": [{ "text": "Summarize ApiGo in three sentences." }]
      }
    ]
  }'
```

## Python の例

```python theme={null}
from google import genai
from google.genai import types

client = genai.Client(api_key="<GEMINI_API_KEY>")

response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="Summarize ApiGo in three sentences.",
    config=types.GenerateContentConfig(
        system_instruction="You are a concise assistant."
    ),
)

print(response.text)
```

## Node.js の例

```js theme={null}
import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

const response = await ai.models.generateContent({
  model: "gemini-2.5-flash",
  contents: "Summarize ApiGo in three sentences.",
  config: {
    systemInstruction: "You are a concise assistant."
  }
});

console.log(response.text);
```

## ベストプラクティス

* 低遅延チャットのために Flash モデルから始める
* `parts` モデルを変更しないで、後から再設計せずにメディアを追加できるようにします。
* 追加の推論コストが必要ない場合は、Gemini 2.5 フラッシュで `thinkingBudget` を `0` に設定します。
