o3-mini
Text Generation • OpenAI
openai/o3-mini
- Third-party
- Zero data retention
o3-mini is the lightweight, low-cost reasoning variant of o3, well suited to quick analytical tasks at scale.
| Model Info | |
|---|---|
| Context Window ↗ | 200,000 tokens |
| Terms and License | link ↗ |
| More information | link ↗ |
| Zero data retention | Yes |
| Request formats | Responses, Chat Completions |
| Pricing | <ul><li>Input (per 1M tokens)$1.10</li><li>Output (per 1M tokens)$4.40</li><li>Cached input (per 1M tokens)$0.55</li></ul> |
Usage
const response = await env.AI.run(
'openai/o3-mini',
{ messages: [{ content: 'What are the three laws of thermodynamics?', 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-mini",
"messages": [
{
"content": "What are the three laws of thermodynamics?",
"role": "user"
}
]
}'
There are a few ways people count the laws of thermodynamics, but a common approach (especially in basic texts) is to focus on these three:
1. First Law of Thermodynamics (Law of Energy Conservation)
• This law states that energy cannot be created or destroyed—only converted from one form to another. In a closed system, the total energy remains constant. For example, when you burn fuel, the chemical energy is converted into heat and work.
2. Second Law of Thermodynamics
• This law introduces the concept of entropy, a measure of disorder. It states that in any natural (irreversible) process, the total entropy of an isolated system increases (or remains constant in ideal reversible cases). This explains why heat flows spontaneously from hot to cold and why certain processes (like perpetual motion machines) are impossible.
3. Third Law of Thermodynamics
• The third law states that as the temperature of a system approaches absolute zero (0 Kelvin), the entropy of a perfect crystal approaches zero. This law implies that absolute zero is unattainable and provides a reference point for the measurement of entropy.
Note: There is also the Zeroth Law of Thermodynamics, which is sometimes considered foundational. It states that if two systems are each in thermal equilibrium with a third system, then they are in thermal equilibrium with each other. This law is crucial in defining temperature but is not always numbered among the “three” if one starts counting from the first law.
These laws together form the basis of classical thermodynamics, helping us understand energy flow, heat transfer, and the directionality of physical processes.
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"annotations": [],
"content": "There are a few ways people count the laws of thermodynamics, but a common approach (especially in basic texts) is to focus on these three:\n\n1. First Law of Thermodynamics (Law of Energy Conservation) \n • This law states that energy cannot be created or destroyed—only converted from one form to another. In a closed system, the total energy remains constant. For example, when you burn fuel, the chemical energy is converted into heat and work.\n\n2. Second Law of Thermodynamics \n • This law introduces the concept of entropy, a measure of disorder. It states that in any natural (irreversible) process, the total entropy of an isolated system increases (or remains constant in ideal reversible cases). This explains why heat flows spontaneously from hot to cold and why certain processes (like perpetual motion machines) are impossible.\n\n3. Third Law of Thermodynamics \n • The third law states that as the temperature of a system approaches absolute zero (0 Kelvin), the entropy of a perfect crystal approaches zero. This law implies that absolute zero is unattainable and provides a reference point for the measurement of entropy.\n\nNote: There is also the Zeroth Law of Thermodynamics, which is sometimes considered foundational. It states that if two systems are each in thermal equilibrium with a third system, then they are in thermal equilibrium with each other. This law is crucial in defining temperature but is not always numbered among the “three” if one starts counting from the first law.\n\nThese laws together form the basis of classical thermodynamics, helping us understand energy flow, heat transfer, and the directionality of physical processes.",
"refusal": null,
"role": "assistant"
}
}
],
"created": 1777319807,
"gatewayMetadata": {
"keySource": "Unified"
},
"id": "chatcmpl-DZMMRxtcAbZLwD8Nd6POej2jkkjhT",
"model": "o3-mini-2025-01-31",
"object": "chat.completion",
"service_tier": "default",
"system_fingerprint": "fp_4e608cacbe",
"usage": {
"completion_tokens": 851,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 512,
"rejected_prediction_tokens": 0
},
"prompt_tokens": 15,
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
},
"total_tokens": 866
}
}
Examples
<details>
<summary>With System Message — Using a system message to set context</summary>
const response = await env.AI.run(
'openai/o3-mini',
{
messages: [
{ content: 'You are a helpful coding assistant specializing in Python.', role: 'system' },
{ content: 'How do I read a JSON file in Python?', 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-mini",
"messages": [
{
"content": "You are a helpful coding assistant specializing in Python.",
"role": "system"
},
{
"content": "How do I read a JSON file in Python?",
"role": "user"
}
]
}'
To read a JSON file in Python, you can use the built-in json module. This module provides methods for encoding and decoding JSON data. Typically, you'll want to use the json.load() function to read and parse JSON data from a file. Here’s a simple step-by-step example:
1. Import the json module.
2. Open the JSON file using the with context manager (this automatically closes the file after you're done).
3. Use json.load() to parse the file.
Below is the complete example code:
--------------------------------------------------
import json
# Open the JSON file and load its content
with open('data.json', 'r') as file:
data = json.load(file)
# Now 'data' contains the JSON file content as a Python dictionary (or list, depending on JSON structure)
print(data)
--------------------------------------------------
Explanation:
• The with statement is used to open the file, which ensures that the file is properly closed even if an error occurs.
• The 'r' mode is specified to open the file in read mode.
• json.load(file) parses the JSON content and returns a Python object.
• The resulting data is stored in the variable data, which you can then work with as needed.
If you have any questions or need further assistance, feel free to ask!
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"annotations": [],
"content": "To read a JSON file in Python, you can use the built-in json module. This module provides methods for encoding and decoding JSON data. Typically, you'll want to use the json.load() function to read and parse JSON data from a file. Here’s a simple step-by-step example:\n\n1. Import the json module.\n2. Open the JSON file using the with context manager (this automatically closes the file after you're done).\n3. Use json.load() to parse the file.\n\nBelow is the complete example code:\n\n--------------------------------------------------\nimport json\n\n# Open the JSON file and load its content\nwith open('data.json', 'r') as file:\n data = json.load(file)\n\n# Now 'data' contains the JSON file content as a Python dictionary (or list, depending on JSON structure)\nprint(data)\n--------------------------------------------------\n\nExplanation:\n• The with statement is used to open the file, which ensures that the file is properly closed even if an error occurs.\n• The 'r' mode is specified to open the file in read mode.\n• json.load(file) parses the JSON content and returns a Python object.\n• The resulting data is stored in the variable data, which you can then work with as needed.\n\nIf you have any questions or need further assistance, feel free to ask!",
"refusal": null,
"role": "assistant"
}
}
],
"created": 1777319809,
"gatewayMetadata": {
"keySource": "Unified"
},
"id": "chatcmpl-DZMMT5z8IEzwWx4HmgAYT2WScVD5o",
"model": "o3-mini-2025-01-31",
"object": "chat.completion",
"service_tier": "default",
"system_fingerprint": "fp_7a15bf1b39",
"usage": {
"completion_tokens": 400,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 128,
"rejected_prediction_tokens": 0
},
"prompt_tokens": 30,
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
},
"total_tokens": 430
}
}
</details>
<details>
<summary>Multi-turn Conversation — Continuing a conversation with context</summary>
const response = await env.AI.run(
'openai/o3-mini',
{
max_completion_tokens: 8192,
messages: [
{
content: 'I need help planning a road trip from San Francisco to Los Angeles.',
role: 'user',
},
{
content:
"I'd be happy to help! The drive is about 380 miles and takes roughly 5-6 hours. Would you like suggestions for scenic routes or interesting stops along the way?",
role: 'assistant',
},
{ content: 'Yes, what are some good places to stop?', 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-mini",
"max_completion_tokens": 8192,
"messages": [
{
"content": "I need help planning a road trip from San Francisco to Los Angeles.",
"role": "user"
},
{
"content": "I'\''d be happy to help! The drive is about 380 miles and takes roughly 5-6 hours. Would you like suggestions for scenic routes or interesting stops along the way?",
"role": "assistant"
},
{
"content": "Yes, what are some good places to stop?",
"role": "user"
}
]
}'
Great! When planning a road trip along the scenic coast (California's Highway 1), here are some must-see stops between San Francisco and Los Angeles:
1. Santa Cruz:
• Enjoy the laid-back vibe at the Santa Cruz Beach Boardwalk.
• Take a stroll by the beach or check out the local shops and cafés downtown.
2. Monterey & Cannery Row:
• Visit the famous Monterey Bay Aquarium, a highlight of the area.
• Walk along Cannery Row and relish the coastal views or even take a local boat tour.
• If time allows, consider the 17-Mile Drive in nearby Pebble Beach for a fantastic coastline drive.
3. Carmel-by-the-Sea:
• This charming town offers art galleries, boutique shopping, and quaint cafés in a picturesque setting.
• Enjoy the beautiful white-sand Carmel Beach and a stroll through the fairy-tale village.
4. Big Sur:
• Drive through one of the most breathtaking stretches of coastline in the world.
• Stop at iconic landmarks like Bixby Creek Bridge or take in the views from Nepenthe.
• Enjoy a short hike or simply take in the ocean views over cliffs—just be sure to check road conditions, as parts of Highway 1 can be winding.
5. San Simeon/Hearst Castle:
• Explore Hearst Castle, a historic mansion with impressive architecture and art.
• Enjoy nearby coastal views and wildlife, including elephant seals which often hang out at the beaches.
6. Santa Barbara (Optional Stop):
• Once you start heading toward Los Angeles, a stop in Santa Barbara can be a relaxing break.
• Stroll through the downtown area, visit the historic Mission Santa Barbara or relax at the beach.
Depending on your schedule and interests, you can choose to spend more time in one area than another. For instance, if you're a nature lover, spending a day in Big Sur might be perfect for you. Alternatively, beer or foodie enthusiasts might enjoy more time exploring the eateries in Monterey or Santa Barbara.
Some additional tips:
• Always check for road conditions and parking information especially in Big Sur, as it can get busy on weekends.
• Consider making reservations at popular restaurants or attractions in advance.
• Pack some snacks and water, as some stretches between stops can be remote.
Would you like more detailed itineraries for any of these stops, or do you have specific interests (like hiking, dining, or cultural attractions) that we should highlight?
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"annotations": [],
"content": "Great! When planning a road trip along the scenic coast (California's Highway 1), here are some must-see stops between San Francisco and Los Angeles:\n\n1. Santa Cruz: \n • Enjoy the laid-back vibe at the Santa Cruz Beach Boardwalk. \n • Take a stroll by the beach or check out the local shops and cafés downtown.\n\n2. Monterey & Cannery Row: \n • Visit the famous Monterey Bay Aquarium, a highlight of the area. \n • Walk along Cannery Row and relish the coastal views or even take a local boat tour.\n • If time allows, consider the 17-Mile Drive in nearby Pebble Beach for a fantastic coastline drive.\n\n3. Carmel-by-the-Sea: \n • This charming town offers art galleries, boutique shopping, and quaint cafés in a picturesque setting. \n • Enjoy the beautiful white-sand Carmel Beach and a stroll through the fairy-tale village.\n\n4. Big Sur: \n • Drive through one of the most breathtaking stretches of coastline in the world. \n • Stop at iconic landmarks like Bixby Creek Bridge or take in the views from Nepenthe. \n • Enjoy a short hike or simply take in the ocean views over cliffs—just be sure to check road conditions, as parts of Highway 1 can be winding.\n\n5. San Simeon/Hearst Castle: \n • Explore Hearst Castle, a historic mansion with impressive architecture and art. \n • Enjoy nearby coastal views and wildlife, including elephant seals which often hang out at the beaches.\n\n6. Santa Barbara (Optional Stop): \n • Once you start heading toward Los Angeles, a stop in Santa Barbara can be a relaxing break. \n • Stroll through the downtown area, visit the historic Mission Santa Barbara or relax at the beach.\n\nDepending on your schedule and interests, you can choose to spend more time in one area than another. For instance, if you're a nature lover, spending a day in Big Sur might be perfect for you. Alternatively, beer or foodie enthusiasts might enjoy more time exploring the eateries in Monterey or Santa Barbara.\n\nSome additional tips: \n• Always check for road conditions and parking information especially in Big Sur, as it can get busy on weekends. \n• Consider making reservations at popular restaurants or attractions in advance. \n• Pack some snacks and water, as some stretches between stops can be remote.\n\nWould you like more detailed itineraries for any of these stops, or do you have specific interests (like hiking, dining, or cultural attractions) that we should highlight?",
"refusal": null,
"role": "assistant"
}
}
],
"created": 1777319813,
"gatewayMetadata": {
"keySource": "Unified"
},
"id": "chatcmpl-DZMMXgd7WUjV61fWbXbNNhOFEVnNB",
"model": "o3-mini-2025-01-31",
"object": "chat.completion",
"service_tier": "default",
"system_fingerprint": "fp_7a15bf1b39",
"usage": {
"completion_tokens": 917,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 384,
"rejected_prediction_tokens": 0
},
"prompt_tokens": 74,
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
},
"total_tokens": 991
}
}
