Cost-Optimizing Prompts
Prompting at scale needs attention to tokens and latency. Small changes often produce large cost savings.
Techniques
- Shorten context: Trim retrieved passages and prefer summaries over verbatim text.
- Limit response length: Set
max_tokensand ask for concise outputs. - Use structured templates: Structured outputs reduce costly re-parsing and follow-ups.
Operational tips
- Cache frequent prompts and responses when acceptable for freshness.
- Use lower-cost models for routing filters and simple tasks, and only escalate to larger models for complex requests.
Monitoring token usage and running small A/B cost experiments uncovers the best balance between quality and price.