Introducing hubVectorize()

Vectorize is a globally distributed vector database that enables you to build full-stack, AI-powered applications with Nuxt.
This feature is available on both free and pro plans and in @nuxthub/core >= v0.7.24.

We are excited to introduce hubVectorize(), which gives you access to a globally distributed vector database from Nuxt. Paired with hubAI(), it makes Nuxt a perfect framework for easily building full-stack AI-powered applications.

NuxtHub Vectorize command

What is a vector database?

Vector databases allows you to querying embeddings, which are representations of values or objects like text, images, audio that are designed to be consumed by machine learning models and semantic search algorithms.

Some key use cases of vector databases include:

  • Semantic search, used to return results similar to the input of the query.
  • Classification, used to return the grouping (or groupings) closest to the input query.
  • Recommendation engines, used to return content similar to the input based on different criteria (for example previous product sales, or user history).

Vector databases are commonly used for Retrieval-Augmented Generation (RAG), which is a technique that enhances language models by retrieving relevant information from an external knowledge base before generating a response.

Learn more about vector databases on Cloudflare's documentation.

How to use hubVectorize()

  1. Update @nuxthub/core to the latest version (v0.7.24 or later)
  2. Configure a Vectorize index in hub.vectorize in your nuxt.config.ts
nuxt.config.ts
export default defineNuxtConfig({
  hub: {
    vectorize: {
      tutorial: {
        dimensions: 768,
        metric: "cosine"
      }
    }
  }
})
  1. Run npx nuxthub link to link a NuxtHub project or create a new one
  2. Deploy the project to NuxtHub with npx nuxthub deploy
  3. Start Nuxt and connect to remote storage by running npx nuxt dev --remote
  4. You can now use hubVectorize('<index>') in your server routes
server/api/vectorize-search.ts
export default defineEventHandler(async (event) => {
  const { query, limit } = getQuery(event)
  const embeddings = await hubAI().run('@cf/baai/bge-base-en-v1.5', {
    text: query
  })
  const queryVector = embeddings.data[0]

  const index = hubVectorize('tutorial')
  return await vectorize.query(vectors, {
    topK: limit,
  })
})

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

If you already have a NuxtHub account, make sure to add the Vectorize 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#177.

Start with NuxtHub today