Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

encode-llm-sdk

印客学院--大模型 SDK

encode, ai, llm, qwen, ernie-bot, hunyuan, minimax

readme

encode-llm-sdk

印客学院 大模型 SDK

📖 使用文档

📦 安装

要安装 encode-llm-sdk,请运行以下命令:

$ pnpm install encode-llm-sdk

👋 使用

在这里获取你的 accessToken 值。

import { ErnieAI } from 'encode-llm-sdk';

const client = new ErnieAI({
  apiKey: 'My API Key', // defaults to process.env["EB_API_KEY"]
});

async function main() {
  const chatCompletion = await client.chat.completions.create({
    model: 'ernie-bot-turbo',
    messages: [{ role: 'user', content: 'Say this is a test' }],
  });
}

main();

支持流式

使用与 OpenAI 的 SDK 完全一致。

import { ErnieAI } from 'encode-llm-sdk';

const client = new ErnieAI();

async function main() {
  const stream = await client.chat.completions.create({
    model: 'ernie-bot-turbo',
    messages: [{ role: 'user', content: 'Say this is a test' }],
    stream: true,
  });

  for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content || '');
  }
}

main();