ChatVertexAI inherits from BaseChatModel which accepts a standard property, max_tokens, from the documentation.
When initializing a ChatVertexAI instance with this standard property, it is not available on the instance and throws an error upon accessing. It is instead available under max_output_tokens.
It should be made available on the instance as the other chat model integrations (ChatOpenAI, ChatAnthropic, ...) all have this property available on the instance.
model = ChatVertexAI(
model="gemini-1.5-pro-002",
temperature=0.0,
max_tokens=500,
top_p=1.0,
)
print(model.max_output_tokens) # 500
print(model.max_tokens). # AttributeError: 'ChatVertexAI' object has no attribute 'max_tokens'
ChatVertexAI inherits from BaseChatModel which accepts a standard property,
max_tokens
, from the documentation.When initializing a ChatVertexAI instance with this standard property, it is not available on the instance and throws an error upon accessing. It is instead available under
max_output_tokens
.It should be made available on the instance as the other chat model integrations (ChatOpenAI, ChatAnthropic, ...) all have this property available on the instance.
LangChain package versions:
langchain-core==0.3.15 langchain-google-vertexai==2.0.7