Type Alias: NlqClient
type NlqClient = object;Defined in: packages/sdk/src/index.ts:834
The typed client returned by createClient — the only HTTP
surface per GLOBAL-001. Every method throws NlqdbApiError on
every failure path; discriminate on err.code (SK-SDK-002). Recoverable
failures (transport, transient 5xx) retry up to 3× automatically
(SK-SDK-008); a 401 on a withCredentials client refreshes and retries
silently (SK-SDK-005), so surfaces never see one. Mutations
auto-generate and reuse an Idempotency-Key across retries (SK-SDK-006).
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
databases |
object |
Bring-your-own-database verbs (SK-DBCONN-001). Namespaced because GLOBAL-003 parity names the surface client.databases.connect. |
packages/sdk/src/index.ts:910 |
databases.connect |
Promise<ConnectDatabaseResult> |
- | packages/sdk/src/index.ts:923 |
Methods
Section titled “Methods”ask(req, opts?): Promise<AskResponse>;Defined in: packages/sdk/src/index.ts:845
POST /v1/ask — answer a plain-English goal. Returns the union
AskOk | AskCreateResult: narrow on status === "ok" (rows + trace)
vs kind === "create" (the goal routed to DB creation). When req.dbId
is present the API always returns AskOk; when omitted it may auto-target
or route to create (SK-ASK-009 / SK-HDC-011). Errors worth a branch:
ambiguous_db (409, body.candidate_dbs), clarify_required (409),
rate_limited (429), db_not_found, sql_rejected. Retries transient
failures and auto-keys the POST (SK-SDK-008).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
req |
AskRequest |
opts? |
{ signal?: AbortSignal; } |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<AskResponse>
askStream()
Section titled “askStream()”askStream(req, opts): Promise<AskOk>;Defined in: packages/sdk/src/index.ts:854
POST /v1/ask (SSE) — streaming variant of ask. Resolves once the
done event arrives with the assembled AskOk; per-step timings surface
via opts.onTrace (SK-SDK-007). Use this — not ask — for chat
surfaces that want incremental rendering (GLOBAL-011). Not retried: a
mid-stream retry would re-fire side-effects (SK-SDK-008). Does not
cover the create branch — call ask when you need AskCreateResult.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
req |
AskRequest |
opts |
AskStreamOptions |
Returns
Section titled “Returns”Promise<AskOk>
clearByollm()
Section titled “clearByollm()”clearByollm(opts?): Promise<ClearByollmResult>;Defined in: packages/sdk/src/index.ts:1020
DELETE /v1/keys/byollm — hard-clear the stored BYOLLM credential (instant
revocation, GLOBAL-018). Idempotent: cleared: false when there was nothing
to clear. Session-only: throws unless withCredentials: true. Mutating:
auto-keyed (SK-SDK-006).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts? |
{ idempotencyKey?: string; signal?: AbortSignal; } |
opts.idempotencyKey? |
string |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<ClearByollmResult>
createDatabase()
Section titled “createDatabase()”createDatabase(req, opts?): Promise<CreateDatabaseResult>;Defined in: packages/sdk/src/index.ts:891
POST /v1/databases — create a database. Goal-first: goal drives the
engine classifier; pass engine to override (GLOBAL-015). Rejects an
unknown engine with invalid_engine (400). Mutating: pass idempotencyKey
for cross-process replay safety, else one is auto-generated (SK-SDK-006).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
req |
CreateDatabaseRequest |
opts? |
{ idempotencyKey?: string; signal?: AbortSignal; } |
opts.idempotencyKey? |
string |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<CreateDatabaseResult>
deleteDatabase()
Section titled “deleteDatabase()”deleteDatabase(dbId, opts?): Promise<void>;Defined in: packages/sdk/src/index.ts:902
DELETE /v1/databases/:id — destructive removal (SK-HDC-016); resolves
once the schema and registry row are dropped. Rejects with db_not_found
when the id is unknown or belongs to another tenant. The UI owns the
typed-name confirmation — this wire call assumes intent is already
gathered. Mutating: auto-keyed (SK-SDK-006).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
dbId |
string |
opts? |
{ idempotencyKey?: string; signal?: AbortSignal; } |
opts.idempotencyKey? |
string |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<void>
getByollmStatus()
Section titled “getByollmStatus()”getByollmStatus(opts?): Promise<ByollmStatusResponse>;Defined in: packages/sdk/src/index.ts:1013
GET /v1/keys/byollm — status of the stored BYOLLM credential (SK-SDK-011).
Never returns the key (SK-APIKEYS-002); { configured: false } is the empty
“add your key” state. Session-only: throws unless withCredentials: true.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts? |
{ signal?: AbortSignal; } |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<ByollmStatusResponse>
getKeyStatus()
Section titled “getKeyStatus()”getKeyStatus(keyHash, opts?): Promise<KeyStatus>;Defined in: packages/sdk/src/index.ts:955
GET /v1/keys/:hash/status — revocation probe (SK-MCP-014). apps/mcp/’s
McpAgent calls this every 1 s to re-check sk_mcp_* revocation. keyHash
is the HMAC-SHA256 hex of the plaintext key (never the plaintext), computed
via hmacHex in the calling Worker. Session-only, tenant-scoped.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
keyHash |
string |
opts? |
{ signal?: AbortSignal; } |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<KeyStatus>
getModels()
Section titled “getModels()”getModels(opts?): Promise<ModelCatalog>;Defined in: packages/sdk/src/index.ts:862
GET /v1/models — the model catalog (SK-PREMIUM-013): goal-first
presets plus the named frontier picker. Public (no auth), static, and the
same for everyone — which entry is active for the account is a separate
read (getByollmStatus). Read-only. Model strings live server-side
(SK-PREMIUM-003); this returns them so surfaces never hardcode them.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts? |
{ signal?: AbortSignal; } |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<ModelCatalog>
listChat()
Section titled “listChat()”listChat(opts?): Promise<{ messages: ChatMessage[];}>;Defined in: packages/sdk/src/index.ts:868
GET /v1/chat/messages — the caller’s persisted chat turns, oldest first.
Each row’s role discriminates user prompt vs assistant result. Read-only;
not idempotency-keyed.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts? |
{ signal?: AbortSignal; } |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<{
messages: ChatMessage[];
}>
listDatabases()
Section titled “listDatabases()”listDatabases(opts?): Promise<{ databases: DatabaseSummary[];}>;Defined in: packages/sdk/src/index.ts:884
GET /v1/databases — the caller’s databases. Each row carries its
resolved engine and the publishable pkLive (or null → fall back to the
anonymous device key, SK-ANON-006). Read-only.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts? |
{ signal?: AbortSignal; } |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<{
databases: DatabaseSummary[];
}>
listGrants()
Section titled “listGrants()”listGrants(opts?): Promise<{ grants: GrantRecord[];}>;Defined in: packages/sdk/src/index.ts:1054
GET /v1/grants — the caller’s grants (SK-EKP-008), both roles in one
list: sold (role: "owner") and held (role: "grantee"), active before
revoked. Session-only: throws unless withCredentials: true — a
leaked bearer cannot enumerate a tenant’s grants.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts? |
{ signal?: AbortSignal; } |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<{
grants: GrantRecord[];
}>
listKeys()
Section titled “listKeys()”listKeys(opts?): Promise<{ keys: KeyRecord[];}>;Defined in: packages/sdk/src/index.ts:973
GET /v1/keys — the caller’s keys (SK-APIKEYS-010), active + revoked,
newest first with revoked rows sorted to the bottom. Session-cookie only:
a leaked sk_live_ cannot enumerate sibling keys. Plaintext is never
present — last4 is the only display affordance.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts? |
{ signal?: AbortSignal; } |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<{
keys: KeyRecord[];
}>
mintGrant()
Section titled “mintGrant()”mintGrant(req, opts?): Promise<GrantMintResult>;Defined in: packages/sdk/src/index.ts:1044
POST /v1/grants — mint a cross-tenant read grant (SK-EKP-008, EK-06):
the owner sells granteeTenantId read-only query access to hosted DB
dbId, scoped to scope (bare table names). Session-only: throws
synchronously unless the client was built with withCredentials: true —
a leaked sk_live_ must not be able to open a tenant’s data to another
tenant. v1 grants mint on platform-provisioned hosted DBs only (byo_not_grantable
on a BYO DB). Errors: invalid_db_id/invalid_grantee/scope_* (400),
cannot_grant_to_self (400), db_not_found/grantee_not_found (404).
Mutating: auto-keyed and replayed under the same key (SK-SDK-006 / GLOBAL-005).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
req |
MintGrantRequest |
opts? |
{ idempotencyKey?: string; signal?: AbortSignal; } |
opts.idempotencyKey? |
string |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<GrantMintResult>
mintKey()
Section titled “mintKey()”mintKey(req, opts?): Promise<MintKeyResult>;Defined in: packages/sdk/src/index.ts:963
POST /v1/keys — mint a new sk_live_* or sk_mcp_* key (SK-APIKEYS-007).
Session-only (withCredentials: true): a leaked sk_live_ cannot bootstrap
sibling keys. The returned key is the plaintext, present exactly once
(SK-APIKEYS-002) — hand it to the user or the host config on the same
render. Mutating: auto-keyed (SK-SDK-006).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
req |
MintKeyRequest |
opts? |
{ idempotencyKey?: string; signal?: AbortSignal; } |
opts.idempotencyKey? |
string |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<MintKeyResult>
postChat()
Section titled “postChat()”postChat(req, opts?): Promise<{ assistant: ChatMessage; user: ChatMessage;}>;Defined in: packages/sdk/src/index.ts:875
POST /v1/chat/messages — run a goal and persist both the user prompt and
the assistant result as a chat turn. Mutating: auto-keyed on the POST
(SK-SDK-006). The returned assistant.result narrows on kind
("ok" vs "error").
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
req |
AskRequest |
opts? |
{ signal?: AbortSignal; } |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<{
assistant: ChatMessage;
user: ChatMessage;
}>
redeemOAuthBridgeCode()
Section titled “redeemOAuthBridgeCode()”redeemOAuthBridgeCode(code, opts?): Promise<OAuthBridgeRedemption>;Defined in: packages/sdk/src/index.ts:990
POST /v1/oauth/mcp-callback/redeem — redeem the one-shot OAuth-bridge code
(SK-MCP-013), the Worker-to-Worker call from apps/mcp/’s bridgeHandler.
The code itself is the auth proof (128-bit random, 60 s TTL, delete-on-read);
no bearer required on the client.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
code |
string |
opts? |
{ signal?: AbortSignal; } |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<OAuthBridgeRedemption>
registerPremiumInterest()
Section titled “registerPremiumInterest()”registerPremiumInterest(opts?): Promise<PremiumInterestResult>;Defined in: packages/sdk/src/index.ts:1029
POST /v1/premium/interest — record a “count me in” for the hosted-premium
plan (SK-PREMIUM-013’s subscribe door, shown “coming soon” only while
the catalog reports premium.live: false). Notifies the
founder with the caller’s account identity; the server dedups per account,
so repeat clicks don’t re-notify. Session-only: throws unless
withCredentials: true. Mutating: auto-keyed (SK-SDK-006).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts? |
{ idempotencyKey?: string; signal?: AbortSignal; } |
opts.idempotencyKey? |
string |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<PremiumInterestResult>
remember()
Section titled “remember()”remember(req, opts?): Promise<RememberResult>;Defined in: packages/sdk/src/index.ts:945
POST /v1/memory/remember — write a typed memory row into an
agent_memory_v1 preset DB (E-02). No LLM in the loop: the payload is
structured, so the server emits a deterministic parameterised INSERT.
Rejects a non-preset DB with wrong_preset (409) and a read-only
pk_live with forbidden. Mutating: auto-keyed (SK-SDK-006).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
req |
RememberRequest |
opts? |
{ idempotencyKey?: string; signal?: AbortSignal; } |
opts.idempotencyKey? |
string |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<RememberResult>
revokeGrant()
Section titled “revokeGrant()”revokeGrant(grantId, opts?): Promise<RevokeGrantResult>;Defined in: packages/sdk/src/index.ts:1063
DELETE /v1/grants/:id — owner revoke (SK-EKP-008). Fails closed within
the 30 s enforcement bound; a grantee cannot revoke (they walk away by not
querying). Tenant-scoped: an id from another tenant rejects as
grant_not_found (404) just like an unknown id — no cross-tenant existence
leak. Idempotent: a re-DELETE returns alreadyRevoked: true.
Session-only: throws unless withCredentials: true. Mutating: auto-keyed.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
grantId |
string |
opts? |
{ idempotencyKey?: string; signal?: AbortSignal; } |
opts.idempotencyKey? |
string |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<RevokeGrantResult>
revokeKey()
Section titled “revokeKey()”revokeKey(keyId, opts?): Promise<RevokeKeyResult>;Defined in: packages/sdk/src/index.ts:980
DELETE /v1/keys/:id — hard-revoke (SK-APIKEYS-011). Tenant-scoped: a key
id from another tenant rejects as key_not_found (404) just like an unknown
id, so the call never leaks cross-tenant existence. Idempotent: a re-DELETE
returns alreadyRevoked: true. Session-only; mutating: auto-keyed.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
keyId |
string |
opts? |
{ idempotencyKey?: string; signal?: AbortSignal; } |
opts.idempotencyKey? |
string |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<RevokeKeyResult>
runSql()
Section titled “runSql()”runSql(req, opts?): Promise<RunSqlResult>;Defined in: packages/sdk/src/index.ts:934
POST /v1/run — raw-SQL escape hatch (SK-SDK-009 / GLOBAL-015). Same
allow-list and trace block as ask; DDL is rejected. Errors worth
a branch: forbidden (a read-only pk_live tried to write), sql_rejected,
sql_too_long. Mutating (may INSERT): auto-keyed (SK-SDK-006).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
req |
RunSqlRequest |
opts? |
{ idempotencyKey?: string; signal?: AbortSignal; } |
opts.idempotencyKey? |
string |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<RunSqlResult>
setByollm()
Section titled “setByollm()”setByollm(cred, opts?): Promise<ByollmSetResult>;Defined in: packages/sdk/src/index.ts:1004
POST /v1/keys/byollm — upsert the single per-account BYOLLM credential
(SK-SDK-011), the persistent counterpart to the per-request byollm
option (SK-SDK-010). Session-only: throws synchronously unless the
client was built with withCredentials: true — a decryptable stored key
must ride a first-party cookie, never a leakable bearer. The key is sent
only on this POST and is never returned by any verb. Errors: invalid_byollm_key
(400, mis-shaped), byollm_unavailable (503, deployment can’t seal keys).
Mutating: auto-keyed (SK-SDK-006).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
cred |
ByollmCredential |
opts? |
{ idempotencyKey?: string; signal?: AbortSignal; } |
opts.idempotencyKey? |
string |
opts.signal? |
AbortSignal |
Returns
Section titled “Returns”Promise<ByollmSetResult>