AI and LLMs · Middle · Question 28 of 75

How do you unit-test code that calls an LLM without paying for each run?

Show the answer

Correct answer: Mock the model client with recorded or fake responses

Explanation

Code around the model (parsing, retries, tool execution) can be tested deterministically. Separate evals test the model's quality.

Further reading

Problem with a question

AI and LLMs · Middle · question 28

Test yourself

Take the AI and LLMs · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz