Create custom analyst

Creates a custom analyst. Identity follows your API key, so you do not send a user object in the body. Most requests are plain JSON, but organisation memory attachments can also be sent with multipart parts named organisationMemoryFiles. See Custom analysts overview.

POST/users/custom-analysts

Body fields

FieldTypeRequiredDescription
namestring
Required
Display name shown in your library. Sent upstream as modelName.
basestring
Required
Which built-in model this analyst is based on (for example leniq-pro). Sent upstream as modelType.
tonestring
Required
How the analyst should respond. One of: professional, friendly, authoritative, consultative, funny. Sent upstream as modelTone.
emojistring
Optional
Icon shown in the UI. Defaults to 🤖 when omitted. Sent upstream as modelEmoji.
organisationMemoryobject
Optional
Optional organisation memory to add after the analyst is created. On success, the response may include organisationMemorySync with the add-to-memory result. If memory sync fails after the analyst was created, you may receive 502.

organisationMemory object

Send organisationMemory as a nested JSON object. Validation keeps the nested object intact, so do not stringify it.

FieldTypeRequiredDescription
noteTitlestring
Required
Title of the organisation memory note. Required when organisationMemory is included on create.
noteContextstring
Required
Body text of the organisation memory note. Required when organisationMemory is included on create.
noteIdnever
Optional
Do not send on create. Use noteId only on update routes when you want to change an existing memory note.
files / filesBase64array
Optional
Optional file attachments using the same base64 shape as add-to-memory (see File uploads). You may also upload via multipart using parts named organisationMemoryFiles.

If you include attachments for organisation memory, use the same base64 object shape described in File uploads, or send binary multipart parts named organisationMemoryFiles.

For multipart clients, send the normal analyst fields together with nested organisation-memory form fields and one or more organisationMemoryFiles parts.

Response

Returns HTTP 201 Created with the created analyst payload (including an id you can use in Run models). If organisationMemory is included and its sync succeeds, the response also includes organisationMemorySync. If the analyst is created but the follow-up memory sync fails, the API may return 502.

Example

JSON
POST /users/custom-analysts
{
  "name": "Lease reviewer",
  "base": "leniq-pro",
  "tone": "professional",
  "emoji": "📄"
}

Example with organisation memory

JSON
POST /users/custom-analysts
{
  "name": "Lease reviewer",
  "base": "leniq-pro",
  "tone": "professional",
  "organisationMemory": {
    "noteTitle": "Scope",
    "noteContext": "Focus on Ontario residential leases."
  }
}

Code examples

const res = await fetch(`${process.env.API_BASE}/users/custom-analysts`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-Api-Key": process.env.LENI_API_KEY!,
  },
  body: JSON.stringify({
    name: "Lease reviewer",
    base: "leniq-pro",
    tone: "professional",
    emoji: "📄",
  }),
});

const data = await res.json();