Gemini 呼び出し方法
Geminiシリーズでは、ネイティブ呼び出しとOpenAI互換の2種類の呼び出し方法を提供しています。 使用する前に、pip install google-genaiまたはpip install -U google-genaiを実行して、ネイティブの依存関係をインストール(更新)してください。
1️⃣ ネイティブ呼び出しの場合、主にAiHubMixキーとリクエストリンクを内部に渡します。このリンクは通常のbase_urlの書き方とは異なることに注意してください。例を参照してください。
client = genai.Client(
api_key="sk-***", # 🔑 AiHubMixで生成したキーに置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"},
)
v1エンドポイントを維持します。
client = OpenAI(
api_key="sk-***", # AiHubMixで生成したキーに置き換えてください
base_url="https://aihubmix.com/v1",
)
- ネイティブ呼び出し:
include_thoughts=Trueを渡す - OpenAI互換方式:
reasoning_effortを渡す
Gemini 2.5 シリーズの「推論」の説明
- 2.5シリーズはすべて推論モデルです。
- 2.5 Flashはハイブリッドモデルで、Claude Sonnet 3.7に似ており、
thinking_budgetを使用して推論予算を制御することで最適な効果を得ることができます。 - 2.5 Proは純粋な推論モデルであるため、思考をオフにしたり、推論予算を明示的に渡したりすることはできません。
from google import genai
from google.genai import types
def generate():
client = genai.Client(
api_key="sk-***", # 🔑 AiHubMixで生成したキーに置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"},
)
model = "gemini-2.0-flash"
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text="""For the average stock investor, if analyzing financial reports works, why is luck still needed?"""),
],
),
]
print(client.models.generate_content(
model=model,
contents=contents,
))
if __name__ == "__main__":
generate()
from google import genai
from google.genai import types
def generate():
client = genai.Client(
api_key="sk-***", # 🔑 AiHubMixで生成したキーに置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"},
)
model = "gemini-2.0-flash"
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text="""For the average stock investor, if analyzing financial reports works, why is luck still needed?"""),
],
),
]
generate_content_config = types.GenerateContentConfig(
response_mime_type="text/plain",
)
for chunk in client.models.generate_content_stream(
model=model,
contents=contents,
config=generate_content_config,
):
print(chunk.text, end="")
if __name__ == "__main__":
generate()
from google import genai
from google.genai import types
def generate():
client = genai.Client(
api_key="sk-***", # 🔑 AiHubMixで生成したキーに置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"},
)
model = "gemini-2.5-flash-preview-04-17" #gemini-2.5-pro-preview-03-25、gemini-2.5-flash-preview-04-17
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text="""For the average stock investor, if analyzing financial reports works, why is luck still needed?"""),
],
),
]
generate_content_config = types.GenerateContentConfig(
thinking_config = types.ThinkingConfig(
thinking_budget=2048, #範囲 0-16384。デフォルト 1024、最適な限界効果 16000
),
response_mime_type="text/plain",
)
for chunk in client.models.generate_content_stream(
model=model,
contents=contents,
config=generate_content_config,
):
print(chunk.text, end="")
if __name__ == "__main__":
generate()
from google import genai
from google.genai import types
def generate():
client = genai.Client(
api_key="sk-***", # 🔑 AiHubMixで生成したキーに置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"},
)
model = "gemini-2.5-pro-preview-03-25"
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text="""How do I know I'm not just wasting my time?"""),
],
),
]
generate_content_config = types.GenerateContentConfig(
response_mime_type="text/plain",
)
for chunk in client.models.generate_content_stream(
model=model,
contents=contents,
config=generate_content_config,
):
print(chunk.text, end="")
if __name__ == "__main__":
generate()
from google import genai
from google.genai import types
def generate():
client = genai.Client(
api_key="sk-***", # 🔑 AiHubMixで生成したキーに置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"},
)
model = "gemini-2.5-pro-preview-05-06"
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text="""How is the Rule of 72 in finance derived?"""),
],
),
]
generate_content_config = types.GenerateContentConfig(
response_mime_type="text/plain",
thinking_config=types.ThinkingConfig(
include_thoughts=True # 🧠 思考プロセスの出力を有効にする
),
)
# 最後のチャンクのusage_metadataを保存するための変数
final_usage_metadata = None
for chunk in client.models.generate_content_stream(
model=model,
contents=contents,
config=generate_content_config,
):
# コンテンツ部分があるか確認
if chunk.candidates and len(chunk.candidates) > 0:
for part in chunk.candidates[0].content.parts:
if part.text:
if part.thought:
# 思考プロセスコンテンツ
print(part.text, end="")
else:
# 最終回答コンテンツ
print(part.text, end="")
# 最新のusage_metadataを保存。最後のチャンクのみ完全な情報を含む
if chunk.usage_metadata:
final_usage_metadata = chunk.usage_metadata
# すべてのチャンクの処理が完了した後、完全なトークン使用状況を出力
if final_usage_metadata:
print(f"\n\n📊 トークン使用状況:")
print(f"思考トークン: {getattr(final_usage_metadata, 'thoughts_token_count', '利用不可')}")
print(f"出力トークン: {getattr(final_usage_metadata, 'candidates_token_count', '利用不可')}")
print(f"合計: {final_usage_metadata}")
if __name__ == "__main__":
generate()
Gemini 2.5 Flash サポート
OpenAI互換方式の呼び出しは以下の通りです。from openai import OpenAI
client = OpenAI(
api_key="sk-***", # AiHubMixで生成したキーに置き換えてください
base_url="https://aihubmix.com/v1",
)
completion = client.chat.completions.create(
model="gemini-2.5-flash-preview-04-17-nothink",
messages=[
{
"role": "user",
"content": "Explain the Occam's Razor concept and provide everyday examples of it"
}
]
)
print(completion.choices[0].message.content)
from openai import OpenAI
client = OpenAI(
api_key="sk-***", # AiHubMixで生成したキーに置き換えてください
base_url="https://aihubmix.com/v1",
)
completion = client.chat.completions.create(
model="gemini-2.5-flash-preview-04-17",
reasoning_effort="low", # "low", "medium", "high"から選択可能で、それぞれ1K、8K、24Kの思考トークン予算に対応します。思考を無効にしたい場合は、reasoning_effortを"none"に設定できます。
messages=[
{
"role": "user",
"content": "Explain the Occam's Razor concept and provide everyday examples of it"
}
]
)
print(completion.choices[0].message.content)
curl -X POST https://aihubmix.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-***" \
-d '{
"model": "gemini-2.5-flash-preview-04-17-nothink",
"messages": [
{
"role": "user",
"content": "Explain the Occam'\''s Razor concept and provide an everyday example of it."
}
]
}'
curl https://aihubmix.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-***" \
-d '{
"model": "gemini-2.5-pro-preview-05-06",
"messages": [
{
"role": "user",
"content": "Explain the Occam'\''s Razor concept and provide an everyday example of it."
}
],
"reasoning_effort": "low"
}'
- 複雑なタスクの場合、モデルIDをデフォルトで思考が有効になっている
gemini-2.5-flash-preview-04-17に設定するだけで済みます。 - Gemini 2.5 Flashは
budget(思考予算)によって思考の深さを制御します。範囲は0〜16Kで、現在の転送ではデフォルトの予算1024が使用されており、最適な限界効果は16Kです。
マルチメディアファイル
Aihubmixは現在、inline_dataを使用してアップロードされた20MB未満のマルチメディアファイル(画像、音声、ビデオ)のみをサポートしています。
20MBを超えるマルチメディアはFile API(未サポート)を使用する必要があります。upload_urlを返すために、ステータスの追跡が完了するのを待っています。
from google import genai
from google.genai import types
# ファイルをバイナリデータとして読み込む
file_path = "yourpath/file.jpeg"
with open(file_path, "rb") as f:
file_bytes = f.read()
client = genai.Client(
api_key="sk-***", # 🔑 AiHubMixで生成したキーに置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"}
)
response = client.models.generate_content(
model="gemini-2.0-flash",
contents=types.Content(
parts=[
types.Part(
inline_data=types.Blob(
data=file_bytes,
mime_type="image/jpeg"
)
),
types.Part(
text="Describe the image."
)
]
)
)
print(response.text)
from google import genai
from google.genai import types
# ファイルをバイナリデータとして読み込む
file_path = "yourpath/file.m4a"
with open(file_path, "rb") as f:
file_bytes = f.read()
client = genai.Client(
api_key="sk-***", # 🔑 AiHubMixで生成したキーに置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"}
)
response = client.models.generate_content(
model="gemini-2.0-flash",
contents=types.Content(
parts=[
types.Part(
inline_data=types.Blob(
data=file_bytes,
mime_type="audio/m4a"
)
),
types.Part(
text="Transcribe the audio to text."
)
]
)
)
print(response.text)
from google import genai
from google.genai import types
# ファイルをバイナリデータとして読み込む
file_path = "yourpath/file.mp4"
with open(file_path, "rb") as f:
file_bytes = f.read()
client = genai.Client(
api_key="sk-***", # 🔑 AiHubMixで生成したキーに置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"}
)
response = client.models.generate_content(
model="gemini-2.0-flash",
contents=types.Content(
parts=[
types.Part(
inline_data=types.Blob(
data=file_bytes,
mime_type="video/mp4"
)
),
types.Part(
text="Summarize this video. Then create a quiz with an answer key based on the information in this video."
)
]
)
)
print(response.text)
from google import genai
from google.genai import types
client = genai.Client(
api_key="sk-***", # 🔑 AiHubMixで生成したキーに置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"}
)
response = client.models.generate_content(
model="gemini-2.0-flash",
contents=types.Content(
parts=[
types.Part(
file_data=types.FileData(
file_uri="https://www.youtube.com/watch?v=OoU7PwNyYUw"
)
),
types.Part(
text="Please summarize the video in 3 sentences."
)
]
)
)
print(response.text)
コード実行
自動コード解析器のユースケースの例:Python
from google import genai
from google.genai import types
# ファイルをバイナリデータとして読み込む
file_path = "yourpath/file.csv"
with open(file_path, "rb") as f:
file_bytes = f.read()
client = genai.Client(
api_key="sk-***", # 🔑 AiHubMixで生成したキーに置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"}
)
response = client.models.generate_content(
model="gemini-2.0-flash",
contents=types.Content(
parts=[
types.Part(
inline_data=types.Blob(
data=file_bytes,
mime_type="text/csv"
)
),
types.Part(
text="Please analyze this CSV and summarize the key statistics. Use code execution if needed."
)
]
),
config=types.GenerateContentConfig(
tools=[types.Tool(
code_execution=types.ToolCodeExecution
)]
)
)
for part in response.candidates[0].content.parts:
if part.text is not None:
print(part.text)
if getattr(part, "executable_code", None) is not None:
print("生成されたコード:\n", part.executable_code.code)
if getattr(part, "code_execution_result", None) is not None:
print("実行結果:\n", part.code_execution_result.output)
Interactions API
Interactions は Gemini の新世代推論インターフェースで、構造化されたInteraction オブジェクトを返し、テキスト生成、ネイティブ画像生成(Nano Banana)、マルチステップ推論をサポートします。現在は同期モード(interactions.create())をサポートしています。非同期モード(Background Interactions)は近日公開予定です。
SDK バージョン要件:
@google/genai >= 2.0.0(JS/TS)または google-genai >= 2.0.0(Python)。古いバージョンの SDK で Interactions を呼び出すと、Google バックエンドに拒否されます(legacy Interactions schema no longer supported)。テキスト生成
interactions.create() を呼び出して推論を開始します。返される Interaction オブジェクトは output_text 便利プロパティを提供します。
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({
apiKey: "sk-***", // AIHubMix で生成した API Key に置き換えてください
httpOptions: { baseUrl: "https://aihubmix.com/gemini" },
});
const interaction = await ai.interactions.create({
model: "gemini-3.5-flash",
input: "Explain quantum computing in one sentence",
});
console.log(interaction.output_text);
console.log(interaction.usage);
// { total_tokens, total_input_tokens, total_output_tokens, ... }
from google import genai
client = genai.Client(
api_key="sk-***", # AIHubMix で生成した API Key に置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"},
)
interaction = client.interactions.create(
model="gemini-3.5-flash",
input="Explain quantum computing in one sentence",
)
print(interaction.output_text)
ネイティブ画像生成
response_format を設定して出力モダリティを画像に構成します。返される Interaction オブジェクトは output_image 便利プロパティを提供します。
- 推奨モデル
gemini-3.1-flash-image(Nano Banana 2、汎用画像生成モデル)。 response_modalitiesの値は小文字の['text', 'image']でなければなりません。大文字はgenerateContentAPI の書き方であり、Interactions API では400が返されます。delivery: 'inline'を渡さないでください(400 Image delivery mode is not supported)。結果はデフォルトで inline 方式で返されます。
import { GoogleGenAI } from "@google/genai";
import fs from "node:fs";
const ai = new GoogleGenAI({
apiKey: "sk-***", // AIHubMix で生成した API Key に置き換えてください
httpOptions: { baseUrl: "https://aihubmix.com/gemini" },
});
const interaction = await ai.interactions.create({
model: "gemini-3.1-flash-image",
input: "A translucent banana-shaped glass lamp on a white desk, soft studio lighting.",
response_modalities: ["text", "image"],
response_format: { type: "image", aspect_ratio: "1:1", image_size: "1K" },
});
// output_image 便利プロパティ(最後に生成された画像を取得)
if (interaction.output_image?.data) {
fs.writeFileSync("output.png", Buffer.from(interaction.output_image.data, "base64"));
}
import base64
from google import genai
client = genai.Client(
api_key="sk-***", # AIHubMix で生成した API Key に置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"},
)
interaction = client.interactions.create(
model="gemini-3.1-flash-image",
input="A translucent banana-shaped glass lamp on a white desk, soft studio lighting.",
response_format={
"type": "image",
"aspect_ratio": "1:1",
"image_size": "1K",
},
)
if interaction.output_image:
with open("output.png", "wb") as f:
f.write(base64.b64decode(interaction.output_image.data))
ストリーミング出力
stream: true を渡して SSE ストリーミング転送を有効にします。増分テキストは event.delta.text から取得します。
JavaScript
const stream = await ai.interactions.create({
model: "gemini-3.5-flash",
input: "Write a haiku about the moon",
stream: true,
});
for await (const event of stream) {
if (event.event_type === "step.delta" && event.delta?.type === "text") {
process.stdout.write(event.delta.text);
}
if (event.event_type === "interaction.completed") {
console.log("\nUsage:", JSON.stringify(event.interaction?.usage));
}
}
完全な SDK 統合ガイド(Embeddings、明示的キャッシュ CRUD、機能マトリックスなどを含む)は Gemini ネイティブ SDK 統合 を参照してください。
コンテキストキャッシュ
Geminiは、ネイティブAPIの下でデフォルトで暗黙的なコンテキストキャッシュを有効にしており、開発者が手動で操作する必要はありません。generate_contentリクエストごとに、システムは自動的に入力コンテンツのキャッシュを作成します。後続のリクエストが以前のコンテンツと完全に一致する場合、キャッシュが直接ヒットし、前回の推論結果が返され、応答速度が大幅に向上し、トークン消費を節約できる可能性があります。
- キャッシュは自動的に有効になり、手動設定は不要です。
- キャッシュは、コンテンツ、モデル、パラメータが完全に一致する場合にのみ有効になります。いずれかのフィールドが異なる場合、新しいリクエストとして扱われ、キャッシュはヒットしません。
- キャッシュの有効期限(TTL)は開発者が設定できます。設定しないことも可能です。指定しない場合、デフォルトは1時間です。最小または最大期間の制限はなく、費用はキャッシュされたトークン数とキャッシュ時間によって異なります。
- Google公式はTTLに上限を設定していませんが、当社は転送プラットフォームであるため、限られたTTL設定範囲のみをサポートしており、永続的な有効性を保証するものではありません。
注意事項
- コスト削減の保証なし:キャッシュされたトークンの課金は入力元の価格の25%であり、理論的には入力部分で最大75%のコストを節約できますが、Google公式は必ずしも節約を保証していません。実際の請求は、キャッシュヒット率、トークンタイプ、ストレージ期間を総合的に評価する必要があります。
- キャッシュヒット条件:キャッシュヒット率を高めるために、重複するコンテキストをリクエストの先頭に配置し、変動するコンテンツ(ユーザー入力など)を後部に配置することをお勧めします。
-
キャッシュヒットフィードバック:応答結果がキャッシュにヒットした場合、
response.usage_metadataにcache_tokens_detailsフィールドが含まれ、cached_content_token_countが表示されます。開発者はこれに基づいて、今回のリクエストがキャッシュにヒットしたかどうかを判断できます。 応答フィールドの例(キャッシュヒット時):cache_tokens_details=[ModalityTokenCount(modality=<MediaModality.TEXT: 'TEXT'>, token_count=2003)] cached_content_token_count=2003
from google import genai
client = genai.Client(
http_options={"base_url": "https://aihubmix.com/gemini"},
api_key="sk-***", # AiHubMixで生成したキーに置き換えてください
)
prompt = """
Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people's hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.
"""
def generate_content_sync():
response = client.models.generate_content(
model="gemini-2.5-flash-preview-05-20",
contents=prompt + "How many sentences are in this passage? ",
)
print(response.usage_metadata) # キャッシュヒット時にcache_tokens_detailsとcached_content_token_countフィールドが表示されます
return response
generate_content_sync()
キャッシュヒット時、**核心的な結論:**暗黙的なキャッシュは自動ヒットとヒットフィードバックをサポートします。開発者はusage_metadataを通じてヒット状況を判断できます。コスト削減は保証されず、実際の結果はリクエスト構造と使用シナリオによって異なります。response.usage_metadataは以下の構造を含みます。cache_tokens_details=[ModalityTokenCount(modality=<MediaModality.TEXT: 'TEXT'>, token_count=2003)] cached_content_token_count=2003
関数呼び出し
OpenAI互換方式でGeminiの関数呼び出し機能を使用する場合、リクエストボディ内にtool_choice="auto"を渡す必要があります。そうしないとエラーが発生します。
from openai import OpenAI
# モデルの関数宣言を定義
schedule_meeting_function = {
"name": "schedule_meeting",
"description": "指定された参加者と日時で会議をスケジュールします。",
"parameters": {
"type": "object",
"properties": {
"attendees": {
"type": "array",
"items": {"type": "string"},
"description": "会議に参加する人のリスト。",
},
"date": {
"type": "string",
"description": "会議の日付(例:'2024-07-29')",
},
"time": {
"type": "string",
"description": "会議の時間(例:'15:00')",
},
"topic": {
"type": "string",
"description": "会議の主題またはトピック。",
},
},
"required": ["attendees", "date", "time", "topic"],
},
}
# クライアントを設定
client = OpenAI(
api_key="sk-***", # AiHubMixで生成したキーに置き換えてください
base_url="https://aihubmix.com/v1",
)
# OpenAI互換形式で関数宣言を含むリクエストを送信
response = client.chat.completions.create(
model="gemini-2.0-flash",
messages=[
{"role": "user", "content": "Schedule a meeting with Bob and Alice for 03/14/2025 at 10:00 AM about the Q3 planning."}
],
tools=[{"type": "function", "function": schedule_meeting_function}],
tool_choice="auto" ## 📍 ここにAiHubmix互換の、より安定したリクエスト方法を追加しました
)
# 関数呼び出しを確認
if response.choices[0].message.tool_calls:
tool_call = response.choices[0].message.tool_calls[0]
function_call = tool_call.function
print(f"呼び出す関数: {function_call.name}")
print(f"引数: {function_call.arguments}")
print(response.usage)
# 実際のアプリでは、ここで関数を呼び出します。
# result = schedule_meeting(**json.loads(function_call.arguments))
else:
print("応答に関数呼び出しが見つかりませんでした。")
print(response.choices[0].message.content)
呼び出す関数: schedule_meeting
引数: {"attendees":["Bob","Alice"],"date":"2025-03-14","time":"10:00","topic":"Q3 planning"}
CompletionUsage(completion_tokens=28, prompt_tokens=111, total_tokens=139, completion_tokens_details=None, prompt_tokens_details=None)
トークン使用量追跡
- GeminiはネイティブAPIで
usage_metadataを使用して使用されたトークンを追跡します。そのフィールドは以下の通りです。
- prompt_token_count: 入力トークン数
- candidates_token_count: 出力トークン数
- thoughts_token_count: 推論に使用されたトークン数。性質上、これも出力トークンです。
- total_token_count: 総トークン使用量(入力+出力)
- OpenAI互換形式の場合、
.usageを使用して追跡します。フィールドは以下の通りです。
- usage.completion_tokens: 入力トークン数
- usage.prompt_tokens: 出力トークン数(推論に使用されたトークン数を含む)
- usage.total_tokens: 総トークン使用量
from google import genai
from google.genai import types
import time
def generate():
client = genai.Client(
api_key="sk-***", # AiHubMixで生成したキーに置き換えてください
http_options={"base_url": "https://aihubmix.com/gemini"},
)
model = "gemini-2.5-pro-preview-03-25"
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text="""How is the Rule of 72 in finance derived?"""),
],
),
]
generate_content_config = types.GenerateContentConfig(
response_mime_type="text/plain",
)
final_usage_metadata = None
for chunk in client.models.generate_content_stream(
model=model,
contents=contents,
config=generate_content_config,
):
print(chunk.text, end="")
if chunk.usage_metadata:
final_usage_metadata = chunk.usage_metadata
# すべてのチャンクの処理が完了した後、完全なトークン使用状況を出力
if final_usage_metadata:
print(f"\nUsage: {final_usage_metadata}")
if __name__ == "__main__":
generate()
from openai import OpenAI
client = OpenAI(
api_key="sk-***", # AiHubMixで生成したキーに置き換えてください
base_url="https://aihubmix.com/v1",
)
completion = client.chat.completions.create(
model="gemini-2.5-flash-preview-04-17",
reasoning_effort="low", # "low", "medium", "high"から選択可能で、それぞれ1K、8K、24Kの思考トークン予算に対応します。思考を無効にしたい場合は、reasoning_effortを"none"に設定できます。
messages=[
{
"role": "user",
"content": "How is the Rule of 72 in finance derived?"
}
],
stream=True
)
#print(completion.choices[0].message.content)
for chunk in completion:
print(chunk.choices[0].delta)
# 最後のチャンク(完全な使用量データを含む)の場合にのみ使用量情報を出力
if chunk.usage and chunk.usage.completion_tokens > 0:
print(f"出力トークン: {chunk.usage.completion_tokens}")
print(f"入力トークン: {chunk.usage.prompt_tokens}")
print(f"総トークン: {chunk.usage.total_tokens}")
最終更新日:2026-07-07