Courseiva
Question 555 of 985

AI-900 Practice Question: Describe features of generative AI workloads on Azure

A developer uses Azure OpenAI to generate Python code. They want the model to limit the length of the generated code to avoid overly long and complex functions. Which parameter should the developer set in the API call?

⚠ Common exam trap

Test-takers frequently confuse `max_tokens` with `temperature` or `top_p`, thinking that randomness parameters can control output length, when in fact only `max_tokens` provides a hard token limit.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

max_tokens

The `max_tokens` parameter controls the maximum number of tokens (words or subwords) the model can generate in a single response. By setting a lower `max_tokens` value, the developer can cap the length of the generated Python code, preventing overly long and complex functions. This is the correct parameter for limiting output length.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • temperature

    Why it's wrong here

    Temperature is a sampling parameter that scales the logits before the probability distribution is computed, controlling how random or deterministic the generated code is. A low value like 0.1 makes output focused and reproducible, while a high value like 0.9 increases diversity at the cost of reliability. It does not impose any bound on output length—it only alters which token sequences are likely—so it cannot cap the number of tokens returned.

  • max_tokens

    Why this is correct

    max_tokens sets a hard upper limit on the number of tokens the Azure OpenAI service will emit in a single completion, and generation stops as soon as that count is reached or the model produces an end-of-sequence marker. For code generation, this means the entire function, class, or script must fit within the allocated budget or the output will be truncated mid-statement. Increasing max_tokens is the only direct way to allow longer generated code; all other parameters affect content probability rather than total length.

  • top_p

    Why it's wrong here

    top_p, also called nucleus sampling, restricts the model to sample from the smallest set of tokens whose combined cumulative probability reaches the specified p value, such as 0.9, while discarding the long tail of unlikely tokens. This changes the diversity of token choices and can make output more focused or more varied, but it does not define any maximum on the number of tokens generated. A token limit like max_tokens is still required to stop generation; top_p alone cannot cap response length.

  • frequency_penalty

    Why it's wrong here

    frequency_penalty adjusts the logit scores of tokens by subtracting a penalty proportional to how often each token has already appeared in the current completion, thereby discouraging repetition of the same words, phrases, or code constructs. This is useful for reducing redundant lines of code, repetitive comments, or boilerplate, but it has no upper-bound effect on total output size. It may make the model write more concise code by avoiding repeats, yet it cannot directly control how many tokens are returned.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 11, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This AI-900 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AI-900 exam.