npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

volcengine-ark-sdk

v0.0.9

Published

火山引擎 | 火山方舟 TypeScript SDK

Readme

volcengine-ark-sdk

火山引擎 | 火山方舟 TypeScript SDK

官方文档: https://www.volcengine.com/docs/82379/1494384?lang=zh

声明: 非官方 SDK. 官方未提供 TypeScript SDK,且 openai sdk 兼容方案诸多属性不支持,如 reasoning_content,并且需要引入 openapi 库才能使用。

基于火山引擎 openapi 规范实现的 TypeScript SDK,仅支持 Chat API (对话 API)。

安装

pnpm add volcengine-ark-sdk

> yarn add volcengine-ark-sdk
> npm install volcengine-ark-sdk

使用

初始化 Client

  • apiKey: 火山引擎方舟的 api key
  • baseUrl: 火山引擎方舟的 base url,默认值为 https://ark.cn-beijing.volces.com/api/v3/chat/completions
import { ArkChatCompletions } from 'volcengine-ark-sdk';

const apiKey = ''; // 火山引擎方舟的 api key

const client = new ArkChatCompletions({
  apiKey,
});

非流式请求

const model = ''; // 模型名称或火山引擎方舟的接入点(多模型混用的场景)

const response = await client.request({
    model,
    messages: [
      {
        role: 'user',
        content: '你好',
      },
    ],
});

读取 content

const content = response.choices[0].message.content;

读取 reasoning_content

const reasoningContent = response.choices[0].message.reasoning_content;

流式请求

const model = ''; // 模型名称或火山引擎方舟的接入点(多模型混用的场景)

const response = await client.stream({
    model,
    messages: [
      {
        role: 'user',
        content: '你好',
      },
    ],
});

for await (const chunk of response) {
    console.log(chunk);
}

读取 content

const content = chunk.choices[0].delta.content;

读取 reasoning_content

const reasoningContent = chunk.choices[0].delta.reasoning_content;

响应结构

非流式请求

{
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "logprobs": null,
            "message": {
                "content": "你好呀,很高兴和你交流,有什么问题或者想聊的都可以告诉我~",
                "reasoning_content": "用户现在说“你好”,我需要友好回应。首先,保持自然亲切,比如“你好呀,很高兴和你交流,有什么问题或者想聊的都可以告诉我~”这样就可以了,既回应了问候,又开放了对话。",
                "role": "assistant"
            }
        }
    ],
    "created": 1771690638,
    "id": "",
    "model": "doubao-seed-1-6-thinking-agent-preview", // 实际使用的模型
    "service_tier": "default",
    "object": "chat.completion",
    "usage": {
        "completion_tokens": 78,
        "prompt_tokens": 34,
        "total_tokens": 112,
        "prompt_tokens_details": {
            "cached_tokens": 0
        },
        "completion_tokens_details": {
            "reasoning_tokens": 58
        }
    }
}

流式请求响应结构

{
    "choices": [
      {
        "delta": {
          "content": "~",
          "role": "assistant"
        },
        "index": 0
      }
    ],
    "created": 1771689823,
    "id": "021771689812785933bcb8fff5a6e275f05e6439785ee79b003a5",
    "model": "doubao-seed-1-6-thinking-agent-preview",
    "service_tier": "default",
    "object": "chat.completion.chunk",
    "usage": {
      "completion_tokens": 73,
      "prompt_tokens": 34,
      "total_tokens": 107,
      "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 34
      },
      "completion_tokens_details": {
        "reasoning_tokens": 50
      }
    }
  }
  
// 每个 chunk 都是一个增量响应,usage 表示截止当前 chunk 的消耗数据,最后一个 chunk 表示整体消耗的 token 数据
{
    "choices": [
      {
        "delta": {
          "content": "",
          "role": "assistant"
        },
        "finish_reason": "stop",
        "index": 0
      }
    ],
    "created": 1771689823,
    "id": "",
    "model": "doubao-seed-1-6-thinking-agent-preview",
    "service_tier": "default",
    "object": "chat.completion.chunk",
    "usage": {
      "completion_tokens": 73,
      "prompt_tokens": 34,
      "total_tokens": 107,
      "prompt_tokens_details": {
        "cached_tokens": 0,
        "text_tokens": 34
      },
      "completion_tokens_details": {
        "reasoning_tokens": 50
      }
    }
  }

// 默认有一个空 chunk,最后一个 chunk 表示整体消耗的 token 数据
  {
    "choices": [],
    "created": 1771689823,
    "id": "",
    "model": "doubao-seed-1-6-thinking-agent-preview",
    "object": "chat.completion.chunk",
    "usage": {
      "completion_tokens": 73,
      "prompt_tokens": 34,
      "total_tokens": 107,
      "prompt_tokens_details": {
        "cached_tokens": 0
      },
      "completion_tokens_details": {
        "reasoning_tokens": 50
      }
    }
  }