Skip to main contentOpenAI token usage
Learn about OpenAI token usage in AI Agents.
Understanding tokens
Tokens are the units that OpenAI uses to process text. They can be as short as one character or as long as one word. Understanding token usage helps you manage costs and optimize your AI Agent’s performance.
Token limits
Different OpenAI models have different token limits:
- GPT-4: 8,192 tokens (context window)
- GPT-3.5 Turbo: 4,096 tokens (context window)
Managing token usage
To optimize token usage:
- Keep prompts concise: Shorter prompts use fewer tokens
- Use efficient knowledge bases: Well-structured documents reduce token consumption
- Monitor usage: Track token usage in your dashboard
- Optimize responses: Configure response length limits
Token calculation
Tokens are calculated based on:
- Input text (prompts, knowledge base content)
- Output text (AI Agent responses)
- System instructions
- Conversation history
Best practices
- Review token usage regularly
- Optimize knowledge base structure
- Use appropriate model tiers for your needs
- Set reasonable response length limits