JavaScript SDK

Mount the oprag chat widget, or build your own chat UI on a typed client — in a browser or on a server, from one package.

Browser or server Embed key in the browser, integration key on the server dev · https://api.dev.oprag.ai

@oprag/sdk is one package with two entries. @oprag/sdk/widget mounts the same chat widget the CDN script ships, with types and programmatic control. @oprag/sdk gives you the typed client the widget uses internally, and imports cleanly on a server because nothing in it touches a DOM global at module scope.

Pick a path

Where each key goes

RuntimeKey kindPrefixEnv varRule
BrowserEmbed keyembed_test_… / embed_live_…PUBLIC_OPRAG_EMBED_KEYShips in the bundle. Locked to the origins you allowlist on the project.
ServerIntegration keysk_test_… / sk_live_…OPRAG_SECRET_KEYRead from the process environment. Never sent to, or through, a browser.

What the two entries export

EntryRuntimeExports
@oprag/sdkBrowser or servercreateClient, isBrowser, citationDisplayLabel, statusToCode, OpragError, OpragConfigError, CreateClientOptions, OpragClient, ChatInput, ChatAskOptions, ChatStreamOptions, ChatResponse, CitationSource, LeadCreateInput
@oprag/sdk/widgetBrowser onlymountWidget, MountWidgetOptions, WidgetHandle, WidgetTheme

Every symbol is listed with its signature on the API reference. Looking for the REST endpoints underneath? They are in the REST API tree.

Ready to ship?

Get started free