feat: expose request_id on ImageResponse - #185
Closed
aheze wants to merge 1 commit into
Closed
Conversation
Capture the x-request-id from the gRPC response initial metadata in image.sample() / image.sample_batch() (sync and aio) and expose it as ImageResponse.request_id, so callers can reference the server-side request in bug reports. Mirrors the request-id extraction the chat client uses internally. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
ImageResponse(sync and aio) now exposes arequest_idproperty, populated from thex-request-idheader on the gRPC response's initial metadata ofimage.sample()/image.sample_batch(). ReturnsNoneif the header is absent.GenerateImage.with_call(...), aio awaitscall.initial_metadata(); a shared_extract_request_idhelper inimage.pyhandles both metadata formats.Test plan
x-request-idinitial metadata onGenerateImage; new sync + aio tests assertresponse.request_idround-trips forsampleandsample_batch, plus a default-Noneunit test.ruff check,ruff format --check, andpyrightclean on changed files.Made with Cursor