Nutrient Web SDK

Interface Configuration

Configuration for the AI Assistant feature.

Contains authentication details, backend connection information, and optional customization settings for AI Agent behavior.

Interface

Example

NutrientViewer.load({
// ... other config
aiAssistant: {
sessionId: 'session-123',
jwt: 'eyJhbGciOiJIUzI1NiIs...',
backendUrl: 'https://localhost:4000'
}
})

Properties

Advanced configuration for customizing AI Assistant agent behavior.

Customize the system prompt, define specialized skills, configure tool execution approval policies.

Example

NutrientViewer.load({
aiAssistant: {
sessionId: 'session-123',
jwt: 'token-here',
backendUrl: 'https://localhost:4000',
agentConfiguration: {
systemPromptTemplate: 'You are an expert legal document assistant.',
skills: [
{
name: 'contract-review',
description: 'Analyze contracts for key terms',
content: 'Focus on liability and payment terms...'
}
],
toolApproval: {
defaults: { default: 'allow', write: 'ask' }
}
}
}
});

agentId

Optional
string

AI Agent preset or custom agent ID.

Selects a base agent configuration with different capabilities and behavior.

Preset Purpose
chat Read-only Q&A mode. This agent can summarize, extract data, and answer questions.
agentic Full autonomous agent. This agent can read, write, add annotations, fill forms, and redact documents.
base Base configuration. This agent uses defaults for all settings and is intended for customization.

Example

agentId: 'chat'  // Use the read-only chat preset

Default Value

'agentic'
string

URL of the AI Assistant service backend.

This should be the base URL where your AI Assistant service is deployed. The URL must include the protocol (http/https) but exclude trailing slashes.

Example

backendUrl: 'https://ai-assistant.example.com' // ✓ correct
backendUrl: 'https://ai-assistant.example.com/' // ✗ avoid trailing slash
string

JSON Web Token (JWT) for authenticating requests to the AI Assistant backend.

This token must be issued by your authentication service and should contain user identity claims. The token is sent with every request to the backend.

Example

jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
string

Session identifier for the AI Assistant conversation.

Use a unique identifier to create a new session, or reuse an existing session ID to restore a previous conversation. The ID must contain only alphanumeric characters.

Example

sessionId: 'userdocsession20250128'
sessionId: 'session123abc'

userId

Optional
string

Optional user identifier for tracking and rate limiting.

Provide a unique identifier for the current user. This enables per-user rate limiting, usage analytics, and audit logging. Must contain only alphanumeric characters.

Example

userId: 'userabc12345'
userId: 'user123'