In Xcode 26 Beta 4, we can use GeneratedContent with json to stream responses from external LLM providers, such as OpenAI, Anthropic, Gemini and more!
Nice write up, thanks Natasha!
This still requires iOS 26, right?
I prefer using Firebase because it handles streaming and provides a proxy (needed to hide API key).
Yes - you're right. There are other ways to accomplish this. Just wanted to show this one as an option.
This way of doing it that you demonstrated here is pretty clever. Thank you for sharing
This should also work with the Firebase streaming API as long as they're streaming json.
Sorry - can't see your other comment, but I updated the post to show that yes, this works with partial json strings as they come in!
So this partial json: {"company":"Apple Inc.","eps":1.48,"key_highlights
Will be converted to this object:
Analysis(company: Optional("Apple Inc."), quarter: nil, revenue: nil, net_income: nil, eps: Optional(1.48), revenue_growth_yoy: nil, key_highlights: nil)
Which you cannot do with Codable as it'll need to be a complete json string to decode.
Nice write up, thanks Natasha!
This still requires iOS 26, right?
I prefer using Firebase because it handles streaming and provides a proxy (needed to hide API key).
Yes - you're right. There are other ways to accomplish this. Just wanted to show this one as an option.
This way of doing it that you demonstrated here is pretty clever. Thank you for sharing
This should also work with the Firebase streaming API as long as they're streaming json.
Sorry - can't see your other comment, but I updated the post to show that yes, this works with partial json strings as they come in!
So this partial json: {"company":"Apple Inc.","eps":1.48,"key_highlights
Will be converted to this object:
Analysis(company: Optional("Apple Inc."), quarter: nil, revenue: nil, net_income: nil, eps: Optional(1.48), revenue_growth_yoy: nil, key_highlights: nil)
Which you cannot do with Codable as it'll need to be a complete json string to decode.