GPT-6 Astra
8.7# The implementation is correct, well typed, and thoroughly documented, though it misses connection pooling via requests.Session and unnecessarily disables redirects.
inspect full trace →Write a small HTTP API client class with error handling and docs
Write a Python class `APIClient` that wraps the `requests` library for a REST API. It should: (1) accept a base_url and optional api_key in __init__, (2) have a `get(path, params=None)` method and a `post(path, data)` method, (3) raise a custom `APIError` exception with the status code and message on non-2xx responses, (4) include type hints throughout, (5) have a complete docstring on the class and each public method. Show a usage example at the bottom.
Does the class work as described? Are error cases handled? Are type hints correct?
Is the code clean and well-structured? Is APIError a proper Exception subclass? Are session/connection concerns handled?
Does the class have a docstring? Do all public methods have docstrings? Is the usage example runnable?
# The implementation is correct, well typed, and thoroughly documented, though it misses connection pooling via requests.Session and unnecessarily disables redirects.
inspect full trace →# The implementation cleanly satisfies the core requirements with proper error handling, typing, sessions, and docstrings, though it lacks timeout/session-closing support and the example may fail against the placeholder URL without catching transport errors.
inspect full trace →