Before sending a long document set, you need to know whether the request fits the model's context window and what it will roughly cost. What should your code do?
- Exam domain
- Model Selection and Optimization16.8% of the exam
- Difficulty
- Easy
- In this mock
- 10 questions on this domainPractise this domain
Why the exam asks this
Domain 5: Model Selection and Optimization (16.8%).
Objective in the exam guide: Technical Fundamentals: basic engineering practices such as integrating with SDKs that wrap REST APIs.
Using the SDK correctly is a technical fundamental.
Why D is the answer
Call the token counting endpoint with the same model, system prompt and messages
The token counting endpoint estimates input tokens for a request; counts differ between models, so count with the model you will use.
How it works
The token counting endpoint returns an estimate of input tokens.
It takes the same model, system and messages as a real request.
Counts from older models should not be reused for newer ones.
Clues in the question
The words that point to the answer, and what each one tells you.
- Fits and roughly what it costs
- Count tokens first.
In detail
- Token counts are estimates.
- Recount when you change models.
Side by side with look-alikes
| Method | Reliable? |
|---|---|
| Token counting endpoint, same model | Yes |
| Word count | No |
| Send and see | No |
| Older model count | No |
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Estimate tokens as the number of wordsWrong
Word counts differ from token counts.
B. Send the request and see if it failsWrong
Failing requests wastes time.
C. Use a token count measured on a different older modelWrongMost tempting
Token counts change between model generations.
Why it tempts: It is available. But tokenizers differ across model generations.
D. Call the token counting endpoint with the same model, system prompt and messagesRight
The token counting endpoint estimates input tokens for a request; counts differ between models, so count with the model you will use.
In practice
- Combine token counts with current prices to estimate cost per request.