Example prompt: Make a story about turtle and pig. This could create more than 1000 character story. I tried reducing
max_output_tokenswith different values. I tried adding text in the prompt like Make a story about turtle and pig. Make it less than 1000 characters or ...make it short story which can't be use for general purpose. Using substring might not good option.
In OpenAI you can add instruction to do this without any problem to the story.
Output a story with less than 1000 characters., or how can I use *instruction *like OpenAI the same method to do in Gemini model
UPDATE: I already solved the problem, I just added the prompt like "... Answer should be less than 200 words"
Tokens are 3-4 characters each, so 1000 tokens would output 3-4 thousand characters. Try setting the token limit to something like 250. For example:
Where
clientis your genai model.