跳转到主要内容
平台目前支持使用 OpenAI chat/completions 协议访问 Gemini 模型。

思考控制

平台会将 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 可用于关闭思考过程

试一试

curl https://api.jiekou.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"
  }'

各模型默认设置

模型默认设置(未设置 reasoning_effort)
2.5 Pro动态思考:模型决定何时以及思考多少
2.5 Flash动态思考:模型决定何时以及思考多少
2.5 Flash Lite思考已禁用
⚠️ 无法为 Gemini 2.5 Pro 禁用思考,reasoning_effort: low 将被转换为最小 thinkingBudget 128 ⚠️ thinkingBudget 仅在 Gemini 2.5 Flash、2.5 Pro 和 2.5 Flash-Lite 中支持。根据提示的不同,模型可能会超出或低于 token 预算。

服务端工具使用

依托 Google Search 可将 Gemini 模型与实时网络内容相关联,并支持所有可用语言。这样一来,Gemini 就可以提供更准确的回答,并引用知识截止日期之后的可验证来源。
https://api.jiekou.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"} # 👈 ADD 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 代码。然后,模型可以根据代码执行结果进行迭代学习,直到获得最终输出。
https://api.jiekou.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"} # 👈 ADD CODE EXECUTION
      }
  ],
  "reasoning_effort": "low"
}
EOF
结果示例如下,代码和代码执行结果将在 content 中体现
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 工具,您可以网址的形式向模型提供更多上下文。 通过在请求中添加网址,模型将访问这些网页中的内容,从而为回答提供信息并提高回答质量。
https://api.jiekou.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"} 👈 ADD 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": [....]
  }
}
I