Requesting the full context window for output fails validation.
Why this happens
Setting max_tokens to the full model context window leaves zero room for the input prompt tokens.
Answer 1: Set a realistic output cap
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hi"}],
max_tokens=4096
)
