Example usage: (3)

print(factorial(5)) # Output: 120


In this example:
- The base case stops the recursion when \( n \) is 0.
- The recursive case reduces the problem by calling the `factorial` function with \( n-1 \), gradually approaching the base case. 
- Each call of the function adds a new layer to the call stack, and returning the result of each call unwinds the stack, culminating in the final result.
````

```json
[
  {
    "choices": [
      {
        "delta": {
          "content": "",
          "refusal": null,
          "role": "assistant"
        },
        "finish_reason": null,
        "index": 0,
        "logprobs": null
      }
    ],
    "created": 1777319831,
    "id": "chatcmpl-DZMMpD11GwQsD27xo2aEnxkId8PGM",
    "model": "gpt-4o-2024-08-06",
    "obfuscation": "BfwwVsWIvF4uTQ",
    "object": "chat.completion.chunk",
    "service_tier": "default",
    "system_fingerprint": "fp_6dd86a7be3",
    "usage": null
  },
  {
    "choices": [
      {
        "delta": {
          "content": "Rec"
        },
        "finish_reason": null,
        "index": 0,
        "logprobs": null
      }
    ],
    "created": 1777319831,
    "id": "chatcmpl-DZMMpD11GwQsD27xo2aEnxkId8PGM",
    "model": "gpt-4o-2024-08-06",
    "obfuscation": "CK2cVlJRUSY0t",
    "object": "chat.completion.chunk",
    "service_tier": "default",
    "system_fingerprint": "fp_6dd86a7be3",
    "usage": null
  },
  "... 339 more chunks omitted ...",
  {
    "choices": [],
    "created": 1777319831,
    "id": "chatcmpl-DZMMpD11GwQsD27xo2aEnxkId8PGM",
    "model": "gpt-4o-2024-08-06",
    "obfuscation": "zYJbbJ6sJN0JV",
    "object": "chat.completion.chunk",
    "service_tier": "default",
    "system_fingerprint": "fp_6dd86a7be3",
    "usage": {
      "completion_tokens": 339,
      "completion_tokens_details": {
        "accepted_prediction_tokens": 0,
        "audio_tokens": 0,
        "reasoning_tokens": 0,
        "rejected_prediction_tokens": 0
      },
      "prompt_tokens": 17,
      "prompt_tokens_details": {
        "audio_tokens": 0,
        "cached_tokens": 0
      },
      "total_tokens": 356
    }
  }
]

</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

Example usage: (3) - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ai/models/openai/gpt-4o/#page","headline":"GPT-4o","description":"GPT-4o is OpenAI’s multimodal flagship, accepting text and images and responding quickly across a wide range of tasks.","url":"https://developers.cloudflare.com/ai/models/openai/gpt-4o/","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: GPT-4o Mini is the lightweight, low-cost variant of GPT-4o, well suited to high-volume tasks with multimodal inputs. title: GPT-4o 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