Skip to main content

Install an SDK

npm install aspect-sdk

Initialize the client

Sign up for your api key on our playground and then head to the Api keys tab
import { Aspect } from 'aspect-sdk'

const client = new Aspect({
  apiKey: 'your-api-key',
})

Create an index

Set default features to run on every asset added to the index.
const index = await client.indexes.create({
  name: 'My Collection',
  description: 'Demo assets',
  defaultFeatures: ['visual']
})

Upload an asset

Assets can be uploaded from a file path or URL. You can request extra features (e.g., transcription) in addition to the index defaults. Asset creation enqueues a task you can poll. We also offer storage management for the original file so you don’t have to worry about where your original files are. It can be toggled on with the save original field.
const { assetId } = await client.assets.create({
  indexId: index.id,
  name: 'video.mp4',
  assetFile: '/path/to/video.mp4',
  // assetUrl: '/url/to/video.mp4',
  saveOriginal: true,
  features: ['visual']
})

// Wait for completion
const done = await client.tasks.waitForDone(taskId, {
  interval: 5000,
  callback: (t) => console.log(t.features)
})

// You can create tasks for an asset at any time for features that haven't already been run.
const { taskId } = await client.tasks.create({
  assetId,
  features: ['transcription']
})

Search across assets

Once assets have the embedding feature processed, you can search across them using natural language queries.
const searchResults = await client.search.run({
  indexId: index.id,
  query: 'players running'
})

console.log('Found assets:', searchResults.assets)

Analyze images (ask, point, box)

For image assets, use analyze to answer questions or locate objects.
const askResponse = await client.analyze.ask({
  assetId,
  query: 'How many many cats are yawning'
})

const pointResponse = await client.analyze.point({
  assetId,
  query: 'All the yawning cats in the shot'
})

const boxResponse = await client.analyze.box({
  assetId,
  query: 'All the birds the cats are looking at'
})
Tip: Use webhooks to receive task status changes without polling.