メインコンテンツへスキップ
プラットフォームは、OpenAI chat/completions プロトコルおよび Gemini ネイティブプロトコルを使用した Gemini モデルへのアクセスをサポートしています。 以下の例はいずれも非 Stream モードを使用しています。Stream モードが必要な場合は、Path を /gemini/v1/models/:streamGenerateContent に変更してください。

クイックスタート

curl https://api.highwayapi.ai/openai/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR-API-KEY>" \
-d '{
    "model": "gemini-2.5-flash",
    "messages": [{
        "role": "user", "content": "What is the capital of France?"
    }],
    "reasoning_effort": "low"
  }'

OpenAI プロトコルの思考制御

プラットフォームは、OpenAI chat/completions リクエストの reasoning_effort パラメータを Gemini thinking パラメータに変換します。
reasoning_effortthinking
”disable”, “none""budget_tokens”: 0
”low""budget_tokens”: 1024
”medium""budget_tokens”: 2048
”high""budget_tokens”: 4096
⚠️ OpenAI の標準値ではない disable/none を使用して、思考プロセスをオフにできます

各モデルのデフォルト設定

モデルデフォルト設定(reasoning_effort 未設定時)
2.5 Pro動的思考:モデルがいつ、どれだけ思考するかを決定
2.5 Flash動的思考:モデルがいつ、どれだけ思考するかを決定
2.5 Flash Lite思考は無効化済み
⚠️ Gemini 2.5 Pro では思考を無効化できません。reasoning_effort: none は最小 thinkingBudget 128 に変換されます ⚠️ thinkingBudget は Gemini 2.5 Flash、2.5 Pro、2.5 Flash-Lite でのみサポートされています。プロンプトによっては、モデルが token 予算を上回る、または下回る場合があります。

サーバーサイドツールの使用

Google Search を利用することで、Gemini モデルをリアルタイムのウェブコンテンツと関連付け、利用可能なすべての言語をサポートできます。これにより、Gemini はより正確な回答を提供し、知識カットオフ日以降の検証可能なソースを引用できるようになります。
curl https://api.highwayapi.ai/openai/chat/completions \
-H "Authorization: Bearer <YOUR-API-KEY>" \
-H "Content-Type: application/json" -d @- <<EOF
{
  "model": "gemini-2.5-flash-lite",
  "messages": [
    {
      "role": "user",
      "content": "列一下今天中国的热点新闻"
    }
  ],
  "tools": [
    {
      "function": {"name": "google_search"}
    }
  ]
}
EOF
結果例は以下のとおりです。OpenAI プロトコルでは、非標準フィールド gemini_grounding_metadata から Grounding 情報を取得できます。
{
  "id": "dcc7eab10b5adeb9e8648d134e815409",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here are some of today's top news in China: ..."
      },
      "finish_reason": "stop"
    }
  ],
  "gemini_grounding_metadata": {  # 👈 GEMINI GROUNDING
    "webSearchQueries": [
      "中国今日热点新闻"
    ],
    ...
    "groundingChunks": [
      ...
    ]
  }
}

Code Execution

Gemini はコード実行ツールを提供しており、モデルが Python コードを生成して実行できるようにします。その後、モデルはコード実行結果に基づいて反復的に学習し、最終的な出力を得ることができます。
curl https://api.highwayapi.ai/openai/chat/completions \
-H "Authorization: Bearer <YOUR-API-KEY>" \
-H "Content-Type: application/json" -d @- <<EOF
{
  "model": "gemini-2.5-flash",
  "messages": [
    {
      "role": "user",
      "content": "What is the sum of the first 50 prime numbers? Generate and run code for the calculation, and make sure you get all 50."
    }
  ],
  "tools": [
      {
           "function":  {"name": "code_execution"}
      }
  ],
  "reasoning_effort": "low"
}
EOF
結果例は以下のとおりです。OpenAI プロトコルでは、コードとコード実行結果は content に表示されます。Gemini プロトコルでは、コードは executableCode フィールドに、実行結果は codeExecutionResult フィールドに、要約は text フィールドに表示されます。
Okay, I can help you with that. I will write a Python script to find the
first 50 prime numbers and then calculate their sum.

Here's the plan:

1.  Create a function to check if a number is prime.
2.  Create a function to generate the first `n` prime numbers.
3.  Call the generation function for the first 50 primes.
4.  Sum the resulting list of primes.

Here is the code to perform this calculation:

