For NDJSON:·续1
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"annotations": [],
"content": "Below are two classic ways to get from San Francisco to Los Angeles, followed by the best stops on each. Pick the route (or combine sections of both) that matches the time you have and the mood you’re after.\n\n────────────────────────\n1. SCENIC COAST ROUTE\n Highway 1 / Pacific Coast Highway (PCH)\n────────────────────────\nTotal distance: ≈ 460 mi \nDriving time (no stops): ≈ 9 hrs \nIdeal trip length: 2–4 days\n\nNorth-to-South Highlights\n1. Santa Cruz (75 mi / 1½ hr from SF) \n • Surfing scene at Steamer Lane, Beach Boardwalk amusement park, funky downtown cafés. \n • 10 min detour inland: Roaring Camp steam train through redwoods.\n\n2. Monterey & Pacific Grove (45 mi) \n • Monterey Bay Aquarium, Cannery Row, whale-watch/via kayak, 17-Mile Drive coastal loop.\n\n3. Carmel-by-the-Sea (5 mi) \n • Fairy-tale cottages, white-sand Carmel Beach, art galleries. \n • Food tip: La Bicyclette or picnic from 5th Ave Deli.\n\n4. Big Sur Corridor (25-90 mi) \n • Bixby Creek Bridge photo stop. \n • Garrapata & Pfeiffer Big Sur State Parks (purple-sand Pfeiffer Beach). \n • Nepenthe Restaurant for clifftop views. \n • McWay Falls at Julia Pfeiffer Burns SP (¼-mile walk to overlook). \n • Overnight options: Big Sur Lodge, Ventana glamping, or campground sites book early.\n\n5. Ragged Point (35 mi) \n • “Gateway to Big Sur” cliffside vista + coffee/snack.\n\n6. San Simeon / Hearst Castle (15 mi) \n • 2-hr hilltop tour of William Randolph Hearst’s mansion. \n • Elephant seal rookery at Piedras Blancas (free, near parking lot).\n\n7. Cambria (8 mi) \n • Moonstone Beach boardwalk, galleries, Linn’s pies.\n\n8. Morro Bay (22 mi) \n • Kayak around Morro Rock, sea otters in the marina, fish-n-chips on Embarcadero.\n\n9. San Luis Obispo (13 mi) \n • Thursday night farmers market, Mission San Luis Obispo, Bubblegum Alley. \n • Unique stay: Madonna Inn’s themed rooms.\n\n10. Pismo Beach / Oceano Dunes (12 mi) \n • Walk the pier at sunset; rent an ATV on the dunes. Splash Café for chowder.\n\n11. Danish Village of Solvang (55 mi) \n • Windmills, aebleskiver pastries, nearby Santa Ynez wine tasting.\n\n12. Santa Barbara (35 mi) \n • Mediterranean downtown, Funk Zone wine bars, Stearns Wharf. \n • Quick hike: Inspiration Point (3 mi round-trip).\n\n13. Ventura & Channel Islands Gateway (30 mi) \n • If you have a half-day, boat to Anacapa or Santa Cruz Island for hiking/kayaking. \n • Otherwise stroll Ventura Pier and old-town Main St.\n\n14. Malibu (29 mi) \n • Lunch at Malibu Farm Café on the pier, surf at Zuma Beach, quick cliff walk at Point Dume.\n\n15. Santa Monica & LA arrival (18 mi) \n • Ferris wheel on the pier, bike path to Venice Beach. \n • From here it’s 15–25 mi into Hollywood/Downtown depending on traffic.\n\n────────────────────────\n2. QUICK(ER) INLAND ROUTE\n US-101 ➜ CA-154 ➜ US-101 or I-5\n────────────────────────\nTotal distance: ≈ 385 mi \nDriving time (no stops): ≈ 5 hrs 45 min \nIdeal trip length: 1–2 days \nCharacter: Rolling hills, vineyards, missions, fewer hairpin turns than Hwy 1.\n\nKey Stops (North-to-South)\n• Gilroy – Garlic capital, outlet shopping. \n• Paso Robles – 200+ wineries, Tin City craft beverage hub, Sensorio light--field art installation (night). \n• San Luis Obispo / Pismo (see above). \n• Solvang & Santa Ynez wine region (see above). \n• Santa Barbara (see above). \n• Optional fast cutover: at Gaviota take CA-154 (San Marcos Pass) to shave ~20 min and drop into Santa Barbara’s north side. \n• From Santa Barbara you can stay on 101 along the coast or jump to I-5 at Ventura (via CA-126) for a straight shot into LA.\n\n────────────────────────\n3. PLANNING TIPS\n────────────────────────\nTime of year\n• Winter–spring: Whale migrations, lush green hills in Big Sur, chance of mudslides (check Caltrans). \n• Summer: Long daylight, heavier traffic, book lodgings far ahead. Coastal fog (“June Gloom”) often burns off by noon. \n• Fall: Warm, clear, vineyards in harvest, lighter crowds.\n\nRoad & safety\n• Fill up before Big Sur; fuel is scarce/pricey between Carmel and Cambria. \n• Cell service is sporadic in Big Sur—download offline maps. \n• Carry layers: temperatures swing 30 °F between sun and coastal fog.\n\nLodging snapshot\n• Quick overnights: Monterey, Cambria, San Luis Obispo, Santa Barbara. \n• Camping gems: Pfeiffer Big Sur SP, Kirk Creek (ocean bluff), Morro Bay SP, Refugio State Beach (just past Santa Barbara). \n• Boutique splurges: Post Ranch Inn (Big Sur), Hotel Cheval (Paso Robles), El Encanto (Santa Barbara).\n\nDriving pace guide (coast route)\nSF → Santa Cruz: 1½ hr \nSanta Cruz → Monterey/Carmel: 45 min \nCarmel → Ragged Point (start of Big Sur): 2 hrs (allow 3-4 hrs with view stops) \nRagged Point → SLO: 1½ hrs \nSLO → Santa Barbara: 1½ hrs \nSanta Barbara → LA (Santa Monica): 1½ hrs (traffic can double this)\n\n────────────────────────\n4. SAMPLE ITINERARIES\n────────────────────────\nTwo-day “Greatest Hits” (coast)\nDay 1: SF → Monterey (aquarium & 17-Mile Drive) → Bixby Bridge sunset → overnight in Big Sur or Cambria. \nDay 2: Hearst Castle → Morro Bay lunch → Santa Barbara stroll/dinner → evening arrival in LA.\n\nThree-day Leisure (mixed routes)\nDay 1: SF → Santa Cruz boardwalk → Carmel lunch → Big Sur hiking → overnight in Cambria. \nDay 2: Cambria → Paso Robles wine tasting → Pismo Beach ATV at dunes → overnight in San Luis Obispo (Thursday farmers market). \nDay 3: Solvang pastries → Santa Barbara beach and mission → Malibu sunset → LA.\n\nExpress one-day (inland)\nMorning: Leave SF 7 a.m. → coffee in Paso Robles (~11 a.m.) → lunch in Santa Barbara (~2 p.m.) → LA by dinner (~6 p.m.), assuming light traffic.\n\nEnjoy the ride, keep an eye on real-time road conditions at quickmap.dot.ca.gov, and don’t forget your camera—this stretch is one of America’s finest coastal drives!",
"refusal": null,
"role": "assistant"
}
}
],
"created": 1777319524,
"gatewayMetadata": {
"keySource": "Unified"
},
"id": "chatcmpl-DZMHsVe39soRjpmDmECvFIoQCf6wr",
"model": "o3-2025-04-16",
"object": "chat.completion",
"service_tier": "default",
"system_fingerprint": null,
"usage": {
"completion_tokens": 1844,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 128,
"rejected_prediction_tokens": 0
},
"prompt_tokens": 76,
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
},
"total_tokens": 1920
}
}
</details>
<details>
<summary>Creative Writing — Longer completion for creative output</summary>
const response = await env.AI.run(
'openai/o3',
{
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/o3",
"max_completion_tokens": 8192,
"messages": [
{
"content": "Write a short story opening about a detective finding an unusual clue.",
"role": "user"
}
]
}'
Detective Lila Navarro crouched beside the overturned rowboat, lantern light trembling across the damp boards. The crime scene smelled of salt, river mud, and something sweeter—freshly ground cinnamon. That scent didn’t belong anywhere near the derelict wharf, yet here it lingered, strongest beneath one splintered plank. She wedged her penknife into the crack and lifted. Nestled in the dark hollow was a single, spotless chess pawn carved from cinnamon bark, its base stamped with today’s date. Lila straightened, pulse quickening. Whoever killed the dock watchman hadn’t just left a calling card; they’d seasoned the night with a puzzle only she would taste.
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"annotations": [],
"content": "Detective Lila Navarro crouched beside the overturned rowboat, lantern light trembling across the damp boards. The crime scene smelled of salt, river mud, and something sweeter—freshly ground cinnamon. That scent didn’t belong anywhere near the derelict wharf, yet here it lingered, strongest beneath one splintered plank. She wedged her penknife into the crack and lifted. Nestled in the dark hollow was a single, spotless chess pawn carved from cinnamon bark, its base stamped with today’s date. Lila straightened, pulse quickening. Whoever killed the dock watchman hadn’t just left a calling card; they’d seasoned the night with a puzzle only she would taste.",
"refusal": null,
"role": "assistant"
}
}
],
"created": 1777319534,
"gatewayMetadata": {
"keySource": "Unified"
},
"id": "chatcmpl-DZMI2T4AGhgxBOrHO2qbtI0kqcaKK",
"model": "o3-2025-04-16",
"object": "chat.completion",
"service_tier": "default",
"system_fingerprint": null,
"usage": {
"completion_tokens": 160,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0,
"rejected_prediction_tokens": 0
},
"prompt_tokens": 19,
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
},
"total_tokens": 179
}
}
</details>
<details>
<summary>Streaming Response — Enable streaming for real-time output</summary>
const response = await env.AI.run(
'openai/o3',
{
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/o3",
"messages": [
{
"content": "Explain the concept of recursion with a simple example.",
"role": "user"
}
],
"stream": true,
"stream_options": {
"include_usage": true
}
}'
Recursion is a problem-solving technique in which a function (or procedure) solves a task by calling itself on smaller or simpler parts of the original problem. Each self-call works on a reduced input until a condition is met that stops further calls; this stopping condition is called the base case.
Why it works:
1. Every call handles only a small piece of the work.
2. The base case guarantees the chain of calls eventually ends.
3. After the base case is reached, the results “bubble back” through the earlier calls to build the final answer.
Simple example: computing the factorial of a non-negative integer n (written n!).
Factorial definition:
• n! = n × (n − 1) × (n − 2) × … × 2 × 1
• 0! is defined as 1.
Recursive idea:
– Base case: 0! = 1 (also 1! = 1).
– Recursive step: n! = n × (n − 1)! for n > 0.
Python-like pseudocode:
```
def factorial(n):
if n == 0: # base case
return 1
else: # recursive case
return n * factorial(n - 1)
```
How factorial(4) is evaluated:
1. factorial(4) = 4 × factorial(3)
2. factorial(3) = 3 × factorial(2)
3. factorial(2) = 2 × factorial(1)
4. factorial(1) = 1 × factorial(0)
5. factorial(0) = 1 ← base case reached
Now the results return:
– factorial(1) = 1 × 1 = 1
– factorial(2) = 2 × 1 = 2
– factorial(3) = 3 × 2 = 6
– factorial(4) = 4 × 6 = 24
Thus factorial(4) = 24.
Key points to remember:
• A recursive function must have at least one base case.
• Each recursive call should bring the problem closer to that base case.
• Recursion often leads to concise, readable solutions for problems that exhibit self-similar structure (e.g., factorial, Fibonacci numbers, tree traversal).
[
{
"choices": [
{
"delta": {
"content": "",
"refusal": null,
"role": "assistant"
},
"finish_reason": null,
"index": 0
}
],
"created": 1777319539,
"id": "chatcmpl-DZMI7UOwfhRHx1WTlcRkuP5IAox0f",
"model": "o3-2025-04-16",
"obfuscation": "6M1dnR1hOq2Q8",
"object": "chat.completion.chunk",
"service_tier": "default",
"system_fingerprint": null,
"usage": null
},
{
"choices": [
{
"delta": {
"content": "Rec"
},
"finish_reason": null,
"index": 0
}
],
"created": 1777319539,
"id": "chatcmpl-DZMI7UOwfhRHx1WTlcRkuP5IAox0f",
"model": "o3-2025-04-16",
"obfuscation": "C4AaX2uB3c8I",
"object": "chat.completion.chunk",
"service_tier": "default",
"system_fingerprint": null,
"usage": null
},
"... 507 more chunks omitted ...",
{
"choices": [],
"created": 1777319539,
"id": "chatcmpl-DZMI7UOwfhRHx1WTlcRkuP5IAox0f",
"model": "o3-2025-04-16",
"obfuscation": "EueFN2OzMKtz",
"object": "chat.completion.chunk",
"service_tier": "default",
"system_fingerprint": null,
"usage": {
"completion_tokens": 525,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0,
"rejected_prediction_tokens": 0
},
"prompt_tokens": 16,
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
},
"total_tokens": 541
}
}
]
