apiKey empty
and set the proxyUrl option (or a sendRequest callback) so your own backend
holds the key and forwards the request to the provider.
The jqxChat widget embeds an AI assistant chat and connects it to your platform key.
A live JavaScript/jQuery example of jqxChat, the jQWidgets Chat component, with its complete source code below. It is one of 5 jqxChat demos for jQuery.
accentColor property – Sets or gets the brand accent colour used for the send button, the user message bubbles, the avatars and the popup launcher.apiKey property – Sets or gets the platform key used to authenticate requests to the AI provider.colorScheme property – Sets or gets the colour scheme of the chat.height property – Sets or gets the chat's height.maxTokens property – Sets or gets the upper bound on the number of tokens in the assistant's response, sent to the provider as max_tokens.model property – Sets or gets the model identifier sent to the provider.provider property – Sets or gets the AI provider adapter.starterPrompts property – Sets or gets an array of suggested prompt strings displayed as clickable chips when the conversation is empty.stream property – Sets or gets whether the assistant response is streamed token by token using Server-Sent Events.subtitle property – Sets or gets the header subtitle text shown under the title.system property – Sets or gets the system / developer instructions sent to the model to define the assistant's behaviour.theme property – Sets the widget's theme.title property – Sets or gets the header title text (also used as the popup launcher tooltip).welcomeMessage property – Sets or gets the welcome text (Markdown supported) shown in the empty state above the starter prompts.width property – Sets or gets the chat's width.messageSent event – This event is triggered when the user sends a message.messageReceived event – This event is triggered when the assistant's response is complete.error event – This event is triggered when a request fails or the connection is misconfigured.focus method – Moves keyboard focus to the message input.val method – Returns the conversation history as an array of message objects (alias of getMessages).To run it in your own page, load jqx.base.css, a theme and the library files below from npm (npm install jqwidgets-scripts) or the jsDelivr CDN, then add the markup and the script. jQuery is not required: jqxcore.js provides $.
The page loads jqx.base.css, a theme and these library files: jqxcore.js, jqxbuttons.js, jqxscrollbar.js, jqxlistbox.js, jqxdropdownlist.js, jqxchat.js.
It also loads helper scripts of this demo site, which are not part of the library: demos.js (getWidth() and other layout helpers).
$(document).ready(function () {
var theme = 'light';
// ---- the chat component ----
$('#chat').jqxChat({
theme: theme,
width: 440,
height: 600,
title: 'AI Assistant',
subtitle: 'Powered by Claude',
colorScheme: 'auto',
accentColor: '#6366f1',
provider: 'anthropic', // "anthropic" (Claude) | "openai" | "custom"
model: 'claude-opus-4-8', // most capable Claude model
system: 'You are a friendly assistant embedded in a jQWidgets demo. ' +
'Keep answers concise and format code with Markdown fences.',
maxTokens: 1024,
stream: true,
welcomeMessage: 'Hi! Connect a platform key above, then ask me anything.',
starterPrompts: [
'What is jQWidgets?',
'Show me a code example',
'Explain streaming responses'
]
});
// ---- connection controls ----
$('#provider').jqxDropDownList({
theme: theme, width: 150, height: 30, autoDropDownHeight: true,
source: ['anthropic', 'openai'], selectedIndex: 0
});
$('#applyKey').jqxButton({ theme: theme, width: 90, height: 30 });
$('#applyKey').on('click', function () {
var provider = $('#provider').jqxDropDownList('getSelectedItem').value;
var model = provider === 'openai' ? 'gpt-4o-mini' : 'claude-opus-4-8';
$('#chat').jqxChat({
provider: provider,
model: model,
subtitle: 'Powered by ' + (provider === 'openai' ? 'OpenAI' : 'Claude'),
apiKey: $('#apiKey').val()
});
$('#status').text('Connected to ' + provider + ' (' + model + ').');
$('#chat').jqxChat('focus');
});
// ---- react to the widget's events ----
$('#chat').on('messageSent', function (e) { console.log('user:', e.args.content); });
$('#chat').on('messageReceived', function (e) { console.log('assistant:', e.args.content); });
$('#chat').on('error', function (e) { $('#status').text('Error: ' + e.args.message); });
});
<div id="panel">
<div class="row">
<label for="apiKey">Platform key:</label>
<input id="apiKey" type="password" placeholder="sk-ant-... or sk-..." autocomplete="off">
<div id="provider"></div>
<input type="button" id="applyKey" value="Connect">
<span id="status"></span>
</div>
<div id="note">
<strong>Security note.</strong> Pasting a key here calls the provider directly from the browser, which
exposes the key. That is fine for a quick local trial only. In production, leave <code>apiKey</code> empty
and set the <code>proxyUrl</code> option (or a <code>sendRequest</code> callback) so your own backend
holds the key and forwards the request to the provider.
</div>
<div class="links">
No key handy? Try the offline demos:
<a href="mock-assistant.htm">Offline assistant</a>
<a href="floating-assistant.htm">Floating launcher</a>
<a href="custom-branding.htm">Custom branding</a>
<a href="events-and-methods.htm">Events & methods</a>
<a href="themes.htm">Dark mode & accents</a>
</div>
</div>
<div id="chat"></div>