Implement generative AI and agentic solutions 2.1 Build generative applications by using Foundry

You call a reasoning model through the Chat Completions API and must cap the total number…

Study guide skill: Deploy and consume LLMs, small models, code models, and multimodal models

Question B1-022

You call a reasoning model through the Chat Completions API and must cap the total number of tokens it generates, including hidden reasoning tokens. Which parameter should you set?

Select one answer.

  • A max_completion_tokens ✓ Correct answer
  • B stop
  • C max_tokens
  • D top_p

Answer: A

Reasoning tokens are billed as output tokens. With the Chat Completions API, max_completion_tokens caps everything the model generates, covering reasoning, visible output and formatting tokens; with the Responses API the equivalent is max_output_tokens. Stop sequences and top_p don't cap reasoning tokens.

Deep dive

How it works

Reasoning models generate reasoning tokens in addition to the input and output tokens you already know. The model uses them to work through the prompt: breaking the problem apart, weighing approaches and dropping paths that don't hold up. Reasoning tokens never appear in the message content, but they take up space in the context window and are billed as output tokens. A single request can use anywhere from a few hundred to tens of thousands of them, depending on how hard the problem is.

To cap everything the model generates, set max_completion_tokens with the Chat Completions API or max_output_tokens with the Responses API. Both limits cover reasoning tokens, visible output tokens and formatting tokens. To see how many reasoning tokens a request used, check completion_tokens_details.reasoning_tokens in a Chat Completions response.

You can also shape how much the model thinks with reasoning_effort. Supported values vary by model, and higher effort generally produces more reasoning tokens.

The other options, and when you'd use them

  • stop: Stop sequences are up to four sequences where the API stops generating. The reference notes they aren't supported with the latest reasoning models o3 and o4-mini. They mark where to stop, not how many tokens to allow.
  • max_tokens: This older parameter is deprecated in favor of max_completion_tokens and isn't compatible with o1 series models.
  • top_p: top_p controls the randomness of the response. It doesn't limit how many tokens are produced.

Exam tip

For reasoning models, remember the pairing: max_completion_tokens for Chat Completions and max_output_tokens for Responses. Both include hidden reasoning tokens. To lower cost per request, cap output or lower reasoning_effort.

References

Last reviewed:

Ready to test yourself? The quiz asks this and every other AI-103 question, with instant feedback. Practice this in a quiz →

All Generative AI & agents questions · AI-103 study guide

Thanks for your feedback!