I’ve noticed discussions about OpenAI in the WIP thread. And at first I wanted to say “why so complicated”, remembering my experience in 2023. A lot of things have really changed since then, neural networks have gotten smarter and APIs have changed a lot.
I downloaded OpenAI nuget, the official repository for C#, and decided to quickly build an example that I could show with the words “this is so simple”. But! I came across something that made my head spin a bit, and maybe you know how to work with something like this? I do not want to find out that it is impossible to work with it because of the wrapper over http request. The 2023 library worked fine.
@bjoern Yeah, I know. In a way, it’s even better and maybe more suitable for use in Gamma. However, as if “official library” sounds better than “unofficial library”.
While digging into Gamma I realised the whole “missing Value” drama is just reflection showing us the raw SDK guts. OpenAI v2 wraps every call in ClientResult<T>; in normal C# the implicit cast or Value property pops the shell, but Gamma hides that property because it’s flagged EditorBrowsable(Never) and it never runs operator overloads.
Add System.ClientModel explicitly (nuget install System.ClientModel) and the Value getter suddenly appears in the node browser; reflection can now see it. The side-effect is hilarious: the CLR may load the same generic type from two different assembly identities, so the runtime yells “ClientResult`1 is not ClientResult`1”. Same full name, different assembly fingerprint—classic type-identity clash.
What’s happening: Gamma already had one copy of System.ClientModel transitively from OpenAI; your manual install brings in another (often a newer minor build). Two distinct assemblies ⇒ two distinct ClientResult<T> definitions ⇒ cast fails. Fix is trivial: keep only one System.ClientModel version (clean obj/bin, consolidate packages, or add an assembly-redirect in App.config). Once the duplicate is gone you can unwrap with either result.Value or an explicit (ChatCompletion)result cast and everything behaves.