# Context window limit to 8192 tokens while using openai embed model

**URL:** <https://community.crewai.com/t/context-window-limit-to-8192-tokens-while-using-openai-embed-model/458>\
**Category:** CrewAI Community Support\
**Created:** [September 18, 2024, 10:09am UTC](https://community.crewai.com/t/context-window-limit-to-8192-tokens-while-using-openai-embed-model/458 "2024-09-18T10:09:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bert](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@bert](https://community.crewai.com/u/bert)\
**Post date:** [September 18, 2024, 10:09am UTC](https://community.crewai.com/t/context-window-limit-to-8192-tokens-while-using-openai-embed-model/458/1 "2024-09-18T10:09:09Z")

</div>

when using gpt4o-mini I got an error saying: File “C:\Users\crewai\legacy\_code\ideal\_prompt\src.venv\Lib\site-packages\openai\_base\_client.py”, line 1041, in \_request  
raise self.\_make\_status\_error\_from\_response(err.response) from None  
openai.BadRequestError: Error code: 400 - {‘error’: {‘message’: “This model’s maximum context length is 8192 tokens, however you requested 10491 tokens (10491 in your prompt; 0 for the completion). Please reduce your prompt; or completion length.”, ‘type’: ‘invalid\_request\_error’, ‘param’: None, ‘code’: None}}

When I however take the same prompt and use that in a non-crewai openai program I have no issues getting a reponse. I used 33261 total tokens and 938 were completion tokens.

LLM\_MODEL is env var set to gpt-4o-mini  
agent code :  
llm\_model = OpenAI(model=os.environ.get(‘LLM\_MODEL’, ‘no\_model\_defined’))  
return Agent(config=self.agents\_config[“Doc\_agent”], verbose=True, llm=llm\_model)

the agents and crew use memory

Using python 3.12.2, crewai 0.60.0 crewai-tools 0.12.1

update : the model which is giving issues is the embeddingmodel. text-embedding-3 which is limited to 8191 tokens.
