For AI agents: a documentation index is available at /llms.txt, and the full corpus at /llms-full.txt. A markdown version of any page on this site is available by appending .md to its URL path — the homepage is at /index.md.

API Reference

Every constructor option, instance method, state field, and event — for the framework-agnostic SDK.

Constructor options

Pass these to the constructor as the second argument.

PropTypeDefaultDescription
renderMode"full" | "dropdown" | "headless""full"Tier — full owns everything; dropdown lets you own the input; headless gives you state only.
apiConfigRequiredAPIConfigRuntime API configuration (key or token).
additionalContextRecord<string, unknown>Optional user context. Include whatever you know about the user (a profile, preferences, workspace, anything) to personalize suggested parameters and options to them.
columnsnumber2Number of columns in the dropdown grid.
mode"light" | "dark" | "auto""auto"Color mode. auto follows prefers-color-scheme.
optionsPosition"above" | "below""below"Where the dropdown opens.
animationsbooleantrueEnable selection streak + shimmer animations.
pillPlacement"inline" | "dropdown" | "hidden""dropdown"Where unfilled pills render. Ignored in "dropdown" render mode, which always puts them in the dropdown.
dropdownTrigger"auto" | "manual" | "hidden""auto"When the dropdown appears.
closeDropdownOnBlurbooleantrueWhen false, the dropdown stays open even when the input loses focus.
showNonTappableOptionsbooleantrueWhen false, options the server marked is_tappable: false (hint rows like "or type something else…") are hidden instead of rendered alongside the selectable ones.
submitButtonHTMLElement | nullCustom submit button. Pass an element to replace the built-in arrow button, or null to render none. Leaving it undefined keeps the default. Clicks on your element bubble up and trigger submit.
autoFocusbooleantrueFocus the input on mount (Tier 1 only).
onFocus() => voidCalled when the input gains focus.
onBlur() => voidCalled when the input loses focus.
maskCompletedTextbooleanfalseStrip completed-param text from network requests (PII masking).
optionOverridesRecord<string, (query) => SuggestionOption[]>Override option lists per suggestion type.
onSubmit(result) => voidCalled on Enter or submit.
onError(error) => voidCalled when a fetch fails.
onChange(text: string) => voidCalled when text changes.
onParamsChange(params) => voidCalled when params change.
onStateChange(state: CoreState) => voidCalled with the full state snapshot whenever it changes — the option form of subscribe(). Use it when you want state pushed to you at construction time rather than wiring a subscription afterwards.
valuestringControlled mode: supply the input text yourself. Pair with onChange, which fires on every mutation.
completedParamsCompletedParamState[]Controlled mode: supply the filled params yourself. Pair with onParamsChange, which fires on every mutation.
productsProductsConfigOpt-in product strip. When set, the dropdown renders a row of product cards below the options grid, fed by your own search endpoint on the SDK's existing fetch cadence. Takes { fetch, transform }: fetch runs your search and must honour the AbortSignal it's handed, transform maps the raw payload to Product[]. Omit it and nothing changes — no request, no markup, no layout shift.
onProductSelect(product: Product) => voidCalled when the user activates a product card. The SDK never navigates — you decide what a selection means (open the product page, add to cart, fill the input). Modifier and middle clicks are left to the browser so cmd-click still opens a tab, and don't fire this.

Instance methods

Methods are available on the instance after construction. Tier 3 (headless) leans heaviest on these.

PropTypeDescription
focus()() => voidFocus the input.
blur()() => voidBlur the input (Tier 1 only).
reset()() => voidClear all state, re-fetch.
destroy()() => voidCleanup — abort fetches, clear timers, remove listeners.
setMode(mode)(mode: "light" | "dark" | "auto") => voidSwitch color mode at runtime.
setValue(text)(text: string) => voidSet text (controlled mode).
setCompletedParams(params)(params) => voidSet completed params (controlled mode).
update(opts)(opts: Partial<Options>) => voidUpdate multiple options at once (e.g. animations, pillPlacement).
handleTextChange(text)(text: string) => voidCall when the user types. Handles capitalization, param reconciliation, filter updates.
handleKeyDown(event)(event: KeyboardEvent) => voidForward keyboard events. Handles arrow nav, Enter, Tab, Escape.
setFocused(focused)(focused: boolean) => voidNotify the library that the input has focus. Required for dropdownTrigger "auto" in Tier 2/3 — the dropdown only opens while focused.
selectOption(option)(option: SuggestionOption) => voidSelect a dropdown option. Updates text, creates completed param, triggers shimmer.
selectProduct(product)(product: Product) => voidAnnounce a product-card activation, firing onProductSelect. The built-in strip calls this for you; call it yourself only if you render your own strip from the products state.
handleCaretMove(offset)(offset: number | null) => voidReport the caret's plain-text offset after a selection-only move. Needed in "dropdown" and "headless" modes, where you own the input: it's what lets the core notice the caret leaving a completed param and exit re-edit mode.
setActiveDropdownIndex(index)(index: number) => voidSet the highlighted option (e.g. for mouse hover).
setActivePill(index)(index: number) => voidMove the pill at index to the front (active).
removeLastParam()() => voidRemove last completed param, restore as a pill.
clearNewParamId()() => voidClear shimmer animation state.
getState()() => CoreStateGet a snapshot of the current state.
subscribe(listener)(listener) => () => voidSubscribe to state changes (fires after derived state settles). Returns an unsubscribe function.
on(event, handler)(event, handler) => () => voidSubscribe to a specific event. Returns an unsubscribe function.

State (CoreState)

Snapshot of the SDK's reactive state. Read it via getState() or via subscribe(state => ...).

PropTypeDescription
textstringCurrent input text.
completedParamsCompletedParamState[]Filled parameters.
skippedParamsSkippedParamState[]Suggestions the user dismissed with the skip key (→). They have no text in the input, so they live here rather than in completedParams, and are folded into the wire completed_params array (as text: "skipped") on every request and submit result.
suggestionsSuggestion[]All suggestions from server (including placeholder type).
actionableSuggestionsSuggestion[]Non-placeholder suggestions (the pills).
filteredOptionsSuggestionOption[]Options for the active suggestion, filtered by the current query.
segmentsSegment[]Input text split into typed text vs completed params — for overlay rendering.
placeholderTextstringPlaceholder text for the current step, from the server's placeholder-type suggestion.
activeDropdownIndexnumberHighlighted option index. -1 = none.
isDropdownOpenbooleanWhether the dropdown should be visible.
isFocusedbooleanWhether the input currently has focus. In "dropdown" and "headless" modes this is whatever you last passed to setFocused().
isActivePillSelectedbooleanWhether the leading pill should render in its selected state (full opacity) rather than de-emphasized. True while the dropdown is open with a tappable option highlighted; always false when dropdownTrigger is "hidden".
productsProduct[]Results of the latest product search. Always empty unless the products option is configured, and cleared on an empty query or a failed search so the strip never shows results from an older query.
newParamIdstring | nullID of the most recently added param (for shimmer).
isLoadingbooleanFetch in progress.
isReadybooleanServer indicates the query is complete.
errorError | nullLast fetch error.

Events

Subscribe to specific events with on(). The returned function unsubscribes.

events.ts
const off = ac.on("submit", (result) => console.log(result));
off(); // unsubscribe
// Available events: "submit" | "error" | "change" | "paramsChange"
// "stateChange" | "focus" | "blur" | "productSelect"