[TypeScript SDK] Add helpers for image, audio, and file inputs/outputs
The Python SDK has convenient wrappers for multimodal content (images, audio, files). Add similar helpers to TypeScript.
What we need
Input helpers
import { Image, Audio, File } from '@agentfield/sdk';
const img = await Image.fromFile('./photo.jpg');
const audio = await Audio.fromUrl('https://example.com/audio.mp3');
const file = File.fromBuffer(buffer, 'document.pdf');
Output handlers
const response = await ctx.ai("Describe this image", { image: img });
if (response.hasAudio) {
await response.audio.save('./output.mp3');
}
Reference implementation
- Input:
sdk/python/agentfield/multimodal.py - Output:
sdk/python/agentfield/multimodal_response.py
Files to create
sdk/typescript/src/ai/multimodal.tssdk/typescript/src/ai/MultimodalResponse.ts
Documentation (internal team)
This adds new developer-facing APIs for multimodal AI. Update the SDK documentation to include:
- New classes: Image, Audio, File, MultimodalResponse
- Factory methods and their parameters
- Complete examples for vision and audio use cases
- Supported file formats
This looks already implemented on main. The helpers described here landed in #330 and were refined in #619: sdk/typescript/src/ai/multimodal.ts has Image, Audio, File (plus a Video class beyond the original spec), each with fromFile, fromUrl, fromBuffer, and fromBase64 factories, and MultimodalResponse.ts provides the output handlers. Both are exported from src/index.ts, and tests exist (ai_multimodal_response_extra.test.ts and related files).
The one gap I can find is the documentation section at the bottom of this issue: I could not find any docs in the repo covering the TypeScript multimodal helpers.
@santoshkumarradha is the remaining scope here just the docs? If so, I would be happy to write them up. Otherwise this can probably be closed as completed.
Confirmed the files, @0xHerm, and your #330/#619 read is right — multimodal.ts really did land inside the #330 commit despite that PR being about the UI revamp. But I went one step further and it changes the conclusion: the classes exist and are exported, but nothing in the SDK consumes them yet.
ctx.ai is the only AI entry point and it forwards a bare string to AIClient.generate; AIRequestOptions has no image/audio/file field, and createMultimodalResponse has zero call sites outside tests. I compiled the two examples in this issue's body and both are rejected by the ctx.ai overloads. So the docs gap you spotted is real, but it's the smaller gap — the helpers aren't wired in, and documenting them now would document an API that can't be called.
Keeping this open and re-scoping it to the integration: accept Image/Audio/Video/File on ctx.ai/AIRequestOptions and translate them to ai-sdk message parts (Python's agent_ai.py:_process_multimodal_args is the reference), return a MultimodalResponse when the provider response carries non-text content (mirror detect_multimodal_response), and add a test that goes through AIClient with a mocked provider — the current 31 tests can't catch this class of gap. The docs section should follow the wiring; it's yours if you still want it once that lands.