feat(sdk/js): add vision support, list(), and missing types to Responses API client#671
Open
feat(sdk/js): add vision support, list(), and missing types to Responses API client#671
Conversation
…ses API client - Add InputImageContent and InputFileContent content part types - Expand ContentPart union to include new types - Add 7 new reasoning/annotation streaming event interfaces and expand StreamingEvent union - Add ListResponsesResult type - Add list() method to ResponsesClient (GET /v1/responses) - Default store to true in ResponsesClientSettings._serialize() - Add vision.ts with createImageContentFromFile and createImageContentFromUrl helpers - Export vision helpers from index.ts - Add unit tests: vision helpers, list(), reasoning event types, store default - Add integration tests for list() and vision (skipped when addon unavailable) - Add IS_NATIVE_ADDON_AVAILABLE guard to testUtils to skip integration tests gracefully - Update responses.ts example with list() and vision examples Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the JS/TS SDK’s Responses API support by adding multimodal (vision) input helpers, a list() endpoint wrapper, and additional missing streaming event/type definitions to better align with the service contract.
Changes:
- Added new content-part and streaming event types (image/file inputs + reasoning/annotation events) and a
ListResponsesResulttype. - Added
ResponsesClient.list()(GET /v1/responses) and changedResponsesClientSettings._serialize()sostoredefaults totrue. - Introduced
createImageContentFromFile()/createImageContentFromUrl()helpers, exported viasrc/index.ts, and expanded tests + examples accordingly.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/js/test/testUtils.ts | Adds IS_NATIVE_ADDON_AVAILABLE detection to help skip integration tests when the native addon isn’t present. |
| sdk/js/test/openai/responsesClient.test.ts | Adds unit/integration tests for vision helpers, list(), new streaming event types, and updates store-default expectations. |
| sdk/js/src/types.ts | Adds image/file content parts, reasoning/annotation streaming event interfaces, extends unions, and defines ListResponsesResult. |
| sdk/js/src/openai/vision.ts | New helper module to build InputImageContent parts from files or URLs. |
| sdk/js/src/openai/responsesClient.ts | Adds list() and changes serialization default for store. |
| sdk/js/src/index.ts | Exports the new vision helper functions from the public SDK surface. |
| sdk/js/examples/responses.ts | Adds examples demonstrating listing stored responses and sending vision input. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
apsonawane
reviewed
Apr 23, 2026
apsonawane
reviewed
Apr 23, 2026
apsonawane
reviewed
Apr 23, 2026
apsonawane
reviewed
Apr 23, 2026
apsonawane
reviewed
Apr 23, 2026
- Make media_type optional in InputImageContent (server can infer) - Add file existence check in createImageContentFromFile - Add bmp support to MEDIA_TYPE_MAP - Add optional maxDimension resize via soft-peer sharp dependency - Omit media_type in createImageContentFromUrl (server infers from URL) - Add JSDoc on ResponsesClientSettings.store documenting default=true - Replace FoundryLocalManager.create() in checkNativeAddonAvailable with file-existence checks (avoids side effects) - Replace unreachable-server list() test with globalThis.fetch mock - Use fs.mkdtempSync for unique temp dirs in file-based tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
apsonawane
reviewed
Apr 24, 2026
- vision.ts: use fs.promises.readFile (async) instead of sync existsSync/readFileSync
- vision.ts: validate maxDimension is a finite positive integer before use
- vision.ts: update JSDoc to reflect overloaded options param (object or detail string)
- vision.ts: resizeImage returns { buffer, mediaType } so media_type is explicit post-resize
- vision.ts: pass fallbackMediaType into resizeImage to avoid hardcoded 'image/png'
- testUtils.ts: check all 4 candidate addon paths (sdk/js/prebuilds, sdk/js/native,
sdk/js/dist/prebuilds, sdk/js/dist/native) matching CoreInterop.loadAddon() logic
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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
Updates the existing Responses API client in the Foundry Local JavaScript/TypeScript SDK with vision support, a
list()method, missing streaming event types, and corrected defaults.Changes
New types (
src/types.ts)InputImageContent— base64-encoded or URL-based image input partInputFileContent— file input partContentPartunion to include both new typesReasoningSummaryPartAddedEvent,ReasoningSummaryPartDoneEvent,ReasoningDeltaEvent,ReasoningDoneEvent,ReasoningSummaryTextDeltaEvent,ReasoningSummaryTextDoneEvent,OutputTextAnnotationAddedEventStreamingEventunion to include all new event typesListResponsesResult— return type forGET /v1/responsesClient updates (
src/openai/responsesClient.ts)list()method —GET /v1/responsesstorenow defaults totruein_serialize()when not explicitly setNew vision helpers (
src/openai/vision.ts)createImageContentFromFile(filePath, detail?)— reads a local image file, base64-encodes it, infers media type from extension (png/jpg/jpeg/gif/webp)createImageContentFromUrl(url, detail?)— creates a URL-based image content partsrc/index.tsTests (
test/openai/responsesClient.test.ts,test/testUtils.ts)list()network error handlingstoredefault serialization testlist()and vision (skipped when native addon unavailable)IS_NATIVE_ADDON_AVAILABLEguard totestUtils.tsso integration tests skip gracefully instead of erroring whenfoundry_local_napi.nodeis not compiledExample (
examples/responses.ts)createImageContentFromFileTest results