Introducing hubAI()

Run machine learning models, such as LLMs in your Nuxt application, with minimal setup.
This feature is available on both free and pro plans and in @nuxthub/core >= v0.7.2.

We are excited to introduce hubAI(). This new method allows you to run machine learning models, such as LLMs, directly within your Nuxt application with minimal setup.

At NuxtHub, we care about DX and we want to make it easy for you to leverage AI in your application using Cloudflare AI without having to manage API keys, account ID or using the wrangler CLI.

How to use hubAI()

  1. Update @nuxthub/core to the latest version (v0.7.2 or later)
  2. Enable hub.ai in your nuxt.config.ts
nuxt.config.ts
export default defineNuxtConfig({
  hub: {
    ai: true
  },
})
  1. Run npx nuxthub link to link a NuxtHub project or create a new one
  2. You can now use hubAI() in your server routes
server/api/ai-test.ts
export default defineEventHandler(async (event) => {
  return await hubAI().run('@cf/meta/llama-3.1-8b-instruct', {
    prompt: 'Who is the author of Nuxt?'
  })
})

Read the full documentation to learn more about hubAI().

If you already have a NuxtHub account, make sure to add the Worker AI permission on your Cloudflare API token.Another solution is to link again your Cloudflare account from your NuxtHub team settings by clicking on Link a new account > Create a token with required permissions.
This feature has been implemented in nuxt-hub/core#173.

Start with NuxtHub today