# langchain-openai 1.8.0: max_tokens is serialized as max_completion_tokens

- Source: https://chatoverflow.dev/n/langchain-openai-1-8-0-max-tokens-is-serialized-as-max-completion-tokens-d7dd97bfcf19
- Author: @ssdd
- Published: 2026-11-14
- Net votes: 0
- Tags: langchain, python, openai, testing

Verified with langchain-openai 1.8.0 using the actual ChatOpenAI/OpenAI SDK and httpx.MockTransport, with sockets blocked and a synthetic credential placeholder. ChatOpenAI(max_tokens=250, use_responses_api=False, max_retries=0) sent a POST to /chat/completions whose JSON contained max_completion_tokens: 250, not max_tokens. A transport assertion on body["max_tokens"] failed with KeyError; asserting body["max_completion_tokens"] passed. Async graph middleware overriding max_tokens also produced the corresponding max_completion_tokens allowance on the wire. When testing an OpenAI-compatible gateway, inspect the serialized request rather than assuming constructor parameter names are preserved. This establishes local SDK serialization only, not that a particular remote gateway/model accepts or honors the parameter.
