Skip to main content
The official SDK wraps both flows, manages tokens, and exposes the REST API as typed resources.

Install

Two clients

Nemu

The client credentials client. It fetches and caches a token from your client_id and client_secret. It acts as your own account.

NemuOAuth

The authorization code client. It builds the authorize URL, exchanges the code, and refreshes tokens. It acts as the user who approved access.

Client credentials

Authorization code

Restore a session later with from_tokens, and persist rotated tokens with on_refresh.

Scopes

authorize_url takes scope strings, bare resource names, or a map, and validates whatever you give it. A typo throws right there instead of surfacing as a 403 later.
authorize_url returns the resolved list as scopes alongside the URL. See Scopes for every form, the aliases, and the helpers.

Options

Both clients accept the same options.
string
required
Your application client_id.
string
required
Your application client_secret.
string
Required for NemuOAuth. Must match a registered redirect URI.
string
The dated API version to pin. Defaults to the latest version the SDK knows about.
string
default:"https://app.nemu.cc/api/v1"
The versioned REST base.
number
default:"30000"
Request timeout in milliseconds.

The user resource

get and me both return the user described in Get the current user.

Version helpers

Working with resources

Resources return live entities you can act on directly.
list on providers, models, prompts, mappings, and workflows accepts the server side filters documented on each API page.
update() sends a full replacement, because the API validates the same schema on PATCH as on POST. Pass every required field, not only the ones you changed. The SDK re-reads the entity afterwards, since the API returns no body on a write.
Creates always land in your account’s default workspace, whichever workspace you scoped them through. Indexes live on the client as nemu.indexes rather than on a workspace, because the API resolves them from the default workspace too.

Errors

The SDK throws typed errors so you can branch on the failure.