@amigo-ai/sdk

中文文档
2.1.0发布于 2026/09/08MITTypeScriptESM + CJS构建来源已验证近 30 天下载 3244

Official TypeScript SDK for the Classic Amigo API at api.amigo.ai

原始使用文档
文档目录12 节
  1. Classic Backend Context
  2. Product Status
  3. Choose The Right SDK
  4. Documentation
  5. Installation
  6. Quick Start
  7. Configuration
  8. Runtime Requirements
  9. Generated Types
  10. Retries
  11. Error Handling
  12. Support

Amigo banner

@amigo-ai/sdk

Official TypeScript SDK for the Classic Amigo API.

Product Docs · Developer Guide · API Reference · Examples · Changelog

npm version CI codecov MIT License

Typed from the committed Classic OpenAPI snapshot, shipped as ESM and CommonJS, and used by existing org-scoped integrations on the original Amigo backend at api.amigo.ai.

Classic Backend Context

@amigo-ai/sdk targets the original org-scoped Amigo backend. Existing deployments still use this surface for conversations, services, organizations, users, agents, context graphs, webhooks, and streaming events.

Classic text session flow

Product Status

@amigo-ai/sdk remains the supported TypeScript client for the Classic API.

The Platform API is where new workspace-scoped capabilities land first, but the Classic API is not being switched off abruptly. Amigo will publish a migration path, compatibility notes, and upgrade guidance before asking customers to move production workloads.

Choose The Right SDK

If you needStart here
Existing org-scoped integrations on api.amigo.ai@amigo-ai/sdk
New workspace-scoped integrations on api.platform.amigo.ai@amigo-ai/platform-sdk

Documentation

NeedBest entry point
Product overview and deployment contextdocs.amigo.ai
Integration guidance and developer docsDeveloper Guide
Generated API referenceamigo-ai.github.io/amigo-typescript-sdk
Runnable examplesexamples/
Release historyCHANGELOG.md

The docs site remains the primary reference. The repo-local examples stay close to the shipped package surface and are validated in CI.

Installation

npm install @amigo-ai/sdk

Before making requests, obtain Classic organization credentials and a user authorized to read the target resources. Keep API keys in server-side environment variables or a secret manager. The examples below read conversation data; they require access to an existing organization.

For the 2.0.0 generated-model changes, review the current SDK upgrade guidance and recheck the package registry when choosing a version.

Quick Start

import { AmigoClient } from '@amigo-ai/sdk'

const client = new AmigoClient({
  apiKey: 'your-api-key',
  apiKeyId: 'your-api-key-id',
  userId: 'user-id',
  orgId: 'your-organization-id',
})

const conversations = await client.conversations.getConversations({
  limit: 10,
  sort_by: ['-created_at'],
})

console.log(conversations.conversations.map(conversation => conversation.id))

Configuration

OptionTypeRequiredDescription
apiKeystringYesAPI key from the Amigo dashboard
apiKeyIdstringYesAPI key ID paired with apiKey
userIdstringYesUser ID on whose behalf the request is made
orgIdstringYesOrganization ID for the classic API
baseUrlstringNoOverride the API base URL. Defaults to https://api.amigo.ai
retryRetryOptionsNoRetry policy overrides for transient HTTP failures

Runtime Requirements

The SDK supports Node 18+ and is tested on active Node releases in CI. It relies on web-standard primitives such as fetch, AbortController, URL, and TextEncoder.

Generated Types

The package re-exports the generated OpenAPI types so application code can type directly against the API contract:

import type { components, operations, paths } from '@amigo-ai/sdk'

type Conversation = components['schemas']['ConversationInstance']
type GetConversationsQuery = operations['get-conversations']['parameters']['query']

Public builds are generated from the committed specs/openapi-baseline.json snapshot in this repo so type output stays deterministic across machines and CI runs. When you need to refresh that snapshot, run:

npm run openapi:sync

Retries

The HTTP client retries transient failures with sensible defaults:

  • Max attempts: 3
  • Backoff base: 250ms with full jitter
  • Max delay per attempt: 30s
  • Statuses: 408, 429, 500, 502, 503, 504
  • Methods: GET, plus POST on 429 when Retry-After is present

Error Handling

import { AmigoClient, AuthenticationError, NetworkError } from '@amigo-ai/sdk'

try {
  const client = new AmigoClient({
    apiKey: 'your-api-key',
    apiKeyId: 'your-api-key-id',
    userId: 'user-id',
    orgId: 'your-organization-id',
  })

  await client.organizations.getOrganization()
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Authentication failed:', error.message)
  } else if (error instanceof NetworkError) {
    console.error('Network error:', error.message)
  } else {
    console.error('Unexpected error:', error)
  }
}

Support

Use the issue tracker for bugs and feature requests. For responsible disclosure, see SECURITY.md.

版本与发布记录

@amigo-ai/sdk 共发布 115 个版本,首次发布于 2025/08/08;过去 12 个月发布了 61 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.0latest2026/09/081 个月前
2.0.02026/09/081 个月前
1.1.32026/05/016 个月前
1.1.22026/05/016 个月前
1.1.12026/05/016 个月前
1.1.02026/05/016 个月前

其他发布通道:alpha → 1.0.0-alpha.4,rc → 1.0.0-rc.3。

关于 @amigo-ai/sdk 的常见问题

@amigo-ai/sdk 是什么?

Official TypeScript SDK for the Classic Amigo API at api.amigo.ai

如何安装 @amigo-ai/sdk?

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

@amigo-ai/sdk 支持 TypeScript 吗?

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

@amigo-ai/sdk 支持 ESM 还是 CommonJS?

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

@amigo-ai/sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@amigo-ai/sdk 可以商用吗?

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

@amigo-ai/sdk 的下载量有多少?

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

@amigo-ai/sdk 还在维护吗?

最新版本 2.1.0 发布于 2026/09/08(1 个月前);至今共发布 115 个版本,其中过去 12 个月发布了 61 个;首次发布于 2025/08/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。