Add types for Responses API (with tests) #88
+340
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds type definitions and tests for the Responses API (POST /v1/responses). No new public API surface or client/resource code in this PR.
Changes
Request types (src/gradient/types/responses/response_create_params.py): ResponseCreateParams and input item types (ResponseInputUserMessage, ResponseInputFunctionCall, ResponseInputFunctionCallOutput), plus ResponseTool, ResponseToolChoice.
Response types (src/gradient/types/responses/response_create_response.py): ResponseCreateResponse with id, output, status, error, model, usage; output item types (ResponseOutputMessage, ResponseOutputFunctionCall) with a discriminated union; output_text property that aggregates text from message items in output.
Exports (src/gradient/types/responses/init.py): Re-exports the above types.
Tests (tests/types/responses/test_response_create_response.py): 8 tests—parsing minimal response and response with usage, output_text aggregation (multiple messages, prefers output_text over content, skips function_call items, empty content), and parsing of message/function_call output items. All use static payloads (no network).
Testing
pytest tests/types/responses/ — 8 passed
pytest -m 'not smoke' — 460 passed (no regressions)
Ruff check & format, mypy on new code — pass
Follow-ups
PR 2: Responses resource + client.responses.create() (and tests)
PR 3: Model constants (ResponsesModels)
PR 4: Example and docs