Docs/Use it in your stack

Svelte and SvelteKit

Add the tag to app.html and call it from a component.

src/app.html (inside <head>)
<script src="https://cdn.chargemy.ai/v1/charge.js"></script>
Ask.svelte
<script>
  let text = $state('')
  let reply = $state('')
  async function run() {
    reply = (await window.charge.ai.chat(text)).text
  }
</script>

<textarea bind:value={text}></textarea>
<button onclick={run}>Ask</button>
<p>{reply}</p>

Call it from event handlers or onMount, never during server-side rendering.

Read next

Still stuck? Talk to us and we'll help.