Grok 4.3

Text Generation • xAI

xai/grok-4.3

  • Third-party
  • Zero data retention

xAI's Grok 4.3 model with a 1M-token context window and strong agentic tool calling with minimal hallucinations. Accepts text and image inputs, and supports function calling, structured outputs, and configurable reasoning effort (none, low, medium, high).

Model Info
Context Window ↗ 1,000,000 tokens
Terms and License link ↗
More information link ↗
Zero data retention Yes
Request formats Chat Completions
Pricing <ul><li>Input (per 1M tokens)$1.25</li><li>Output (per 1M tokens)$2.50</li><li>Cached input (per 1M tokens)$0.20</li></ul>

Usage

const response = await env.AI.run(
  'xai/grok-4.3',
  { 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": "xai/grok-4.3",
  "messages": [
    {
      "content": "What are the three laws of thermodynamics?",
      "role": "user"
    }
  ]
}'
The three main laws of thermodynamics (often called the First, Second, and Third Laws) are fundamental principles describing energy, entropy, and absolute temperature. (A "Zeroth Law" was added later to define thermal equilibrium and temperature, but it is not usually counted among the classic three.)

**First Law (Conservation of Energy)**  
Energy cannot be created or destroyed, only converted from one form to another or transferred. For a closed system, the change in internal energy \(\Delta U\) equals heat added to the system \(Q\) minus work done by the system \(W\):  
\[
\Delta U = Q - W
\]  
(This is essentially a statement of energy conservation.)

**Second Law (Entropy and Direction of Processes)**  
The total entropy of an isolated system (or the universe) always increases over time for irreversible processes and remains constant for reversible ones. Heat naturally flows from hotter to colder bodies, and not all heat can be converted into work without losses. Mathematically, for any real process:  
\[
\Delta S_{\text{universe}} > 0
\]  
(where \(S\) is entropy). This law sets the arrow of time and limits the efficiency of heat engines.

**Third Law (Absolute Zero)**  
As the temperature of a perfect crystal approaches absolute zero (0 K or −273.15 °C), its entropy approaches a minimum value (usually taken as zero). This implies that absolute zero is unattainable in a finite number of steps, and it becomes impossible to remove all thermal energy from a system.  
\[
\lim_{T \to 0} S = 0 \quad \text{(for a perfect crystal)}
\]

These laws apply to macroscopic systems and form the foundation of classical thermodynamics.
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "The three main laws of thermodynamics (often called the First, Second, and Third Laws) are fundamental principles describing energy, entropy, and absolute temperature. (A \"Zeroth Law\" was added later to define thermal equilibrium and temperature, but it is not usually counted among the classic three.)\n\n**First Law (Conservation of Energy)**  \nEnergy cannot be created or destroyed, only converted from one form to another or transferred. For a closed system, the change in internal energy \\(\\Delta U\\) equals heat added to the system \\(Q\\) minus work done by the system \\(W\\):  \n\\[\n\\Delta U = Q - W\n\\]  \n(This is essentially a statement of energy conservation.)\n\n**Second Law (Entropy and Direction of Processes)**  \nThe total entropy of an isolated system (or the universe) always increases over time for irreversible processes and remains constant for reversible ones. Heat naturally flows from hotter to colder bodies, and not all heat can be converted into work without losses. Mathematically, for any real process:  \n\\[\n\\Delta S_{\\text{universe}} > 0\n\\]  \n(where \\(S\\) is entropy). This law sets the arrow of time and limits the efficiency of heat engines.\n\n**Third Law (Absolute Zero)**  \nAs the temperature of a perfect crystal approaches absolute zero (0 K or −273.15 °C), its entropy approaches a minimum value (usually taken as zero). This implies that absolute zero is unattainable in a finite number of steps, and it becomes impossible to remove all thermal energy from a system.  \n\\[\n\\lim_{T \\to 0} S = 0 \\quad \\text{(for a perfect crystal)}\n\\]\n\nThese laws apply to macroscopic systems and form the foundation of classical thermodynamics.",
        "reasoning_content": "The user is asking for the three laws of thermodynamics. There are actually four laws, including the zeroth law, but commonly people refer to the first, second, and third laws. I should be accurate.\n\n...",
        "refusal": null,
        "role": "assistant"
      }
    }
  ],
  "created": 1778620601,
  "gatewayMetadata": {
    "keySource": "Unified"
  },
  "id": "aa6188e7-7a27-9a26-ae62-4254a81c52a4",
  "model": "grok-4.3",
  "object": "chat.completion",
  "system_fingerprint": "fp_655c34cb90f68992",
  "usage": {
    "completion_tokens": 351,
    "completion_tokens_details": {
      "accepted_prediction_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 328,
      "rejected_prediction_tokens": 0
    },
    "cost_in_usd_ticks": 17356000,
    "num_sources_used": 0,
    "prompt_tokens": 138,
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 128,
      "image_tokens": 0,
      "text_tokens": 138
    },
    "total_tokens": 817
  }
}

Examples

<details>

<summary>With System Message — Using a system message to set context</summary>

const response = await env.AI.run(
  'xai/grok-4.3',
  {
    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": "xai/grok-4.3",
  "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, use the built-injson` module. Here's the standard way:

```python import json