If I was going to write a Go application to utilize the OpenAI API, is there a reason to use this vs. just making calls directly to the OpenAI API?
Genuine questions so I can understand and learn more.
When you make an LLM call, if you use the streaming responses (typical of token streaming into applications) then the response from the LLM provider comes in a specific format; mostly made up of individual json events, one for each text-delta or token generated, and some framing around start/stop. That API format differs across different LLM providers, and also isn't that convenient to process for what you actually want to show in the client/browser.
The backend portion of these sdks (AI-SDK) are an abstraction over the LLM provider, and re-write the 'events' that you get back from the LLM provider into an abstracted json format that's a little bit easier to work with. And not coupled to a specific provider.
The frontend portion of these SDKs (AI UI SDK) helps you to render those message into a frontend interface, and uses the same abstracted format that the backend uses.
There's one big missing piece though, and that's the fact that the transport between frontend and backend is over a single HTTP+SSE stream. If that connection fails, all the work that the backend is doing cannot be transported to the frontend anymore. The HTTP connection also doesn't allow for useful features like cancellation, steering, interruption, and multiple devices.
If you want those, checkout Ably AI Transport, which targeting the _transport_ section between backend and frontend, to make sure you get reliable experiences in the UI regardless of which AI provider or SDKs you use.
Disclaimer, I work for ably on this product:
These days I am very very cautious about the quality of packages. I’ve become a lot more reluctant/hesitant (which is not to say prior I was in favor of just adding packages left and right). I was still conservative, but these days I’ve become much much more conservative when it comes to adding a package to a production system.
I will review this later and report back for the community
"Go port of Vercel's AI SDK (github.com/grafana/ai-sdk), providing streaming LLM orchestration wire-compatible with @ai-sdk/react"
Btw, the emdash in the repo description is a giveaway too.
However, that person worked for Vercel, so be aware that the design is apt to be questionable. Another comment has already pointed out some of the core design flaws, as is emblematic of everything that comes out of Vecel.
But you may find it useful if you have to integrate into that ecosystem.
I think they really missed the opportunity to add in resumable streaming after a dropped SSE connection, or multi-device support. Because these SDKs are easy to drop-in to your applications, but hard once you actually try and build resilient systems on top of them. Systems that can heal from dropped connections, or support multiple users or multiple devices.
https://adk.dev/get-started/about/ | https://github.com/google/adk-go