o3-mini·续

</details>

<details>

<summary>Creative Writing — Longer completion for creative output</summary>

const response = await env.AI.run(
  'openai/o3-mini',
  {
    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-mini",
  "max_completion_tokens": 8192,
  "messages": [
    {
      "content": "Write a short story opening about a detective finding an unusual clue.",
      "role": "user"
    }
  ]
}'
Detective Elena Marquez stood motionless in the dim glow of the abandoned warehouse, her eyes fixated on a peculiar object half-buried in layers of dust and cobwebs. Amidst scattered papers and defaced photographs, the unusual clue—a small porcelain figurine with an ethereal, almost luminescent crack running down its side—seemed to beckon her closer. Its delicate features, strangely out of place in this grim setting, whispered secrets of a long-forgotten past and hinted at connections far deeper than any ordinary case.

As she carefully lifted the figurine with gloved hands, Elena noted an inscription faintly etched along its base, its characters reminiscent of an undiscovered language. The artifact pulsed with an energy that both unnerved and fascinated her, a silent promise that solving its mystery might unravel the threads of a labyrinthine conspiracy. In that hushed moment, the detective realized that this was no random piece of debris—it was an intentional breadcrumb leading to a truth hidden beneath layers of time and deceit.
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "annotations": [],
        "content": "Detective Elena Marquez stood motionless in the dim glow of the abandoned warehouse, her eyes fixated on a peculiar object half-buried in layers of dust and cobwebs. Amidst scattered papers and defaced photographs, the unusual clue—a small porcelain figurine with an ethereal, almost luminescent crack running down its side—seemed to beckon her closer. Its delicate features, strangely out of place in this grim setting, whispered secrets of a long-forgotten past and hinted at connections far deeper than any ordinary case.\n\nAs she carefully lifted the figurine with gloved hands, Elena noted an inscription faintly etched along its base, its characters reminiscent of an undiscovered language. The artifact pulsed with an energy that both unnerved and fascinated her, a silent promise that solving its mystery might unravel the threads of a labyrinthine conspiracy. In that hushed moment, the detective realized that this was no random piece of debris—it was an intentional breadcrumb leading to a truth hidden beneath layers of time and deceit.",
        "refusal": null,
        "role": "assistant"
      }
    }
  ],
  "created": 1777319815,
  "gatewayMetadata": {
    "keySource": "Unified"
  },
  "id": "chatcmpl-DZMMZ0kiOSZsAi3ZVIKwPfnLDiAIz",
  "model": "o3-mini-2025-01-31",
  "object": "chat.completion",
  "service_tier": "default",
  "system_fingerprint": "fp_7a15bf1b39",
  "usage": {
    "completion_tokens": 414,
    "completion_tokens_details": {
      "accepted_prediction_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 192,
      "rejected_prediction_tokens": 0
    },
    "prompt_tokens": 19,
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    },
    "total_tokens": 433
  }
}

</details>

<details>

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

const response = await env.AI.run(
  'openai/o3-mini',
  {
    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-mini",
  "messages": [
    {
      "content": "Explain the concept of recursion with a simple example.",
      "role": "user"
    }
  ],
  "stream": true,
  "stream_options": {
    "include_usage": true
  }
}'
Recursion is a technique in programming where a function calls itself to solve a problem. The function breaks the problem into smaller, similar subproblems until it reaches a simple case that can be solved directly—this is known as the base case. Once the base case is reached, the recursion stops, and the solutions to the smaller subproblems are combined to solve the original problem.

A simple example is calculating the factorial of a number. The factorial of a non-negative integer n (written as n!) is defined as:

n! = n × (n-1) × (n-2) × ... × 1

By definition, 0! is 1. Using recursion, you can express the factorial function as:

factorial(n) = n × factorial(n-1)

with the base case:

factorial(0) = 1

Here’s a step-by-step explanation:

1. If n is 0, return 1 (base case).
2. Otherwise, return n multiplied by the factorial of (n-1).

For example, to compute 3!:
  • factorial(3) = 3 × factorial(2)
  • factorial(2) = 2 × factorial(1)
  • factorial(1) = 1 × factorial(0)
  • factorial(0) = 1 (base case)

Working back up:
  • factorial(1) = 1 × 1 = 1
  • factorial(2) = 2 × 1 = 2
  • factorial(3) = 3 × 2 = 6

Thus, 3! equals 6.

This example illustrates how recursion solves a problem by simplifying it step by step until it reaches a solution.
[
  {
    "choices": [
      {
        "delta": {
          "content": "",
          "refusal": null,
          "role": "assistant"
        },
        "finish_reason": null,
        "index": 0
      }
    ],
    "created": 1777319820,
    "id": "chatcmpl-DZMMetd1XpZ1frdVc0o4T4L12OVXk",
    "model": "o3-mini-2025-01-31",
    "obfuscation": "zz38RTm3YrrY6",
    "object": "chat.completion.chunk",
    "service_tier": "default",
    "system_fingerprint": "fp_b5e0a50a2e",
    "usage": null
  },
  {
    "choices": [
      {
        "delta": {
          "content": "Rec"
        },
        "finish_reason": null,
        "index": 0
      }
    ],
    "created": 1777319820,
    "id": "chatcmpl-DZMMetd1XpZ1frdVc0o4T4L12OVXk",
    "model": "o3-mini-2025-01-31",
    "obfuscation": "Q2PVeG8xwBfH",
    "object": "chat.completion.chunk",
    "service_tier": "default",
    "system_fingerprint": "fp_b5e0a50a2e",
    "usage": null
  },
  "... 371 more chunks omitted ...",
  {
    "choices": [],
    "created": 1777319820,
    "id": "chatcmpl-DZMMetd1XpZ1frdVc0o4T4L12OVXk",
    "model": "o3-mini-2025-01-31",
    "obfuscation": "2wTYZNsXap",
    "object": "chat.completion.chunk",
    "service_tier": "default",
    "system_fingerprint": "fp_b5e0a50a2e",
    "usage": {
      "completion_tokens": 640,
      "completion_tokens_details": {
        "accepted_prediction_tokens": 0,
        "audio_tokens": 0,
        "reasoning_tokens": 256,
        "rejected_prediction_tokens": 0
      },
      "prompt_tokens": 16,
      "prompt_tokens_details": {
        "audio_tokens": 0,
        "cached_tokens": 0
      },
      "total_tokens": 656
    }
  }
]

</details>

Parameters

Schema variant

ResponsesChat Completions

▶input

one ofrequired

instructions

string

temperature

numberminimum: 0maximum: 2

max_output_tokens

numberexclusiveMinimum: 0

top_p

numberminimum: 0maximum: 1

stream

boolean

▶tools[]

array

tool_choice

▶text{}

object

▶reasoning{}

object

▶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

stringconst: response

created_at

number

model

string

▶output[]

array

output_text

string

status

stringenum: in_progress, completed, failed, incomplete

▶usage{}

object

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

o3-mini·续 - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ai/models/openai/o3-mini/#page","headline":"o3-mini","description":"o3-mini is the lightweight, low-cost reasoning variant of o3, well suited to quick analytical tasks at scale.","url":"https://developers.cloudflare.com/ai/models/openai/o3-mini/","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 fast, lightweight reasoning model optimized for multi-step problem solving at lower cost. title: o4-mini 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