GPT-5·续2
Recursion is when a function solves a problem by calling itself on a smaller version of the same problem, stopping at a simple “base case.”
Simple example: factorial
- Definition: n! (n factorial) is n × (n−1) × (n−2) × … × 1, and 0! = 1.
- Recursive idea: n! = n × (n−1)! with base case 0! = 1.
How factorial(4) works:
- fact(4) = 4 × fact(3)
- fact(3) = 3 × fact(2)
- fact(2) = 2 × fact(1)
- fact(1) = 1 × fact(0)
- fact(0) = 1 ← base case
- Unwinding: 1 → 1 → 2 → 6 → 24, so fact(4) = 24.
Tiny Python version:
def fact(n):
if n == 0: # base case
return 1
return n * fact(n-1) # recursive step
Key points:
- Always have a base case to stop.
- Each call must move toward the base case (smaller/simpler input).
- Missing either leads to infinite recursion (and a crash).
[
{
"id": "chatcmpl-DpLF5wgUn4piBACWXAMIcVeY5hgvW",
"object": "chat.completion.chunk",
"created": 1781128755,
"model": "gpt-5-2025-08-07",
"service_tier": "default",
"system_fingerprint": null,
"choices": [
{
"index": 0,
"delta": {
"role": "assistant",
"content": "",
"refusal": null
},
"finish_reason": null
}
],
"usage": null,
"obfuscation": "SbmWVVEKFF"
},
{
"id": "chatcmpl-DpLF5wgUn4piBACWXAMIcVeY5hgvW",
"object": "chat.completion.chunk",
"created": 1781128755,
"model": "gpt-5-2025-08-07",
"service_tier": "default",
"system_fingerprint": null,
"choices": [
{
"index": 0,
"delta": {
"content": "Rec"
},
"finish_reason": null
}
],
"usage": null,
"obfuscation": "779H6FdPD"
},
"... 276 more chunks omitted ...",
{
"id": "chatcmpl-DpLF5wgUn4piBACWXAMIcVeY5hgvW",
"object": "chat.completion.chunk",
"created": 1781128755,
"model": "gpt-5-2025-08-07",
"service_tier": "default",
"system_fingerprint": null,
"choices": [],
"usage": {
"prompt_tokens": 16,
"completion_tokens": 797,
"total_tokens": 813,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 512,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"obfuscation": "FQ6Wmta"
}
]
</details>
<details>
<summary>Web Search — Letting the model use OpenAI's built-in web search tool to answer with current information</summary>
const response = await env.AI.run(
'openai/gpt-5',
{
input: 'What were the top news stories about Cloudflare this week? Summarise in three bullets.',
max_output_tokens: 4096,
tools: [{ type: 'web_search_preview' }],
},
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/responses \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "openai/gpt-5",
"input": "What were the top news stories about Cloudflare this week? Summarise in three bullets.",
"max_output_tokens": 4096,
"tools": [
{
"type": "web_search_preview"
}
]
}'
- June 22, 2026: Cloudflare reported increased error rates and latency tied to a fiber cut in Eastern North America, leading to a partial outage and degraded CDN/Cache performance before traffic engineering mitigations stabilized services later in the day. ([cloudflarestatus.com](https://www.cloudflarestatus.com/))
- June 17–18, 2026: Cloudflare expanded its channel focus—launching a Cloudflare One “Design Partner” designation and AI-powered migration toolkit for SASE/Zero Trust deployments—and signed Westcon‑Comstor as an EMEA‑wide distributor to scale partner-led delivery. ([itpro.com](https://www.itpro.com/technology/artificial-intelligence/cloudflare-launches-new-partner-initiative-to-support-ai-and-sase-adoption?utm_source=openai))
- June 16, 2026: Investor group JLens urged Cloudflare shareholders to withhold votes for two directors at the June 30 annual meeting, citing an ADL report criticizing Cloudflare’s services being used by extremist sites; the campaign was covered across financial wires. ([investing.com](https://www.investing.com/news/company-news/jlens-urges-cloudflare-shareholders-to-withhold-board-votes-93CH-4744895))
{
"id": "resp_02d60b161a01d826016a3990457fa8819b9fc528ec4ea8ad5c",
"object": "response",
"created_at": 1782157381,
"model": "gpt-5-2025-08-07",
"output": [
{
"id": "rs_02d60b161a01d826016a399046a994819b9d25e70abcd3c56c",
"type": "reasoning",
"content": [],
"summary": []
},
{
"id": "ws_02d60b161a01d826016a3990486108819ba2c466fcb838af82",
"type": "web_search_call",
"status": "completed",
"action": {
"type": "search",
"queries": [
"Cloudflare news this week June 2026",
"Cloudflare outage June 2026",
"Cloudflare announces new product June 2026",
"Cloudflare earnings June 2026"
],
"query": "Cloudflare news this week June 2026"
}
},
{
"id": "rs_02d60b161a01d826016a39904d3e18819bb22818e22bb15f3d",
"type": "reasoning",
"content": [],
"summary": []
},
{
"id": "ws_02d60b161a01d826016a399050a86c819bae0316a4c7791202",
"type": "web_search_call",
"status": "completed",
"action": {
"type": "open_page",
"url": "https://www.cloudflarestatus.com/"
}
},
{
"id": "rs_02d60b161a01d826016a39905240c4819b8bc7c2276ee250d7",
"type": "reasoning",
"content": [],
"summary": []
},
{
"id": "ws_02d60b161a01d826016a399055207c819bade6df968621d6c8",
"type": "web_search_call",
"status": "completed",
"action": {
"type": "search",
"queries": [
"site:cloudflare.com blog June 2026 Cloudflare announcement",
"Cloudflare announces new AI features June 2026",
"Cloudflare expands partner program June 2026 news"
],
"query": "site:cloudflare.com blog June 2026 Cloudflare announcement"
}
},
{
"id": "rs_02d60b161a01d826016a3990593d7c819bb833cdeb40ea0a49",
"type": "reasoning",
"content": [],
"summary": []
},
{
"id": "ws_02d60b161a01d826016a39905b72e8819b9cd20de4259f2bba",
"type": "web_search_call",
"status": "completed",
"action": {
"type": "search",
"queries": [
"Cloudflare news June 21 2026",
"Cloudflare June 20 2026 news",
"Cloudflare June 19 2026 news",
"Cloudflare June 16 2026 news"
],
"query": "Cloudflare news June 21 2026"
}
},
{
"id": "rs_02d60b161a01d826016a3990606f34819baa6fb7267003e879",
"type": "reasoning",
"content": [],
"summary": []
},
{
"id": "ws_02d60b161a01d826016a3990622f28819bbabde7f244f20734",
"type": "web_search_call",
"status": "completed",
"action": {
"type": "find_in_page",
"pattern": "Jun 22",
"url": "https://www.cloudflarestatus.com/"
}
},
{
"id": "rs_02d60b161a01d826016a399065ff30819b9c45d7c98a8f4e39",
"type": "reasoning",
"content": [],
"summary": []
},
{
"id": "ws_02d60b161a01d826016a39906963c0819bb0131af6ba3bc7f7",
"type": "web_search_call",
"status": "completed",
"action": {
"type": "open_page",
"url": "https://www.investing.com/news/company-news/jlens-urges-cloudflare-shareholders-to-withhold-board-votes-93CH-4744895"
}
},
{
"id": "rs_02d60b161a01d826016a39906b470c819ba2d18b349dc31613",
"type": "reasoning",
"content": [],
"summary": []
},
{
"id": "ws_02d60b161a01d826016a39906c101c819ba96f130294f46458",
"type": "web_search_call",
"status": "completed",
"action": {
"type": "search",
"queries": [
"JLens urges Cloudflare shareholders to withhold votes Reuters June 16, 2026",
"ADL report Cloudflare withhold vote JLens June 2026"
],
"query": "JLens urges Cloudflare shareholders to withhold votes Reuters June 16, 2026"
}
},
{
"id": "rs_02d60b161a01d826016a3990725224819ba7f98ab9f71093ef",
"type": "reasoning",
"content": [],
"summary": []
},
{
"id": "ws_02d60b161a01d826016a3990757154819b9d9aee09a6c4a2e7",
"type": "web_search_call",
"status": "completed",
"action": {
"type": "open_page",
"url": "https://simplywall.st/stocks/us/software/nyse-net/cloudflare/news/cloudflare-net-expands-ai-security-with-ping-identity-partne"
}
},
{
"id": "rs_02d60b161a01d826016a399079c738819b8b884bab3927fe7c",
"type": "reasoning",
"content": [],
"summary": []
},
{
"id": "ws_02d60b161a01d826016a39907a6720819b8df7a6994610bd54",
"type": "web_search_call",
"status": "completed",
"action": {
"type": "search",
"queries": [
"Cloudflare Ping Identity partnership June 2026",
"Ping Identity Cloudflare partnership 2026"
],
"query": "Cloudflare Ping Identity partnership June 2026"
}
},
{
"id": "rs_02d60b161a01d826016a3990817980819bab31195c884444a6",
"type": "reasoning",
"content": [],
"summary": []
},
{
"id": "msg_02d60b161a01d826016a3990922d28819ba309de72951ad102",
"type": "message",
"status": "completed",
"content": [
{
"type": "output_text",
"annotations": [
{
"type": "url_citation",
"end_index": 316,
"start_index": 257,
"title": "Cloudflare Status",
"url": "https://www.cloudflarestatus.com/"
},
{
"type": "url_citation",
"end_index": 746,
"start_index": 582,
"title": "Cloudflare launches new partner initiative to support AI and SASE adoption",
"url": "https://www.itpro.com/technology/artificial-intelligence/cloudflare-launches-new-partner-initiative-to-support-ai-and-sase-adoption?utm_source=openai"
},
{
"type": "url_citation",
"end_index": 1152,
"start_index": 1017,
"title": "JLens urges Cloudflare shareholders to withhold board votes By Investing.com",
"url": "https://www.investing.com/news/company-news/jlens-urges-cloudflare-shareholders-to-withhold-board-votes-93CH-4744895"
}
],
"logprobs": [],
"text": "- June 22, 2026: Cloudflare reported increased error rates and latency tied to a fiber cut in Eastern North America, leading to a partial outage and degraded CDN/Cache performance before traffic engineering mitigations stabilized services later in the day. ([cloudflarestatus.com](https://www.cloudflarestatus.com/))\n- June 17–18, 2026: Cloudflare expanded its channel focus—launching a Cloudflare One “Design Partner” designation and AI-powered migration toolkit for SASE/Zero Trust deployments—and signed Westcon‑Comstor as an EMEA‑wide distributor to scale partner-led delivery. ([itpro.com](https://www.itpro.com/technology/artificial-intelligence/cloudflare-launches-new-partner-initiative-to-support-ai-and-sase-adoption?utm_source=openai))\n- June 16, 2026: Investor group JLens urged Cloudflare shareholders to withhold votes for two directors at the June 30 annual meeting, citing an ADL report criticizing Cloudflare’s services being used by extremist sites; the campaign was covered across financial wires. ([investing.com](https://www.investing.com/news/company-news/jlens-urges-cloudflare-shareholders-to-withhold-board-votes-93CH-4744895))"
}
],
"role": "assistant"
}
],
"status": "completed",
"usage": {
"input_tokens": 45264,
"output_tokens": 2548,
"total_tokens": 47812,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 1920
}
},
"background": false,
"billing": {
"payer": "developer"
},
... response truncated ...
</details>
Parameters
Schema variant
ResponsesChat Completions
▶input
one ofrequired
instructions
string
temperature
numberminimum: 0maximum: 2
max_output_tokens
numberexclusiveMinimum: 0
top_p
numberminimum: 0maximum: 1
stream
boolean
▶tools[]
array
tool_choice
▶text{}
object
▶reasoning{}
object
▶messages[]
arrayrequired
temperature
numberminimum: 0maximum: 2
max_tokens
numberexclusiveMinimum: 0
max_completion_tokens
numberexclusiveMinimum: 0
top_p
numberminimum: 0maximum: 1
frequency_penalty
numberminimum: -2maximum: 2
presence_penalty
numberminimum: -2maximum: 2
stream
boolean
▶stream_options{}
object
▶tools[]
array
tool_choice
response_format
▶modalities[]
array
▶audio{}
object
reasoning_effort
stringOptional reasoning control; availability and accepted values are model-dependent.
id
string
object
stringconst: response
created_at
number
model
string
▶output[]
array
output_text
string
status
stringenum: in_progress, completed, failed, incomplete
▶usage{}
object
id
string
object
string
created
number
model
string
▶choices[]
array
▶usage{}
object
API Schemas (Raw)
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ai/models/openai/gpt-5/#page","headline":"GPT-5","description":"OpenAI's model excelling at coding, writing, and reasoning.","url":"https://developers.cloudflare.com/ai/models/openai/gpt-5/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: GPT-5 Mini is the lightweight, low-cost variant of GPT-5, well suited to high-volume coding and reasoning tasks. title: GPT-5 mini image: https://developers.cloudflare.com/og-docs.png
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt
Use this file to discover all available pages before exploring further.

