@eyepop.ai/eyepop

中文文档
4.0.0发布于 2026/11/14MITTypeScriptESM + CJS构建来源已验证近 30 天下载 3610

The official Node.js / Typescript library for EyePop.ai's inference API

原始使用文档
文档目录19 节
  1. Installation
  2. Node
  3. Browser
  4. React Native
  5. Authentication
  6. Server-Side API Key
  7. Persistent Sessions
  8. Browser and Mobile Clients
  9. Browser OAuth for Local Dashboard Demos
  10. Processing Media
  11. Local Files
  12. Readable Streams
  13. Public URLs
  14. Image Groups (multiple images, one result)
  15. Canceling Jobs
  16. Endpoint Options
  17. Visualization
  18. Data Endpoint Preview
  19. Composable Pops

EyePop.ai Node SDK

The EyePop.ai Node SDK provides JavaScript and TypeScript access to EyePop worker sessions for image and video inference.

Installation

Node

Requires Node.js 18 or newer. CI validates Node.js 22.

npm install --save @eyepop.ai/eyepop

See the Node examples for runnable scripts.

Browser

Browser applications can use the bundled SDK directly:

<script src="https://cdn.jsdelivr.net/npm/@eyepop.ai/eyepop/dist/eyepop.min.js"></script>

API keys must not be used in browser code. Browser apps should connect with sessions created by your trusted backend.

React Native

React Native applications should use the React Native package:

npm install --save @eyepop.ai/react-native-eyepop

See the React Native example.

Authentication

The SDK supports these authentication patterns:

  • API key authentication for trusted server-side code.
  • Persistent worker session selection for provisioned deployments.
  • Browser OAuth for dashboard users building local demos.

Server-Side API Key

Set EYEPOP_API_KEY in your server environment. API keys are secrets and must not be exposed in browser bundles, mobile app bundles, or public repositories.

export EYEPOP_API_KEY=<your_api_key>

Create transient sessions with a pop when the worker endpoint is constructed. This lets EyePop schedule the right compute before media is processed.

import { EyePop } from '@eyepop.ai/eyepop'
;(async () => {
    const endpoint = await EyePop.workerEndpoint({
        pop: {
            components: [
                {
                    type: 'inference',
                    ability: 'eyepop.person:latest',
                    categoryName: 'person',
                },
            ],
        },
    }).connect()
    try {
        const results = await endpoint.process({ source: { path: 'examples/example.jpg' } })
        for await (const result of results) {
            console.log(result)
        }
    } finally {
        await endpoint.disconnect()
    }
})()

For transient sessions, pass pop when creating the endpoint whenever possible. Use endpoint.changePop(pop) only when an already connected transient worker needs to switch Pops.

Pipeline mode is the default and runs no worker session; EYEPOP_ENV=staging|production|local picks its pipeline API. With isPipelineMode: false (or EYEPOP_PIPELINE_MODE=false) and no sessionUuid, the SDK creates compute sessions with POST /v1/sessions?wait=true.

ModelLess CPU pops use the same constructor-pop path:

const endpoint = await EyePop.workerEndpoint({
    pop: {
        components: [
            {
                type: 'inference',
                ability: 'eyepop.localize-objects:latest',
                categoryName: 'objects',
                params: {
                    prompts: [{ prompt: 'person' }],
                },
            },
        ],
    },
}).connect()

You can also pass the key explicitly from server-side configuration:

const endpoint = await EyePop.workerEndpoint({
    apiKey: process.env.EYEPOP_API_KEY,
}).connect()

accessToken is accepted as the same bearer credential shape:

const endpoint = await EyePop.workerEndpoint({
    accessToken: process.env.EYEPOP_ACCESS_TOKEN,
}).connect()

The nested auth option is still supported but deprecated. Pass apiKey, accessToken, session, or oAuth2 at the top level for new code.

Persistent Sessions

If EyePop has provisioned a persistent worker session for your deployment, set EYEPOP_SESSION_UUID in the trusted server environment or pass sessionUuid explicitly, with pipeline mode off (isPipelineMode: false).

export EYEPOP_API_KEY=<your_api_key>
export EYEPOP_SESSION_UUID=<your_session_uuid>
import { EyePop } from '@eyepop.ai/eyepop'
;(async () => {
    const endpoint = await EyePop.workerEndpoint({
        sessionUuid: process.env.EYEPOP_SESSION_UUID,
        isPipelineMode: false,
    }).connect()

    try {
        const results = await endpoint.process({ source: { path: 'sample.mp4' } })
        for await (const result of results) {
            console.log(result)
        }
    } finally {
        await endpoint.disconnect()
    }
})()

Persistent sessions are normally preconfigured. In that case, process media directly and do not call changePop() unless your deployment is meant to accept runtime Pop changes.

Persistent deployments are created through compute-api or EyePop tooling. For example, a trusted server can create a persistent deployment with an inline pop and then pass the returned session_uuid to the SDK:

curl -sS -X POST "https://compute.eyepop.ai/v1/deployments?wait=true" \
  -H "Authorization: Bearer $EYEPOP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "display_name": "node-modeless-deployment",
    "pop": {
      "components": [
        {
          "type": "inference",
          "ability": "eyepop.localize-objects:latest",
          "categoryName": "objects",
          "params": {
            "prompts": [{ "prompt": "person" }]
          }
        }
      ]
    }
  }'

