GPT-5·续1
</details>
<details>
<summary>Creative Writing — Longer completion for creative output</summary>
const response = await env.AI.run(
'openai/gpt-5',
{
max_completion_tokens: 8192,
messages: [
{
content: 'Write a short story opening about a detective finding an unusual clue.',
role: 'user',
},
],
},
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/chat/completions \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "openai/gpt-5",
"max_completion_tokens": 8192,
"messages": [
{
"content": "Write a short story opening about a detective finding an unusual clue.",
"role": "user"
}
]
}'
The diner on Maple had the sort of dawn that came with mop water and an apology. Lemon and old fry oil hung in the air; the neon COFFEE sign in the front window had sputtered itself into a coma sometime before three. Someone had left the door propped with a folded phone book. Someone else had left fingerprints everywhere you could put a hand to steady yourself.
“Mr. Hale?” The manager’s voice came out thin. He was a man who wore his keys like medals, ring clinking against the register as if noise could keep the room from thinking about what had happened in the stockroom. He kept rubbing a clean spot on the Formica with the heel of his palm. “They said not to touch anything. But, uh, someone’s going to have to… You know. She’s back there.”
“I know.” I did not look back there yet. The living are easier to talk to than the dead. The living lie worse, too.
It wasn’t my first crime scene in a place that sold coffee by the gallon, but it was the first time time itself had been sitting on the counter.
Right in the dead center of the service line, between the sugar pourer and a pitcher lipped with milk, stood an hourglass. Not the novelty kind with pink sand and a smiley face, but two clean bulbs pinched at the waist and sealed with a brass cap, the sort of thing you buy for seventeen dollars at a shop that also sells candles that smell like foreign countries.
The stuff pouring through it wasn’t sand.
Dark grit eased from the top bulb to the bottom in a slow, stubborn ribbon. The grounds were too coarse for espresso, too fine for the diner’s clumsy metal basket. I leaned in and the smell of chicory lifted and slid clean into my head. Coffee with teeth. Not something Maple Street Diner served, not in the ten years I’d been stopping in for grilled cheese on Tuesdays. They brewed what came in five-pound bricks with promises on the bag and regrets in the cup.
The hourglass sat in a perfect ring of coffee, the way a drink leaves its mark if you lift it and set it down, lift it and set it down, chasing conversation. Only the ring was too clean, too even. Not slapped there by accident but drawn, like a target.
“Don’t they come with sand?” the manager said, as if I’d stock tips on timepieces. He had the kind of face you wanted to put directions on. He kept glancing toward the hallway where the kitchen started. “Who would bring that here?”
“Somebody who wanted us to see it.” I bent until the glass filled my whole world, the way a thing does when you’re trying not to see a bigger thing behind it. Grounds slid down and hit the bottom with tiny clicks, a sound you feel more than hear. The top bulb was half-empty. The bottom was making a little hill that would slump and start again, brown avalanches inside a winter globe.
There were four notch marks on the counter by the hourglass, burned in with something hot. A cigarette, maybe, or a soldering iron. Not long lines, just ticks where a thumbnail might count. The fugitive smell of something singed lived there. I put a finger near one and felt the edge of the scorch under the polish of a thousand elbows. Not fresh. But made last night, if the way they were crisping under the fluorescent hum meant anything.
I didn’t touch the glass. I touched the ring instead, lightly, because that’s what people notice if you don’t. It was tacky. It left the faint outline of my fingertip when I lifted it away. The coffee in the ring had been thick when it went down, not drip-thin but almost syrup, like someone boiled it down on the stovetop. Old trick for buzzing cheap liquor. Or for drawing with.
“Chicory,” I said, mostly to the hourglass. The manager blinked at me, like I’d just named my favorite constellation.
“Is that… good?”
“If you’re homesick for New Orleans and don’t mind lying to yourself,” I said. It wasn’t a Maple Street thing. It was nowhere-on-this-block thing. There was a place on Luzerne that sold blue crab on Sundays and tobacco under the counter on every day that ended in Y; they stocked cans with a fleur-de-lis on the label behind a curtain you had to ask to see. People who bought it were a certain kind of precise. They liked their mornings with a habit in them.
Someone had clocked her in the stockroom, the call had said, a quick violence that made a long problem. Someone had propped the door so the sirens wouldn’t have to rattle the handle. Someone had time to leave me a prop that wasn’t a prop at all.
“Do me a favor,” I said. “Don’t let anyone touch this. Or sneeze on it. Or breathe enthusiastically.”
The manager nodded as if those were the rules we’d been living by all along. He made himself small, backing away without looking away, like the hourglass might leap off the counter and bite him.
I watched grounds fall through the neck. When they hit the bottom, they rolled a little and settled. The top empties, the bottom fills. After a certain point, if you don’t turn it over, it’s done.
Four notches. A ring drawn too carefully to have happened on accident. Chicory where there shouldn’t be chicory. I counted in my head with the tiny rain of grit, not minutes, because those stretch and snap, but beats. The hourglass bled its coffee heart out with a drummer’s stubbornness—two hundred and forty by the time the hill slumped over and smoothed into itself.
Four flips. Four songs at two minutes each. Four smoke breaks. Four chances to wait and see if someone came through the side door with a soft apology and a reason.
I didn’t know, not yet, what the someone had been timing. Grief. Guts. The moment the street went quiet enough for them to walk. A message for anybody who could read taste and habit like handwriting.
All I knew was that the glass didn’t belong here and neither did its smell. The clue wasn’t unusual because it was clever. It was unusual because it was kind. Somebody, standing in a cheap-lit diner with lemon in their nose and something ruinous at their back, had thought to leave me time that I could tip over with a wrist. Time I could see.
I wish the dead had names like that. I wish they all came with something you could hold up to the light and say, here, this is how long it took. This is where it started; this is where it ran out.
“Mr. Hale?” The manager had drifted back. He’d taken off his keys and set them in a neat circle beside the register, a little hourglass of his own. He had a voice that was trying to be a whisper but kept smarting into sound. “Do you want to—should I—”
“In a minute,” I said. The coffee ring had started to skin over. The grounds made a small mountain inside their bottle. I lowered my head until I could see the thin seam in the brass cap that sealed it, a tiny imperfection in a factory finish. Someone had pried it open once with a butter knife and tamped the top with a thumb. It had a dent in it, a crescent like the side of a bitten moon.
Sometimes the city gives you a map. Sometimes it just gives you a circle and tells you to stand inside it until the world narrows down to what fits. I straightened, and the room got bigger.
“Okay,” I said. “Let’s go look at the thing we’re not looking at.”
{
"id": "chatcmpl-DpLK1cHoQaButs3hdRNv4w58l1y8J",
"object": "chat.completion",
"created": 1781129061,
"model": "gpt-5-2025-08-07",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The diner on Maple had the sort of dawn that came with mop water and an apology. Lemon and old fry oil hung in the air; the neon COFFEE sign in the front window had sputtered itself into a coma sometime before three. Someone had left the door propped with a folded phone book. Someone else had left fingerprints everywhere you could put a hand to steady yourself.\n\n“Mr. Hale?” The manager’s voice came out thin. He was a man who wore his keys like medals, ring clinking against the register as if noise could keep the room from thinking about what had happened in the stockroom. He kept rubbing a clean spot on the Formica with the heel of his palm. “They said not to touch anything. But, uh, someone’s going to have to… You know. She’s back there.”\n\n“I know.” I did not look back there yet. The living are easier to talk to than the dead. The living lie worse, too.\n\nIt wasn’t my first crime scene in a place that sold coffee by the gallon, but it was the first time time itself had been sitting on the counter.\n\nRight in the dead center of the service line, between the sugar pourer and a pitcher lipped with milk, stood an hourglass. Not the novelty kind with pink sand and a smiley face, but two clean bulbs pinched at the waist and sealed with a brass cap, the sort of thing you buy for seventeen dollars at a shop that also sells candles that smell like foreign countries.\n\nThe stuff pouring through it wasn’t sand.\n\nDark grit eased from the top bulb to the bottom in a slow, stubborn ribbon. The grounds were too coarse for espresso, too fine for the diner’s clumsy metal basket. I leaned in and the smell of chicory lifted and slid clean into my head. Coffee with teeth. Not something Maple Street Diner served, not in the ten years I’d been stopping in for grilled cheese on Tuesdays. They brewed what came in five-pound bricks with promises on the bag and regrets in the cup.\n\nThe hourglass sat in a perfect ring of coffee, the way a drink leaves its mark if you lift it and set it down, lift it and set it down, chasing conversation. Only the ring was too clean, too even. Not slapped there by accident but drawn, like a target.\n\n“Don’t they come with sand?” the manager said, as if I’d stock tips on timepieces. He had the kind of face you wanted to put directions on. He kept glancing toward the hallway where the kitchen started. “Who would bring that here?”\n\n“Somebody who wanted us to see it.” I bent until the glass filled my whole world, the way a thing does when you’re trying not to see a bigger thing behind it. Grounds slid down and hit the bottom with tiny clicks, a sound you feel more than hear. The top bulb was half-empty. The bottom was making a little hill that would slump and start again, brown avalanches inside a winter globe.\n\nThere were four notch marks on the counter by the hourglass, burned in with something hot. A cigarette, maybe, or a soldering iron. Not long lines, just ticks where a thumbnail might count. The fugitive smell of something singed lived there. I put a finger near one and felt the edge of the scorch under the polish of a thousand elbows. Not fresh. But made last night, if the way they were crisping under the fluorescent hum meant anything.\n\nI didn’t touch the glass. I touched the ring instead, lightly, because that’s what people notice if you don’t. It was tacky. It left the faint outline of my fingertip when I lifted it away. The coffee in the ring had been thick when it went down, not drip-thin but almost syrup, like someone boiled it down on the stovetop. Old trick for buzzing cheap liquor. Or for drawing with.\n\n“Chicory,” I said, mostly to the hourglass. The manager blinked at me, like I’d just named my favorite constellation.\n\n“Is that… good?”\n\n“If you’re homesick for New Orleans and don’t mind lying to yourself,” I said. It wasn’t a Maple Street thing. It was nowhere-on-this-block thing. There was a place on Luzerne that sold blue crab on Sundays and tobacco under the counter on every day that ended in Y; they stocked cans with a fleur-de-lis on the label behind a curtain you had to ask to see. People who bought it were a certain kind of precise. They liked their mornings with a habit in them.\n\nSomeone had clocked her in the stockroom, the call had said, a quick violence that made a long problem. Someone had propped the door so the sirens wouldn’t have to rattle the handle. Someone had time to leave me a prop that wasn’t a prop at all.\n\n“Do me a favor,” I said. “Don’t let anyone touch this. Or sneeze on it. Or breathe enthusiastically.”\n\nThe manager nodded as if those were the rules we’d been living by all along. He made himself small, backing away without looking away, like the hourglass might leap off the counter and bite him.\n\nI watched grounds fall through the neck. When they hit the bottom, they rolled a little and settled. The top empties, the bottom fills. After a certain point, if you don’t turn it over, it’s done.\n\nFour notches. A ring drawn too carefully to have happened on accident. Chicory where there shouldn’t be chicory. I counted in my head with the tiny rain of grit, not minutes, because those stretch and snap, but beats. The hourglass bled its coffee heart out with a drummer’s stubbornness—two hundred and forty by the time the hill slumped over and smoothed into itself.\n\nFour flips. Four songs at two minutes each. Four smoke breaks. Four chances to wait and see if someone came through the side door with a soft apology and a reason.\n\nI didn’t know, not yet, what the someone had been timing. Grief. Guts. The moment the street went quiet enough for them to walk. A message for anybody who could read taste and habit like handwriting.\n\nAll I knew was that the glass didn’t belong here and neither did its smell. The clue wasn’t unusual because it was clever. It was unusual because it was kind. Somebody, standing in a cheap-lit diner with lemon in their nose and something ruinous at their back, had thought to leave me time that I could tip over with a wrist. Time I could see.\n\nI wish the dead had names like that. I wish they all came with something you could hold up to the light and say, here, this is how long it took. This is where it started; this is where it ran out.\n\n“Mr. Hale?” The manager had drifted back. He’d taken off his keys and set them in a neat circle beside the register, a little hourglass of his own. He had a voice that was trying to be a whisper but kept smarting into sound. “Do you want to—should I—”\n\n“In a minute,” I said. The coffee ring had started to skin over. The grounds made a small mountain inside their bottle. I lowered my head until I could see the thin seam in the brass cap that sealed it, a tiny imperfection in a factory finish. Someone had pried it open once with a butter knife and tamped the top with a thumb. It had a dent in it, a crescent like the side of a bitten moon.\n\nSometimes the city gives you a map. Sometimes it just gives you a circle and tells you to stand inside it until the world narrows down to what fits. I straightened, and the room got bigger.\n\n“Okay,” I said. “Let’s go look at the thing we’re not looking at.”",
"refusal": null,
"annotations": []
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 19,
"completion_tokens": 4961,
"total_tokens": 4980,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 3328,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"service_tier": "default",
"system_fingerprint": null,
"gatewayMetadata": {
"keySource": "Unified"
}
}
</details>
<details>
<summary>Streaming Response — Enable streaming for real-time output</summary>
const response = await env.AI.run(
'openai/gpt-5',
{
messages: [{ content: 'Explain the concept of recursion with a simple example.', role: 'user' }],
stream: true,
stream_options: { include_usage: true },
},
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/chat/completions \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"model": "openai/gpt-5",
"messages": [
{
"content": "Explain the concept of recursion with a simple example.",
"role": "user"
}
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'
