Max tokens vs max_completion_tokens - which to use?
Jordan LeeMar 15, 2026
I'm confused about the difference between max_tokens and max_completion_tokens in the API. The docs mention both but I'm not sure when to use which.
# Which one should I use?
response = client.chat.completions.create(
model="gpt-4o",
messages=[...],
max_tokens=1000, # This one?
# max_completion_tokens=1000, # Or this one?
)
Are they the same thing? Is one deprecated?
2.3k views8 replies19 likesSolved
1 Reply
The validation error is likely because the tools field needs to be at the same level as messages, not nested inside. Here's the correct format:
{
"messages": [...],
"tools": [{"type": "function", "function": {"name": "get_weather", ...}}]
}
Make sure each training example includes the complete tool definition.
Log in to reply to this topic.