The response includes session_uuid, session_status, status_url, and worker access metadata. Poll status_url until the deployment reaches pipeline_ok, then connect with sessionUuid.

Browser and Mobile Clients

Do not put EYEPOP_API_KEY in browser or mobile application code. Create EyePop sessions from a trusted backend, then pass only the session JSON to the client.

Browser OAuth for Local Dashboard Demos

Dashboard users can run local browser demos with the current browser session:

<script>
    document.addEventListener('DOMContentLoaded', async () => {
        const endpoint = await EyePop.workerEndpoint({ oAuth2: true }).connect()
        try {
            await endpoint.changePop({
                components: [
                    {
                        type: 'inference',
                        ability: 'eyepop.person:latest',
                        categoryName: 'person',
                    },
                ],
            })
        } finally {
            await endpoint.disconnect()
        }
    })
</script>

Processing Media

Local Files

const results = await endpoint.process({ source: { path: 'examples/example.jpg' } })
for await (const result of results) {
    console.log(result)
}

process() returns an AsyncIterable of predictions. Images normally produce one prediction. Videos and animated image containers produce one prediction per frame.

Readable Streams

Streams require an explicit MIME type:

import fs from 'node:fs'

const stream = fs.createReadStream('examples/example.jpg')
const results = await endpoint.process({
    source: { stream, mimeType: 'image/jpeg' },
})

Public URLs

Public HTTP(S), RTSP, and RTMP URLs can be processed without uploading the file from your application.

const results = await endpoint.process({
    source: { url: 'https://demo-eyepop-videos.s3.amazonaws.com/test1_vlog.mp4' },
})

Image Groups (multiple images, one result)

Send several images as a single source that the pop processes together as one inference unit — for example a multi-image VLM prompt. The group yields one prediction for the whole set, unlike batching below, where each image is an independent inference.

// Local files
const results = await endpoint.uploadGroup(['a.jpg', 'b.jpg', 'c.jpg'])
for await (const result of results) {
    console.log(result)
}

// In-memory streams (optional parallel MIME types)
import fs from 'node:fs'
import { Readable } from 'node:stream'
const stream1 = Readable.toWeb(fs.createReadStream('a.jpg'))
const stream2 = Readable.toWeb(fs.createReadStream('b.jpg'))
const results = await endpoint.uploadStreamGroup([stream1, stream2], ['image/jpeg', 'image/jpeg'])

// Remote URLs (the server fetches each)
const results = await endpoint.loadFromGroup(['https://example.com/a.jpg', 'https://example.com/b.jpg'])

Image order is preserved end-to-end. A group may contain up to 16 images (enforced server-side). The pop's ability must be multi-image-capable; a single-image ability handed a group returns an error.

Canceling Jobs

Queued and in-progress jobs can be cancelled from the result iterator:

const results = await endpoint.process({
    source: { url: 'https://demo-eyepop-videos.s3.amazonaws.com/test1_vlog.mp4' },
})

for await (const result of results) {
    console.log(result)
    if ((result.seconds ?? 0) >= 10) {
        results.cancel()
    }
}

Endpoint Options

By default, EyePop.workerEndpoint({ pop }).connect() starts a transient worker when needed and cancels queued jobs on that worker when it connects.

Disable worker startup:

const endpoint = await EyePop.workerEndpoint({ pop, autoStart: false }).connect()

Keep pending jobs:

const endpoint = await EyePop.workerEndpoint({ pop, stopJobs: false }).connect()

Visualization

Rendering helpers are provided by @eyepop.ai/eyepop-render-2d.

Data Endpoint Preview

EyePop.dataEndpoint() provides preview support for dataset management and model optimization workflows. This API is experimental and subject to change.

Composable Pops

See Composable Pops for client-side Pop composition.

版本与发布记录

@eyepop.ai/eyepop 共发布 153 个版本,首次发布于 2024/01/25;过去 12 个月发布了 51 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.0.0latest2026/11/14今天
4.0.0-rc.3next2026/11/14今天
4.0.0-rc.22026/11/131 天前
4.0.0-rc.12026/11/131 天前
3.27.12026/11/131 天前
3.27.02026/11/104 天前

关于 @eyepop.ai/eyepop 的常见问题

@eyepop.ai/eyepop 是什么?

The official Node.js / Typescript library for EyePop.ai's inference API

如何安装 @eyepop.ai/eyepop?

在项目目录运行 npm install @eyepop.ai/eyepop,或使用 pnpm add / yarn add / bun add。

@eyepop.ai/eyepop 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@eyepop.ai/eyepop 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@eyepop.ai/eyepop 可以商用吗?

@eyepop.ai/eyepop 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@eyepop.ai/eyepop 的下载量有多少?

根据 npm 官方下载统计,@eyepop.ai/eyepop 在 2026/10/14 – 2026/11/12 这 30 天内被下载 3,610 次,日均约 120 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@eyepop.ai/eyepop 还在维护吗?

最新版本 4.0.0 发布于 2026/11/14(今天);至今共发布 153 个版本,其中过去 12 个月发布了 51 个;首次发布于 2024/01/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。