Menu

Idiomatic where it counts: notes on nRouter's Go SDK
πŸ“°

Idiomatic where it counts: notes on nRouter's Go SDK

DEV Community: goΒ·nRouterΒ·2 days ago
#tCjEwPcn
#devtogo#devto#dev#nrouter#call
Reading 0:00
15s threshold

Go developers can smell a ported SDK. The ones that arrive from another language bring foreign idioms with them β€” builders everywhere, exceptions cosplaying as errors, a client you configure by mutating a global. nRouter's Go SDK page reads like it was written by someone who writes Go on purpose, and the details worth stealing are small ones.

The install is versioned, the client comes from the environment

go get github.com/nRouterGateway/nrouter-sdk/sdks/go/[email protected] β€” a v3 module path, pinned to a release. The client is nrouter.NewFromEnv() , reading NROUTER_API_KEY from the environment and targeting https://api.nrouter.ai/v1 . No config struct ceremony before the first call. And if you'd rather not take the dependency, the page is upfront that the OpenAI Go client can be pointed at the same endpoint β€” the SDK has to earn its place, which is the right posture.

Requests are maps, and that is a deliberate trade

Calls take a map[string]any β€” model, messages, the usual fields.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.