Embeddings
Get a vector representation of a given input.
npm i @xsai/embed
Examples
embed
import { embed } from '@xsai/embed'
import { env } from 'node:process'
const { embedding } = await embed({
apiKey: env.OPENAI_API_KEY!,
baseURL: 'https://api.openai.com/v1/',
input: 'sunny day at the beach',
model: 'text-embedding-3-large',
})
embedMany
import { embedMany } from '@xsai/embed'
import { env } from 'node:process'
const { embeddings } = await embedMany({
apiKey: env.OPENAI_API_KEY!,
baseURL: 'https://api.openai.com/v1/',
input: [
'sunny day at the beach',
'rainy afternoon in the city',
'snowy night in the mountains',
],
model: 'text-embedding-3-large'
})