@cozeloop/ai
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

🧭 CozeLoop SDK

npm version License: MIT

English | 简体中文

Official Node.js SDK for CozeLoop API platform.

Quick Start

1. Installation

npm install @cozeloop/ai
# or
pnpm install @cozeloop/ai

2. Basic Usage

import { ApiClient, PromptHub } from '@cozeloop/ai';

// 1. setup API client
const apiClient = new ApiClient({
  baseURL: 'https://api.coze.cn',
  token: 'your_access_token',
});

// 2. Using prompt hub to get prompt
const promptHub = new PromptHub({
  // or set it as process.env.COZELOOP_WORKSPACE_ID,
  workspaceId: 'your_workspace_id',
  apiClient,
});

const prompt = await promptHub.getPrompt(
  'your_prompt_key',
  'prompt_version (optional)',
);

Key Features

  • 🗄️ Prompt Hub: Develop, submit and publish prompts on CozeLoop, and access them it via PromptHub
  • 🔐 Authentication Methods: PAT and JWT
  • ⚙️ Configurable: Timeout, headers, signal, debug options

Authentication Options

  1. Personal Access Token (PAT, the simplest way)
const apiClient = new ApiClient({
  baseURL: 'https://api.coze.cn',
  token: 'your_pat_token',
});
  1. JWT
const authFlow = new OAuthJWTFlow({
  baseURL: 'https://api.coze.cn',
  appId: '1177045121217', // Auth App Id
  aud: 'api.coze.cn', // just use api.coze.cn
  keyid: 'public_key_id of Auth App',
  privateKey: 'private_key_content',
});

const tokenResp = await authFlow.getToken();
const apiClient = new ApiClient({
  baseURL: 'https://api.coze.cn',
  token: tokenResp.access_token,
});

Package Sidebar

Install

npm i @cozeloop/ai

Weekly Downloads

8

Version

0.0.4

License

MIT

Unpacked Size

175 kB

Total Files

61

Last publish

Collaborators

  • qihaiqh