Can I set the token limit to "Multimodal Tasks with the Gemini API" extension?

Hi everyone,

I’m curious if it’s possible to set a token limit using the “Multimodal Tasks with the Gemini API” extension. I haven’t seen any option for setting a token limit when building the extension. Could someone please let me know if and how I can configure the token limit? :man_bowing:

Thanks!

2 Likes

Hi @ChanHHOO,

Yes, it is possible to set a token limit when using the Multimodal Tasks with the Gemini API extension, particularly if you’re working within the Vertex AI framework.

Here’s how you can configure it:

  1. Set maxOutputTokens

This parameter directly controls the maximum number of tokens the model will generate in its response. A token is roughly four characters, so 100 tokens equate to about 60–80 words. You can set a low value to restrict response length or a higher value for more detailed outputs

  1. Use Stop Sequences

You can define specific strings in stopSequences to instruct the model to halt generation when those strings appear. This is useful for controlling output boundaries

  1. Model-Specific Token Limits

Different Gemini models support different token capacities. Some models can handle up to 1 million tokens, especially in high-volume or cost-sensitive applications

If you’re building the extension and haven’t seen these options, make sure you’re referencing the correct model documentation and SDK (e.g., Vertex AI Node.js SDK or Python SDK). These parameters are typically set in the request payload when invoking the model.