REFERENCE
SDK Demos
How to use @asgard-js/core and @asgard-js/react, with demos you can try on the page.
Auth
The SDK exposes an authState prop that renders different UI for each phase
of the authentication flow. Use it alongside onApiKeySubmit to validate an
API key asynchronously.
Supported States
State UI Behavior authenticatedNormal chat interface needApiKeyPrompt the user to enter an API key invalidApiKeyError state with retry affordance loadingSpinner while auth is being determined errorGeneric error UI subscriptionExpiredBlocking notice with upgrade CTA botNotFoundBlocking notice when the bot provider 404s Code Example
const [authState, setAuthState] = useState<AuthState>("needApiKey");
<Chatbot
authState={authState}
onApiKeySubmit={async (key) => {
const valid = await validate(key);
setAuthState(valid ? "authenticated" : "invalidApiKey");
}}
{...rest}
/>;