typescriptintermediate

Clustering Embeddings

AI/ML technique: clustering-embeddings

typescript
import OpenAI from "openai";

const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

const input = ["vector search", "semantic retrieval"]; 
const res = await client.embeddings.create({
  model: "text-embedding-3-small",
  input,
});

console.log(res.data.map((x) => x.embedding.length));

Use Cases

  • machine learning
  • AI applications

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.