Skip to content
mager-bench1.3
← historical challenges

api-client

Write a small HTTP API client class with error handling and docs

the prompt

$ cat api-client.prompt
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.

rubric

correctness

Does the class work as described? Are error cases handled? Are type hints correct?

quality

Is the code clean and well-structured? Is APIError a proper Exception subclass? Are session/connection concerns handled?

documentation

Does the class have a docstring? Do all public methods have docstrings? Is the usage example runnable?

results

GPT-6 Astra

8.7
correctness 9.0quality 8.0documentation 9.031897ms

# The implementation is correct, well typed, and thoroughly documented, though it misses connection pooling via requests.Session and unnecessarily disables redirects.

inspect full trace →

GPT-5.6 Sol

8.7
correctness 9.0quality 8.0documentation 9.014062ms

# 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 →