```PYTHON
def is_prime(num):
    """Checks if a number is prime."""
    if num <= 1:
        return False
    if num <= 3:
        return True
    if num % 2 == 0 or num % 3 == 0:
        return False
    i = 5
    while i * i <= num:
        if num % i == 0 or num % (i + 2) == 0:
            return False
        i += 6
    return True

def get_first_n_primes(n):
    """Generates a list of the first n prime numbers."""
    primes = []
    num = 2
    while len(primes) < n:
        if is_prime(num):
            primes.append(num)
        num += 1
    return primes

# Get the first 50 prime numbers
first_50_primes = get_first_n_primes(50)


# Calculate the sum of these prime numbers

sum_of_primes = sum(first_50_primes)


print(f"The first 50 prime numbers are: {first_50_primes}")

print(f"The sum of the first 50 prime numbers is: {sum_of_primes}")
```

The first 50 prime numbers are: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,
37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107,
109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191,
193, 197, 199, 211, 223, 227, 229]

The sum of the first 50 prime numbers is: 5117

URL context

URL context ツールを使用すると、URL の形式でモデルに追加のコンテキストを提供できます。 リクエストに URL を追加すると、モデルはそれらのウェブページ内のコンテンツにアクセスし、回答の情報源として利用することで回答品質を向上させます。
curl https://api.highwayapi.ai/openai/chat/completions \
-H "Authorization: Bearer <YOUR-API-KEY>" \
-H "Content-Type: application/json" -d @- <<EOF
{
  "model": "gemini-2.5-flash-lite",
  "messages": [
    {
      "role": "user",
      "content": "这份食谱适合什么人士 https://www.foodnetwork.com/recipes/ina-garten/perfect-roast-chicken-recipe-1940592"
    }
  ],
  "tools": [
    {
      "function": {"name": "url_context"}
    }
  ]
}
EOF
レスポンス例は以下のとおりです
{
  "id": "82f10046aebe6697ed9d33a9fa398de4",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "这份食谱是关于如何制作 Ina Garten 的完美烤鸡。\n\n**关键信息:**\n* **食谱来源:** Ina Garten,改编自《Barefoot Contessa Cookbook》。\n* **准备时间:** 20 分钟\n* **烘烤时间:** 1 小时 30 分钟\n* **总时间:** 2 小时 10 分钟\n* **份量:** 8 人份\n* **难度:** 中等\n\n**食材:**\n* 一只 5-6 磅的烤鸡\n* 犹太盐\n* 新鲜磨碎的黑胡椒\n* 一大把新鲜百里香,外加 20 枝\n* 一个柠檬,对半切\n* 一头大蒜,横向切半\n* 2 汤匙(1/4 条)黄油,融化\n* 1 个大黄洋葱,厚切\n* 4 根胡萝卜,切成 2 英寸块\n* 1 个茴香头,去掉顶部,切成楔形\n* 橄榄油\n\n**制作步骤:**\n1. 预热烤箱至 425 华氏度(约 220 摄氏度)。\n2. 清理鸡的内脏,冲洗鸡的内外。去除多余的脂肪和残留的羽毛,并拍干鸡的外部。\n3. 在鸡的内部慷慨地撒上盐和胡椒。将一把百里香、半个柠檬和所有大蒜塞入鸡腔。\n4. 用融化的黄油刷鸡的外部,并再次撒上盐和胡椒。\n5. 用厨房绳子将鸡腿绑在一起,并将鸡翅尖塞到鸡身下方。\n6. 将洋葱、胡萝卜和茴香放入烤盘。用盐、胡椒、20 枝百里香和橄榄油拌匀。将蔬菜铺在烤盘底部,然后将鸡放在蔬菜上面。\n7. 烘烤鸡肉 1.5 小时,或直至用刀在腿和 thigh 之间切割时,汁水清澈。\n8. 将烤好的鸡和蔬菜移至盘子,用铝箔覆盖静置约 20 分钟。\n9. 将鸡肉切片装盘,与蔬菜一起食用。\n\n**烹饪技巧和用户反馈:**\n* 食谱中提到,如果蔬菜底部开始变褐色,可以加入一杯鸡汤帮助保持湿润。\n* 有用户建议使用更小的烤盘,以避免蔬菜烤焦。\n* 有用户将茴香替换成土豆。\n* 许多用户反馈鸡肉非常鲜嫩多汁,风味十足,而且烹饪过程简单。"
      },
      "finish_reason": "stop"
    }
  ],
  "gemini_grounding_metadata": {
    "groundingChunks": [
      {
        "web": {
          "uri": "https://www.foodnetwork.com/recipes/ina-garten/perfect-roast-chicken-recipe-1940592",
          "title": "Perfect Roast Chicken Recipe | Ina Garten | Food Network"
        }
      }
    ],
    "groundingSupports": [....]
  }
}