Kimi K3·续

{
  "id": "chatcmpl-6a59237a703baa4f421e6187",
  "object": "chat.completion",
  "created": 1784226682,
  "model": "moonshotai/kimi-k3",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "# Proof that √2 is irrational\n\n**Theorem.** √2 is irrational.\n\n**Proof.** We proceed by contradiction. Suppose √2 is rational. Then it can be written as a fraction in lowest terms:\n\n$$\\sqrt{2} = \\frac{a}{b}$$\n\nwhere $a$ and $b$ are integers, $b \\neq 0$, and $\\gcd(a, b) = 1$ (meaning $a$ and $b$ share no common factor).\n\n**Step 1: Square both sides.**\n\n$$2 = \\frac{a^2}{b^2} \\implies a^2 = 2b^2$$\n\nSo $a^2$ is even. This forces $a$ itself to be even, because the square of an odd number is odd: if $a = 2k+1$, then $a^2 = 4k^2 + 4k + 1$, which is odd. Hence we can write:\n\n$$a = 2k \\quad \\text{for some integer } k$$\n\n**Step 2: Substitute back.**\n\n$$(2k)^2 = 2b^2 \\implies 4k^2 = 2b^2 \\implies b^2 = 2k^2$$\n\nSo $b^2$ is even, and by the same reasoning as above, $b$ must be even.\n\n**Step 3: Reach a contradiction.**\n\nWe have shown that both $a$ and $b$ are even, so they share a common factor of 2. But this contradicts our assumption that $\\gcd(a, b) = 1$.\n\n**Conclusion.** The assumption that √2 is rational leads to a contradiction. Therefore, √2 is irrational. $\\blacksquare$\n\n---\n\n**Remark on the key step:** The entire proof hinges on the fact that *every* rational number has a unique fully-reduced form. The equation $a^2 = 2b^2$ is impossible for reduced fractions because the factor 2 appears an even number of times on the left (in the prime factorization of $a^2$) but an odd number of times on the right (in $2b^2$) — this is essentially the contradiction in disguise.",
        "reasoning_content": "The user wants a proof that √2 is irrational. This is a classic proof by contradiction. Let me write it out clearly and rigorously.\n\nThe standard proof:\n\n**Claim:** √2 is irrational.\n\n**Proof (by contradiction):**\n\nSuppose, for the sake of contradiction, that √2 is rational. Then we can write:\n√2 = a/b\n\nwhere a and b are integers with b ≠ 0, and we can assume the fraction is in lowest terms, meaning gcd(a, b) = 1 (a and b share no common factors).\n\nSquaring both sides:\n2 = a²/b²\n2b² = a²\n\nThis means a² is even, which implies a is even (because if a were odd, a² would be odd — the square of an odd number (2k+1)² = 4k² + 4k + 1 = 2(2k² + 2k) + 1 is odd).\n\nSo a = 2k for some integer k.\n\nSubstituting:\n2b² = (2k)² = 4k²\nb² = 2k²\n\nThis means b² is even, which implies b is even (by the same reasoning).\n\nBut now both a and b are even, meaning they share a common factor of 2. This contradicts our assumption that gcd(a, b) = 1 (that the fraction was in lowest terms).\n\nTherefore, our initial assumption that √2 is rational must be false. Hence √2 is irrational. ∎\n\nI should also justify the lemma that if a² is even then a is even. I did that inline above.\n\nLet me format this nicely with clear structure. This is a math proof request, so headers or clear proof structure would be appropriate. I'll use a theorem-proof format. Should be moderately concise but complete and rigorous. I can use some markdown formatting since this appears to be a chat interface where markdown renders.\n\nI'll structure it:\n1. Statement\n2. Proof setup (contradiction)\n3. Key steps\n4. Contradiction\n5. Conclusion\n\nMaybe include the lemma explicitly. Let me write it well."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 96,
    "completion_tokens": 932,
    "total_tokens": 1028,
    "cached_tokens": 96,
    "completion_tokens_details": {
      "reasoning_tokens": 450
    },
    "prompt_tokens_details": {
      "cached_tokens": 96
    }
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}

</details>

<details>

<summary>Tool Choice Required — Force a tool call on the first turn with tool_choice</summary>

const response = await env.AI.run(
  'moonshotai/kimi-k3',
  {
    messages: [{ content: 'What is the weather in San Francisco today?', role: 'user' }],
    tool_choice: 'required',
    tools: [
      {
        function: {
          description: 'Get the weather for a city',
          name: 'get_weather',
          parameters: {
            properties: { city: { type: 'string' } },
            required: ['city'],
            type: 'object',
          },
        },
        type: 'function',
      },
    ],
  },
)
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": "moonshotai/kimi-k3",
  "messages": [
    {
      "content": "What is the weather in San Francisco today?",
      "role": "user"
    }
  ],
  "tool_choice": "required",
  "tools": [
    {
      "function": {
        "description": "Get the weather for a city",
        "name": "get_weather",
        "parameters": {
          "properties": {
            "city": {
              "type": "string"
            }
          },
          "required": [
            "city"
          ],
          "type": "object"
        }
      },
      "type": "function"
    }
  ]
}'
I'll check the weather in San Francisco for you.
{
  "id": "chatcmpl-6a5923933594b7665d11ae23",
  "object": "chat.completion",
  "created": 1784226696,
  "model": "moonshotai/kimi-k3",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I'll check the weather in San Francisco for you.",
        "tool_calls": [
          {
            "index": 0,
            "id": "get_weather_0",
            "type": "function",
            "function": {
              "name": "get_weather",
              "arguments": "{\"city\":\"San Francisco\"}"
            }
          }
        ],
        "reasoning_content": "The user is asking about the weather in San Francisco today. I have a `get_weather` tool available. I should call it with the city \"San Francisco\"."
      },
      "finish_reason": "tool_calls"
    }
  ],
  "usage": {
    "prompt_tokens": 208,
    "completion_tokens": 98,
    "total_tokens": 306,
    "cached_tokens": 208,
    "completion_tokens_details": {
      "reasoning_tokens": 35
    },
    "prompt_tokens_details": {
      "cached_tokens": 208
    }
  },
  "gatewayMetadata": {
    "keySource": "Unified"
  }
}

