Output shorter than instruct at the prompt

I’m trying to generate blog posts using 4o-mini.
I’m instructing in the prompt the model generates a blog post with 2000-3000 words.

The problem is, no matter what I changed in the prompt OR in the max_tokens parameter, the response is always something between 1200-1500 words.

Anyone already resolved this?

Some guy in an online community told me he had the same problem. The only way was to change the process first to generate an outline structure of the blog post and, after that, generate the content for each section using individual requests.

Part of my code:

self.creator_template = PromptTemplate(template="""Write a detailed and expert-level SEO-optimized blog post in {language} suitable for readers in the {country} about {keyword}:

        Writing requirements:
        - Write a detailed blog post with 2000-3000 words (this is equivalent to 4096 tokens), to generate deep value for the audience;
        - Use the keyword {keyword} at least 4 times in the blog post;
        - Write in first person, like a human sharing his wisdom; 
        - Use a active and conversational tone that engages the reader;
        - Use idioms, colloquialisms, and cultural references in {country} where appropriate;
        - Pose rhetorical questions and directly address the reader to enhance engagement;
        - Express emotions and show empathy towards the reader's needs or challenges;
        - Avoid using overused or common AI-generated words and phrases such as: Transformative, foster, delve into, unlock the secrets, in today's digital age, cutting-edge, robust, furthermore, moreover, thus, however, in conclusion, fast paced, etc.
        - Connect ideas using natural transitions instead of formal or stiff phrases;
        - Avoid generic advice and provide advanced insights and unique perspectives demonstrating a deep understanding of the subject matter;
        - Use famous case studies, examples, data, and research to backup key points when appropriate;
        - Write clear explanations of complex concepts, assuming the reader has some familiarity with the basics but is looking for advanced knowledge;
        - Provide actionable tips to overcome the challenges;
        - The content should be structured logically with a clear introduction, deep exploration of the topic, and a well-rounded conclusion with key takeaways.

        Answer: """, input_variables=["keyword", "country", "language"])

    def invoke_openai(self, prompt, max_tokens=8192, temperature=0.8):
        try:
            response = openai.chat.completions.create(
                model="gpt-4o-mini",  # Open AI Model
                messages=[
                    {"role": "system", "content": "You are a helpful expert assistant that generates SEO strategies, keywords and blog posts, based in what the user ask."},
                    {"role": "user", "content": prompt}
                ],
                max_tokens=max_tokens,
                temperature=temperature,
                timeout=300,  # Set timeout to 300 seconds (5 minutes)
                presence_penalty=0.6,
                frequency_penalty=0.3
            )
            # Clean the response of formatting artifacts
            raw_response = response.choices[0].message.content.strip()

            # Remove backticks and code block markers from the response if they exist
            clean_response = raw_response.replace("```json", "").replace("```", "").strip()

            return clean_response
        except Exception as e:
            print(f"Error invoking OpenAI: {str(e)}")
            return None