Skip to content

Latest commit

 

History

History
212 lines (154 loc) · 14.3 KB

File metadata and controls

212 lines (154 loc) · 14.3 KB

AiFeatures

Overview

Available Operations

updateSummary

This endpoint allows you to generate the summary for an existing media.

How it works

  1. Send a PATCH request to this endpoint, replacing <mediaId> with the ID of the media you want to summarize.
  2. Include the generate parameter in the request body.
  3. Include the summaryLength parameter, specify the desired length of the summary in words (for example, 120 words), this determines how concise or detailed the summary will be. If no specific summary length is provided, the default length will be 100 words.
  4. The response includes the updated media data and confirmation of the changes applied.

You can use the video.mediaAI.summary.ready webhook event to track and notify about the summary generation.

Use case: This is particularly useful when a user uploads a video and later chooses to generate a summary without needing to re-upload the video.

Related guide: Video summary

Example Usage

import { Fastpix } from "@fastpix/fastpix-node";

const fastpix = new Fastpix({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const result = await fastpix.aiFeatures.updateSummary({
    mediaId: "your-media-id",
    body: {
      generate: true,
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { aiFeaturesUpdateSummary } from "@fastpix/fastpix-node/funcs/aiFeaturesUpdateSummary.js";

// Use `FastpixCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fastpix = new FastpixCore({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const res = await aiFeaturesUpdateSummary(fastpix, {
    mediaId: "your-media-id",
    body: {
      generate: true,
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aiFeaturesUpdateSummary failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.UpdateMediaSummaryRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.UpdateMediaSummaryResponse>

Errors

Error Type Status Code Content Type
errors.FastpixDefaultError 4XX, 5XX */*

generateNamedEntities

This endpoint allows you to extract named entities from an existing media. Named Entity Recognition (NER) is a fundamental natural language processing (NLP) technique that identifies and classifies key information (entities) in text into predefined categories. For instance:

  • Organizations (for example, "Microsoft", "United Nations")
  • Locations (for example, "Paris", "Mount Everest")
  • Product names (for example, "iPhone", "Coca-Cola")

How it works

  1. Make a PATCH request to this endpoint, replacing <mediaId> with the ID of the media you want to extract named-entities.
  2. Include the namedEntities parameter in the request body to enable.
  3. Receive a response containing the updated media data, confirming the changes made.

You can use the video.mediaAI.named-entities.ready webhook event to track and notify about the named entities extraction.

Use case: If a user uploads a video and later decides to enable named entity extraction without re-uploading the entire video.

Related guide: Named entities

Example Usage

import { Fastpix } from "@fastpix/fastpix-node";

const fastpix = new Fastpix({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const result = await fastpix.aiFeatures.generateNamedEntities({
    mediaId: "your-media-id",
    body: {
      namedEntities: true,
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { FastpixCore } from "@fastpix/fastpix-node/core.js";
import { aiFeaturesGenerateNamedEntities } from "@fastpix/fastpix-node/funcs/aiFeaturesGenerateNamedEntities.js";

// Use `FastpixCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const fastpix = new FastpixCore({
  security: {
    username: "your-access-token",
    password: "your-secret-key",
  },
});

async function run() {
  const res = await aiFeaturesGenerateNamedEntities(fastpix, {
    mediaId: "your-media-id",
    body: {
      namedEntities: true,
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aiFeaturesGenerateNamedEntities failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.UpdateMediaNamedEntitiesRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.UpdateMediaNamedEntitiesResponse>

Errors

Error Type Status Code Content Type
errors.FastpixDefaultError 4XX, 5XX */*