2025 年阿布扎比大奖赛第 8 圈,刘易斯·汉密尔顿在维修区通道内共用时 21.601 秒。他驾驶的法拉利赛车静止了 2.4 秒。 两个数字都来自同一次进站。计时表上,这一段比赛中用时最长的其实是第 9 圈。
你可以亲自还原这个过程。接下来要创建的 Stint Notebook 是一个读取 OpenF1 API 的 Quickchat AI Agent。询问汉密尔顿首次进站前后各三圈的情况,它会给出七圈的用时、从软胎换到硬胎的过程,以及答案所依据的原始记录链接。
这次在本地运行 Quickchat AI,得到七圈的数据,以及指向进站记录、轮胎赛段记录和单圈记录的公开链接。
下载 Stint Notebook 工具包,其中包含五个 Action 的配置示例、Main Prompt、保存的 OpenF1 响应和一个可运行的 Python 小脚本。无需 OpenF1 账号或 API 令牌,你就能查阅 OpenF1 的比赛记录。到第 2 步时,你会登录 Quickchat AI。
1. 要查的是阿布扎比站的哪个场次?
先确认比赛和车手。一个大奖赛周末有多个场次,汉密尔顿在每个场次都使用 44 号。只有先确定场次和车手,圈号才能对应到具体记录。
- 打开 OpenF1 场次记录,找到
Race、Yas Marina Circuit和日期 2025 年 12 月 7 日。每次请求都要保留session_key=9839。 - 打开 44 号车手记录,返回结果会显示刘易斯·汉密尔顿和 Ferrari。添加 Action 时,先保留这个浏览器标签页。
保持比赛场次不变,只换车手号码,就能用同一个问题查询这场比赛中的另一辆赛车。
试试 OpenF1 首页上的示例。选择 Shell,然后点击 Run。示例会返回汉密尔顿前三圈的数据。在 JSON 响应中找出 driver_number 和 lap_number。
这个示例返回第 1 至第 3 圈的数据。稍后询问进站情况时,你要查的是第 5 至第 11 圈。
OpenF1 提供自 2023 年起的历史数据,供个人使用。有关如何获取实时数据,请参阅身份验证指南。
2. 如何为 Agent 添加前两个 Action?
- 创建 Quickchat AI 账号或登录。依次选择 Add new AI Agent → Set up manually,将 Agent 命名为 Stint Notebook。AI 回复和测试会消耗额度。
- 打开 Identity → Main Prompt,粘贴下方的指令并保存。这些指令会告诉 Agent,在解释某一圈的情况之前,应先查哪些记录。
- 依次打开 Actions & MCPs → Custom Actions → Add Action → API Action → Create manually。在 API Action Name 中输入
identify_session,What to ask the user first 留空。在 API Endpoint 中选择 GET 并输入下方的 URL。Headers 和 Body 均留空。 - 在 API Action Description 中填入下方的说明,保存并启用该 Action。用同样的步骤配置
identify_driver。在这个 Action 的 What to ask the user first 中添加driver_number,选择 Number 并设为必填,再通过 Add AI Data → Parameters 将它插入 URL。
比赛场次已经写入保存的 URL。查询车手是第一个需要从对话中取值的 Action。
复制 Stint Notebook 的 Main Prompt
You are Stint Notebook. Help a race viewer inspect the completed 2025 Abu Dhabi Grand Prix, OpenF1 session 9839. Confirm the Race session and driver with Actions before reporting race facts. For Hamilton use driver 44 and verify his name. If a driver cannot be found, ask for a valid number. Run Actions one at a time. For a stop, fetch the driver's pit events and stints, then fetch at most ten laps around the selected stop. Three laps on either side means seven rows including the pit lap.
Start with the pit lap, lane_duration in seconds and stop_duration in seconds. Join each lap to its inclusive stint interval. For a lap window, show a compact Markdown table with Lap, Time (s), Tyre and Note. Use three decimal places for lap times. Note the recorded pit lap and the is_pit_out_lap flag; leave the other notes blank. Cite the exact OpenF1 pit, stint and bounded lap queries as short Markdown links.
Use only returned fields. Distinguish time in the pit lane from stationary time. A missing duration is unavailable. If a request fails, say which data you could not retrieve. Timing alone cannot establish team intent. For an aggregate, give the source rows and tell the reader to use the worksheet. Only answer historical questions on demand.
复制场次和车手查询的 Action 配置
identify_session
GET https://api.openf1.org/v1/sessions?session_key=9839
Identify the configured session. Check that session_name is Race, then report its date, circuit and session key.
identify_driver
GET https://api.openf1.org/v1/drivers?session_key=9839&driver_number={{driver_number}}
Resolve the driver by number within this race. Use full_name and driver_number from the response. If no record is found, ask for a valid number.
driver_number (Number, required): Confirmed driver number in this session, such as 44 for Lewis Hamilton.
打开 AI Preview 并提问:Which session is this, and is driver 44 in it? 确认回复中有比赛日期和汉密尔顿的姓名,再继续。如果这是你第一次配置 Action,可以参考创建可调用 API 的 Agent 的指南,按步骤操作编辑器。
3. 如何找准要查的七圈?
按进站记录确定查询区间。汉密尔顿在这场比赛中两次进站,分别在第 8 圈和第 31 圈。选中第一次进站,再向前查三圈、向后查三圈,得到第 5 至第 11 圈,首尾都包含在内。要是先查单圈数据,Agent 就得猜该从哪里找起。
F1 官方的进站摘要列出 21.601 秒。OpenF1 同时记录了这段维修区通道总用时,以及其中赛车静止的 2.4 秒。
- 在 Custom Actions 中添加
get_driver_pits和get_driver_stints。两者都使用与车手查询相同的必填参数driver_number。查询进站用单数形式的 pit 端点,查询轮胎赛段用 stints 端点。OpenF1 字段参考解释了各计时字段,包括维修区通道用时的旧别名pit_duration。 - 添加
get_driver_laps,并设置三个必填的 Number 参数。通过 Add AI Data 将driver_number、first_lap和last_lap插入 URL,保留配置示例中已编码的符号。最终的筛选条件是圈号 ≥ 起始圈号和圈号 ≤ 结束圈号。 - 在 Test Response 中输入 44、5 和 11。检查返回数组的首尾两条记录,保存并启用这三个 Action。每个问题用这个 Action 查询的范围应控制在十圈以内。提示词规定了这个上限,API URL 本身可以接受更大的范围。
上下界要放在同一个 GET 请求中。少了任何一个,都可能把比赛中该区间之外的圈也查出来。
复制进站、轮胎赛段和单圈查询的 Action 配置
get_driver_pits
GET https://api.openf1.org/v1/pit?session_key=9839&driver_number={{driver_number}}
Retrieve recorded pit events for the confirmed driver. Identify the requested pit lap. lane_duration is total time in the pit lane, stop_duration is stationary time; both are seconds. Preserve missing values.
driver_number (Number, required): Confirmed driver number in this session, such as 44 for Lewis Hamilton.
get_driver_stints
GET https://api.openf1.org/v1/stints?session_key=9839&driver_number={{driver_number}}
Retrieve tyre compounds and inclusive lap_start and lap_end boundaries for this driver. Use these intervals to label the pit and surrounding laps.
driver_number (Number, required): Confirmed driver number in this session, such as 44 for Lewis Hamilton.
get_driver_laps
GET https://api.openf1.org/v1/laps?session_key=9839&driver_number={{driver_number}}&lap_number%3E={{first_lap}}&lap_number%3C={{last_lap}}
Retrieve an inclusive interval of at most ten laps after selecting the pit event. Use lap_number, lap_duration in seconds and is_pit_out_lap. Preserve null durations. If OpenF1 returns HTTP 429, stop and ask the reader to try later. Do not repeat the lap request in the same turn.
driver_number (Number, required): Confirmed driver number in this session, such as 44 for Lewis Hamilton.
first_lap (Number, required): First lap number of the inclusive interval around the selected pit event.
last_lap (Number, required): Last lap number of the inclusive interval, at most nine above first_lap.
4. 第 8 圈和第 9 圈发生了什么变化?
在 AI Preview 中发送 Show Hamilton's three laps before and after his first pit stop in the 2025 Abu Dhabi race. 看回复时,从进站记录入手,再看前后的单圈数据。OpenF1 将第 8 圈归为软胎赛段的最后一圈。第 9 圈是换上硬胎后的第一圈,也是这个区间中唯一一条 is_pit_out_lap 为 true 的记录。
看某一圈落在哪个赛段的起止圈范围内,就能确定该圈的轮胎配方。第 8 圈仍属于首个赛段。
| 圈号 | 单圈用时(秒) | 轮胎配方 | 进出站记录 |
|---|---|---|---|
| 5 | 90.229 | 软胎 | |
| 6 | 90.254 | 软胎 | |
| 7 | 90.539 | 软胎 | |
| 8 | 92.249 | 软胎 | 进站 |
| 9 | 108.500 | 硬胎 | 出站 |
| 10 | 88.517 | 硬胎 | |
| 11 | 89.022 | 硬胎 |
这个区间用时最长的一圈是 108.500 秒,其中包含驶离维修区通道、回到赛道的过程。出站后的第一个完整圈用时 88.517 秒。如果只看两圈都用了同一种轮胎,就把它们当作普通圈来比较,会忽略其中一圈是出站圈。你可以在七圈的原始记录中逐个核对数字,再查看轮胎赛段。
进站事件和单圈用时峰值出现在相邻两行。比较配速时,可以根据出站圈标记把那一圈排除。
动手算一次。 解压工具包,在解压后的目录中运行 python3 worksheet.py。脚本会列出每一圈是否纳入计算。排除进站圈、出站圈和缺少用时的圈后,剩下五圈,用时中位数为 90.229 秒。这个结果描述的是跨两种轮胎配方选出的几圈。要研究其中一个赛段的配速,就在该赛段内选取区间,并注明排除了哪些圈。
5. 如何核验 AI 对比赛的解读?
- 在 Inbox 中打开对话,展开调用过的 Action,再打开单圈查询 Action 的 View logs。这次运行中,五次读取请求都返回了 HTTP 200。在单圈查询日志中,核对场次 9839、车手号码 44 和起止圈 5、11,确认它们与返回的七条记录对应。
- 提问:
Did Hamilton pit because Ferrari wanted an undercut?Stint Notebook 查到了两次进站,并说明仅凭这些记录无法确定法拉利当时的考虑。要核对赛车静止时间,请在原始进站记录中查看stop_duration。 - 打开 Testing → Simulation,选择 Create Dataset,再选择 Paste messages,粘贴工具包里的测试问题。相邻问题之间用一行单独的
---隔开。保存数据集并选择 Run。测试应包含一个未知车手的查询和一个实时更新请求。我们查询车手号码 999 时,数据服务返回了 404。如果查不到记录,就请用户提供有效的车手号码。如果 OpenF1 缺少某个用时或返回临时错误,就将该值标为不可用。
通过调用日志,可以把实际发出的请求与回复中描述的进站相互核对。
修改 Action 说明后,用同一组问题重新测试。既要看回复,也要核对 Action 查回的数据。
进站记录能确认法拉利何时让汉密尔顿进站。计时数据没有记录车队意图的字段。
试试这处改动。 我们模拟了单圈查询返回 HTTP 429 的情况,另外四次读取均成功。Agent 对单圈数据发起了两次请求。我们在单圈查询 Action 的说明里加了一条指令,要求遇到请求限流就停止,然后用同一个问题再测一次。这次它只请求了一次,报告了已经核实的进站情况,并将单圈用时标为不可用。测试自己的指令措辞时,可以在 View logs 中查看请求次数。
如果你已经通过 ChatGPT 或 Claude 管理 Quickchat AI,可以把工具包里的 actions.json 和 main-prompt.txt 交给该助手,让它为场次 9839 准备五个 GET Action。启用前先检查各个 URL。运行测试会消耗 Quickchat AI 额度。
用 Stint Notebook 查第二次进站。 询问汉密尔顿下一次是什么时候换胎的。这回,进站记录应指向第 31 圈,而中性胎赛段应从第 32 圈开始。这样,还没读解释,你就已经有两处原始记录可以核对答案。
常见问题
F1 的轮胎赛段是什么?
轮胎赛段指车手用同一套轮胎跑过的连续几圈。OpenF1 会记录每个赛段的编号、轮胎配方以及起止圈。在 2025 年阿布扎比大奖赛中,汉密尔顿的首个赛段是第 1 至第 8 圈,使用软胎。
获取 OpenF1 历史数据需要 API 密钥吗?
不需要。OpenF1 向个人用户提供自 2023 年起的历史场次数据,无需密钥。Quickchat AI 的对话和测试会消耗额度。访问实时数据另有要求。
汉密尔顿在 2025 年阿布扎比大奖赛的首次进站用了多久?
OpenF1 记录显示,汉密尔顿在第 8 圈通过维修区通道共用时 21.601 秒,其中赛车静止了 2.4 秒。pit 端点中的对应字段分别是 lane_duration 和 stop_duration。维修区通道总用时已包含赛车静止时间。
如何通过 OpenF1 API 获取 F1 单圈用时和轮胎配方?
用同一组 session_key 和 driver_number 获取 laps 和 stints 数据。对每个 lap_number,找到由 lap_start 和 lap_end 界定且涵盖该圈的赛段,取该赛段的 compound。laps 端点返回的 lap_duration 以秒为单位。
从这几圈能看出法拉利为什么让汉密尔顿进站吗?
记录能看出汉密尔顿何时进站、赛车静止了多久,以及出站后用了什么轮胎。车队的决策过程并未记录在内。要确认车队是否采用了提前进站争取超越(undercut)之类的策略,需要掌握对手的情况和车队意图的证据。
能用这七圈估算赛段配速吗?
只要交代纳入了哪些圈,就可以描述这段区间的配速。附带的 Python 脚本会排除进站圈、出站圈和缺少用时的圈,并给出剩余圈数和用时中位数。跨越两种轮胎配方的区间无法得出任一赛段有代表性的配速。