JavaScript ChatClient Streaming Uses Callbacks, Not Async Iterators
Severity: Documentation gap
Component: foundry-local-sdk JavaScript v0.9.x — ChatClient.completeStreamingChat()
The ChatClient returned by model.createChatClient() provides a completeStreamingChat() method, but it uses a callback pattern rather than returning an async iterable:
// ❌ This does NOT work — throws "stream is not async iterable"
for await (const chunk of chatClient.completeStreamingChat(messages)) { ... }
// ✅ Correct pattern — pass a callback
await chatClient.completeStreamingChat(messages, (chunk) => {
process.stdout.write(chunk.choices?.[0]?.delta?.content ?? "");
});
Impact: Developers familiar with the OpenAI SDK's async iteration pattern (for await) will encounter confusing errors. The callback must be a valid function or the SDK throws "Callback must be a valid function."
Expected: Document the callback pattern in the SDK reference. Alternatively, support the async iterable pattern for consistency with the OpenAI SDK.
JavaScript ChatClient Streaming Uses Callbacks, Not Async Iterators
Severity: Documentation gap
Component:
foundry-local-sdkJavaScript v0.9.x —ChatClient.completeStreamingChat()The
ChatClientreturned bymodel.createChatClient()provides acompleteStreamingChat()method, but it uses a callback pattern rather than returning an async iterable:Impact: Developers familiar with the OpenAI SDK's async iteration pattern (
for await) will encounter confusing errors. The callback must be a valid function or the SDK throws "Callback must be a valid function."Expected: Document the callback pattern in the SDK reference. Alternatively, support the async iterable pattern for consistency with the OpenAI SDK.