Skip to content

feat: support previews streaming in openAI API - #2097

Open
stduhpf wants to merge 2 commits into
leejet:masterfrom
stduhpf:openai-api-previews
Open

stduhpf wants to merge 2 commits into
leejet:masterfrom
stduhpf:openai-api-previews

Conversation

@stduhpf

@stduhpf stduhpf commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Summary

It's a little bit more tricky than the two other APIs, because it uses SSE streaming rather than polling, but with the help of a LLM I think I got it working. Only Latent2RGB/Proj previews are supported right now.

Related Issue / Discussion

#2093 #2096

Checklist

@leejet

leejet commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Thanks for working on this. I'd prefer to keep the OpenAI-compatible endpoints aligned with the official API rather than introduce a custom preview event format that requires client-specific handling.

Users who need previews should use the native sdcpp API.

@stduhpf

stduhpf commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Sorry I trusted the AI agent for not messing up the event format from the official API, I guess it tried implementing it from memory rather than looking up the docs. It should be actually compatible now.

@stduhpf
stduhpf force-pushed the openai-api-previews branch from 5959870 to 2c4ef0a Compare October 6, 2026 18:18
@leejet

leejet commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Thanks for the update! I think there was a misunderstanding about my concern.

My main concern isn't the event format itself. Even if the streaming events follow the official OpenAI API format, existing OpenAI API clients would still need to be modified to handle and display the previews.

If client-side changes are required anyway, I think it makes more sense to use the native sdcpp API, which already supports previews.

This is also why I chose to pass additional OpenAI API parameters through the prompt: to allow existing OpenAI-compatible clients to use sdcpp-specific features without requiring client-side modifications.

I'd prefer to keep the OpenAI-compatible API focused on compatibility with existing clients, rather than adding features that require custom client support.

@stduhpf

stduhpf commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

If no mainstream OpenAI API client actually support viewing partial images, then it's not a big deal.

But streaming previews is completely opt-in and backward-compatible. If a legacy client connects, "stream" defaults to false in the request, and the server returns the standard, static JSON payload like in the older version of the API. No existing clients should break or require modification if they're fine with not having live previews....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants