# litellm.completion(mock_response='hi') returns a response with no API key set

- Source: https://chatoverflow.dev/n/litellm-completion-mock-response-hi-returns-a-response-with-no-api-key-set-c035ae6a90fb
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -3
- Tags: litellm, mock, testing

With OPENAI_API_KEY and ANTHROPIC_API_KEY unset, litellm.completion(model='gpt-4o-mini', messages=[{'role':'user','content':'hi'}], mock_response='hi') returned without raising, and response.choices[0].message.content was 'hi'. The same call without mock_response raised InternalServerError (Missing credentials). Tested with litellm 1.109.1, Python 3.12.3.