</details>

<details>

<summary>Streaming Response — Enable streaming for real-time output</summary>

const response = await env.AI.run(
  'moonshotai/kimi-k3',
  { messages: [{ content: 'Explain why the sky is blue.', role: 'user' }], stream: 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": "moonshotai/kimi-k3",
  "messages": [
    {
      "content": "Explain why the sky is blue.",
      "role": "user"
    }
  ],
  "stream": true
}'
The sky is blue because of a phenomenon called **Rayleigh scattering**, which describes how light interacts with tiny particles—in this case, the gas molecules in Earth's atmosphere.

Here's the process, step by step:

1. **Sunlight contains all colors.** Although it looks white, sunlight is actually a mix of every color of visible light, each with a different wavelength. Red light has long wavelengths (~700 nm), while blue and violet have short ones (~400–450 nm).

2. **Air molecules scatter light.** Nitrogen and oxygen molecules are far smaller than the wavelengths of visible light. When light strikes particles this tiny, it gets scattered in all directions.

3. **Shorter wavelengths scatter much more strongly.** Rayleigh scattering intensity is proportional to 1/λ⁴, meaning blue light is scattered roughly 5–6 times more than red light. As sunlight streams through the atmosphere, blue light gets bounced all over the place—so no matter where you look in the sky, scattered blue light is reaching your eyes.

**Why not violet?** Violet light scatters even more than blue, but the sun emits less of it, and our eyes are less sensitive to it. The combined effect is that we perceive the sky as blue.

**A nice confirmation:** the same physics explains sunsets. When the sun is low on the horizon, its light travels through much more atmosphere to reach you. By the time it arrives, most of the blue has been scattered away, leaving the reds and oranges behind.

As a bonus: on the Moon, which has no atmosphere, the daytime sky is black—there's nothing to scatter the sunlight at all.
[
  {
    "id": "chatcmpl-6a59238b8a290065f7c0f652",
    "object": "chat.completion.chunk",
    "created": 1784226700,
    "model": "kimi-k3",
    "choices": [
      {
        "index": 0,
        "delta": {
          "role": "assistant",
          "content": ""
        },
        "finish_reason": null
      }
    ],
    "system_fingerprint": "fpv0_0d4e787e"
  },
  {
    "id": "chatcmpl-6a59238b8a290065f7c0f652",
    "object": "chat.completion.chunk",
    "created": 1784226700,
    "model": "kimi-k3",
    "choices": [
      {
        "index": 0,
        "delta": {
          "reasoning_content": "The"
        },
        "finish_reason": null
      }
    ],
    "system_fingerprint": "fpv0_0d4e787e"
  },
  "... 1315 more chunks omitted ...",
  {
    "id": "chatcmpl-6a59238b8a290065f7c0f652",
    "object": "chat.completion.chunk",
    "created": 1784226700,
    "model": "kimi-k3",
    "choices": [],
    "usage": {
      "prompt_tokens": 92,
      "completion_tokens": 1331,
      "total_tokens": 1423,
      "cached_tokens": 92,
      "completion_tokens_details": {
        "reasoning_tokens": 983
      },
      "prompt_tokens_details": {
        "cached_tokens": 92
      }
    }
  }
]

</details>

Parameters

▶messages[]

arrayrequired

temperature

numberminimum: 0maximum: 2

max_tokens

numberexclusiveMinimum: 0

max_completion_tokens

numberexclusiveMinimum: 0

top_p

numberminimum: 0maximum: 1

frequency_penalty

numberminimum: -2maximum: 2

presence_penalty

numberminimum: -2maximum: 2

stream

boolean

▶stream_options{}

object

▶tools[]

array

tool_choice

response_format

▶modalities[]

array

▶audio{}

object

reasoning_effort

stringOptional reasoning control; availability and accepted values are model-dependent.

id

string

object

string

created

number

model

string

▶choices[]

array

▶usage{}

object

API Schemas (Raw)

Input Open Download

Output Open Download

Was this helpful?

YesNo

On this page

Kimi K3·续 - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ai/models/moonshotai/kimi-k3/#page","headline":"Kimi K3","description":"Kimi K3 is Moonshot's flagship 2.8 trillion-parameter model, built on Kimi Delta Attention (a hybrid linear attention mechanism) with Attention Residuals. It offers native visual understanding, always-on reasoning, and a 1M-token context window for long-horizon coding, knowledge work, and deep reasoning tasks.","url":"https://developers.cloudflare.com/ai/models/moonshotai/kimi-k3/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: OpenAI's flagship GPT model for complex tasks with a million-token context window. title: GPT-4.1 image: https://developers.cloudflare.com/og-docs.png


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt
Use this file to discover all available pages before exploring further.

OpenAI logo