GPT-5.4 pro
Text Generation • OpenAI
openai/gpt-5.4-pro
- Third-party
- Zero data retention
GPT-5.4 pro uses OpenAI's Responses API with built-in tools, improved reasoning, and stateful context management.
| Model Info | |
|---|---|
| Context Window ↗ | 1,000,000 tokens |
| Terms and License | link ↗ |
| More information | link ↗ |
| Zero data retention | Yes |
| Request formats | Responses |
| Pricing | <ul><li>Input (per 1M tokens)$30.00</li><li>Output (per 1M tokens)$180.00</li></ul> |
Usage
const response = await env.AI.run(
'openai/gpt-5.4-pro',
{ input: 'What are the three laws of thermodynamics?' },
)
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.4-pro",
"input": "What are the three laws of thermodynamics?"
}'
The **three laws of thermodynamics** usually mean:
1. **First Law — Conservation of Energy**
Energy cannot be created or destroyed, only transferred or transformed.
- In thermodynamics: the change in a system’s internal energy equals heat added to the system minus work done by the system.
2. **Second Law — Entropy Increases**
In any natural process, the total entropy of an isolated system tends to increase.
- This means energy spontaneously spreads out, and no heat engine can be 100% efficient.
- Heat naturally flows from hot objects to cold ones, not the reverse without input of work.
3. **Third Law — Entropy at Absolute Zero**
As temperature approaches **absolute zero** (0 K), the entropy of a perfect crystal approaches zero.
- A consequence is that absolute zero cannot be reached in a finite number of steps.
Small note: thermodynamics also has a **Zeroth Law**, which is often listed before these:
- If system A is in thermal equilibrium with B, and B is in thermal equilibrium with C, then A is in thermal equilibrium with C.
- This is the basis for the concept of **temperature**.
If you want, I can also give a **one-line intuitive version** of each law.
{
"background": false,
"billing": {
"payer": "developer"
},
"completed_at": 1777054203,
"created_at": 1777054122,
"error": null,
"frequency_penalty": 0,
"gatewayMetadata": {
"keySource": "Unified"
},
"id": "resp_00272dd8da5b37c90169ebb1aaeb288194a6e5ddeb7bb03dc8",
"incomplete_details": null,
"instructions": null,
"max_output_tokens": null,
"max_tool_calls": null,
"metadata": {},
"model": "gpt-5.4-pro-2026-03-05",
"moderation": null,
"object": "response",
"output": [
{
"id": "rs_00272dd8da5b37c90169ebb1faf90c81948fd9a67a37b4c209",
"summary": [],
"type": "reasoning"
},
{
"content": [
{
"annotations": [],
"logprobs": [],
"text": "The **three laws of thermodynamics** usually mean:\n\n1. **First Law — Conservation of Energy** \n Energy cannot be created or destroyed, only transferred or transformed. \n - In thermodynamics: the change in a system’s internal energy equals heat added to the system minus work done by the system.\n\n2. **Second Law — Entropy Increases** \n In any natural process, the total entropy of an isolated system tends to increase. \n - This means energy spontaneously spreads out, and no heat engine can be 100% efficient.\n - Heat naturally flows from hot objects to cold ones, not the reverse without input of work.\n\n3. **Third Law — Entropy at Absolute Zero** \n As temperature approaches **absolute zero** (0 K), the entropy of a perfect crystal approaches zero. \n - A consequence is that absolute zero cannot be reached in a finite number of steps.\n\nSmall note: thermodynamics also has a **Zeroth Law**, which is often listed before these:\n- If system A is in thermal equilibrium with B, and B is in thermal equilibrium with C, then A is in thermal equilibrium with C. \n- This is the basis for the concept of **temperature**.\n\nIf you want, I can also give a **one-line intuitive version** of each law.",
"type": "output_text"
}
],
"id": "msg_00272dd8da5b37c90169ebb1fafad0819488ef71fbebf8527a",
"phase": "final_answer",
"role": "assistant",
"status": "completed",
"type": "message"
}
],
"parallel_tool_calls": true,
"presence_penalty": 0,
"previous_response_id": null,
"prompt_cache_key": null,
"prompt_cache_retention": "in_memory",
"reasoning": {
"effort": "medium",
"summary": null
},
"safety_identifier": null,
"service_tier": "default",
"status": "completed",
"store": false,
"temperature": 1,
"text": {
"format": {
"type": "text"
},
"verbosity": "medium"
},
"tool_choice": "auto",
"tools": [],
"top_logprobs": 0,
"top_p": 0.98,
"truncation": "disabled",
"usage": {
"input_tokens": 15,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 342,
"output_tokens_details": {
"reasoning_tokens": 67
},
"total_tokens": 357
},
"user": null
}
Examples
<details>
<summary>With Instructions — Using instructions to set context</summary>
const response = await env.AI.run(
'openai/gpt-5.4-pro',
{
input: 'How do I read a JSON file in Python?',
instructions: 'You are a helpful coding assistant specializing in Python.',
},
)
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.4-pro",
"input": "How do I read a JSON file in Python?",
"instructions": "You are a helpful coding assistant specializing in Python."
}'
Use Python’s built-in `json` module.
### Read a JSON file into a Python object
```python
import json
with open("data.json", "r", encoding="utf-8") as f:
data = json.load(f)
print(data)
```
### What you get back
`json.load()` converts JSON into normal Python types:
- JSON object → `dict`
- JSON array → `list`
- JSON string → `str`
- JSON number → `int` / `float`
- JSON true/false → `True` / `False`
- JSON null → `None`
### Example
If `data.json` contains:
```json
{
"name": "Alice",
"age": 30,
"skills": ["Python", "SQL"]
}
```
Then:
```python
import json
with open("data.json", "r", encoding="utf-8") as f:
data = json.load(f)
print(data["name"]) # Alice
print(data["skills"]) # ['Python', 'SQL']
```
### Handle errors safely
```python
import json
try:
with open("data.json", "r", encoding="utf-8") as f:
data = json.load(f)
except FileNotFoundError:
print("File not found.")
except json.JSONDecodeError:
print("Invalid JSON.")
```
### If you already have JSON as a string
Use `json.loads()` instead:
```python
import json
text = '{"name": "Alice", "age": 30}'
data = json.loads(text)
print(data)
```
If you want, I can also show how to **write JSON back to a file**.
{
"background": false,
"billing": {
"payer": "developer"
},
"completed_at": 1777054145,
"created_at": 1777054123,
"error": null,
"frequency_penalty": 0,
"gatewayMetadata": {
"keySource": "Unified"
},
"id": "resp_00e5a81e42bf0bda0169ebb1ab449c8190a0d57802b4aebebd",
"incomplete_details": null,
"instructions": "You are a helpful coding assistant specializing in Python.",
"max_output_tokens": null,
"max_tool_calls": null,
"metadata": {},
"model": "gpt-5.4-pro-2026-03-05",
"moderation": null,
"object": "response",
"output": [
{
"id": "rs_00e5a81e42bf0bda0169ebb1c0e57881909eaf01efa0557a43",
"summary": [],
"type": "reasoning"
},
{
"content": [
{
"annotations": [],
"logprobs": [],
"text": "Use Python’s built-in `json` module.\n\n### Read a JSON file into a Python object\n```python\nimport json\n\nwith open(\"data.json\", \"r\", encoding=\"utf-8\") as f:\n data = json.load(f)\n\nprint(data)\n```\n\n### What you get back\n`json.load()` converts JSON into normal Python types:\n\n- JSON object → `dict`\n- JSON array → `list`\n- JSON string → `str`\n- JSON number → `int` / `float`\n- JSON true/false → `True` / `False`\n- JSON null → `None`\n\n### Example\nIf `data.json` contains:\n```json\n{\n \"name\": \"Alice\",\n \"age\": 30,\n \"skills\": [\"Python\", \"SQL\"]\n}\n```\n\nThen:\n```python\nimport json\n\nwith open(\"data.json\", \"r\", encoding=\"utf-8\") as f:\n data = json.load(f)\n\nprint(data[\"name\"]) # Alice\nprint(data[\"skills\"]) # ['Python', 'SQL']\n```\n\n### Handle errors safely\n```python\nimport json\n\ntry:\n with open(\"data.json\", \"r\", encoding=\"utf-8\") as f:\n data = json.load(f)\nexcept FileNotFoundError:\n print(\"File not found.\")\nexcept json.JSONDecodeError:\n print(\"Invalid JSON.\")\n```\n\n### If you already have JSON as a string\nUse `json.loads()` instead:\n```python\nimport json\n\ntext = '{\"name\": \"Alice\", \"age\": 30}'\ndata = json.loads(text)\nprint(data)\n```\n\nIf you want, I can also show how to **write JSON back to a file**.",
"type": "output_text"
}
],
"id": "msg_00e5a81e42bf0bda0169ebb1c0e7608190b3928d22f252a21a",
"phase": "final_answer",
"role": "assistant",
"status": "completed",
"type": "message"
}
],
"parallel_tool_calls": true,
"presence_penalty": 0,
"previous_response_id": null,
"prompt_cache_key": null,
"prompt_cache_retention": "in_memory",
"reasoning": {
"effort": "medium",
"summary": null
},
"safety_identifier": null,
"service_tier": "default",
"status": "completed",
"store": false,
"temperature": 1,
"text": {
"format": {
"type": "text"
},
"verbosity": "medium"
},
"tool_choice": "auto",
"tools": [],
"top_logprobs": 0,
"top_p": 0.98,
"truncation": "disabled",
"usage": {
"input_tokens": 30,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 397,
"output_tokens_details": {
"reasoning_tokens": 35
},
"total_tokens": 427
},
"user": null
}
</details>
<details>
<summary>Multi-turn Conversation — Continuing a conversation with message array</summary>
const response = await env.AI.run(
'openai/gpt-5.4-pro',
{
input: [
{
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, name three good stops in one short sentence each.', role: 'user' },
],
max_output_tokens: 16000,
},
)
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.4-pro",
"input": [
{
"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, name three good stops in one short sentence each.",
"role": "user"
}
],
"max_output_tokens": 16000
}'
