Menu

A gateway SDK that refuses to be a new API: notes on nRouter's Java SDK
πŸ“°

A gateway SDK that refuses to be a new API: notes on nRouter's Java SDK

DEV Community: apiΒ·nRouterΒ·2 days ago
#9wn80A9U
#devtoapi#devto#dev#nrouter#java
Reading 0:00
15s threshold

Most vendor SDKs ask you to learn a second API and call it convenience. nRouter's Java SDK page makes the opposite bet, and it's worth a look for exactly that reason: there is almost no new API to learn.

One dependency, one static factory, the client you already know

The SDK ships on Maven Central as ai.nrouter:nrouter-sdk:3.1.2 β€” one line in a pom.xml, or implementation 'ai.nrouter:nrouter-sdk:3.1.2' in Gradle. Then:

OpenAIClient client = NRouter.create();

That's the whole integration surface of the nRouter-specific code. NRouter.create() reads NROUTER_API_KEY from the environment, targets https://api.nrouter.ai/v1 , and hands you back a configured instance of the standard OpenAI Java client. Everything after that β€” client.chat().completions().create(...) , the builder-typed ChatCompletionCreateParams , the response types β€” is the OpenAI Java API, unchanged.…

Continue reading β€” create a free account

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