---
title: "System One 决策 SDK 类型化判断。"
description: "用 System One 决策 SDK，一次 evaluate() 接入结构化决策。定义选项、打分量表与是否问题，在应用中直接使用类型化答案。"
canonical: "https://system-one.dev/zh-CN/sdk"
language: "zh-CN"
---

# System One 决策 SDK 类型化判断。

用 System One 决策 SDK，一次 evaluate() 接入结构化决策。定义选项、打分量表与是否问题，在应用中直接使用类型化答案。

开源 · TypeScript · Node.js

## 安装 SDK

```sh
npm install @system-one-ai/core@0.8.0 @system-one-ai/adapter-system-one@0.7.0 @system-one-ai/transport-fetch@0.8.0
```
## 连接模型服务

安装 core、服务适配器与 transport。为 System One API 配置 systemOneAdapter 与 createFetchTransport()。凭证保存在服务器环境中。

```ts
import { createSystemOne, choice } from '@system-one-ai/core';
import { systemOneAdapter } from '@system-one-ai/adapter-system-one';
import { createFetchTransport } from '@system-one-ai/transport-fetch';

const client = createSystemOne({
  adapter: systemOneAdapter,
  transport: createFetchTransport(),
  baseURL: process.env.SYSTEM_ONE_BASE_URL!,
  apiKey: process.env.SYSTEM_ONE_API_KEY!,
  maxRetries: 0,
});

const result = await client.evaluate({
  state: { message: 'I was charged twice.' },
  questions: {
    team: choice('Who should handle this?', {
      billing: 'Payments and refunds',
      support: 'Technical issues',
    }),
  },
});

result.answers.team.choice; // 'billing' | 'support'
```
## 统一的结构化决策接口

### 从问题到答案的类型

Choice 结果将选项名保留为 TypeScript 字面量类型。Score 与是否概率以数字返回。

### 连接你的提供方

可直接使用 System One API。可选的 Vercel AI SDK 适配器可连接其他受支持的模型服务。

### 控制请求行为

配置超时与重试，用 AbortSignal 取消，并在应用中处理类型化错误。

## 连接到 System One API

使用 System One API 密钥调用托管服务。在 Playground 测试输入，并在控制台查看请求用量。

[将 SDK 连接到托管 API](https://docs.system-one.dev/zh-CN/docs/getting-started)

## 从这里开始

- [开发文档](https://docs.system-one.dev/zh-CN)
- [版本与弃用规则](https://docs.system-one.dev/zh-CN/docs/api/versioning)
- [幂等与重试](https://docs.system-one.dev/zh-CN/docs/api/idempotency)
- [API 错误](https://docs.system-one.dev/zh-CN/docs/api/errors)
- [TypeScript SDK](https://system-one.dev/zh-CN/sdk)
- [API 参考](https://system-one.dev/zh-CN/api)
- [模型](https://system-one.dev/zh-CN/models)
- [模型目录](https://docs.system-one.dev/zh-CN/docs/models)
- [认证](https://system-one.dev/zh-CN/auth.md)
- [定价](https://system-one.dev/zh-CN/pricing)
- [积分计费](https://docs.system-one.dev/zh-CN/docs/billing)
- [OpenAPI 定义](https://system-one.dev/openapi.json)
- [智能体接入指南](https://system-one.dev/zh-CN/skill.md)
- [Cursor、Claude Code、Codex 接入 System One 教程](https://docs.system-one.dev/zh-CN/docs/coding-agents)
- [可安装的编程智能体技能](https://system-one.dev/skills/system-one/SKILL.md)
- [关于](https://system-one.dev/zh-CN/about)
- [联系](https://system-one.dev/zh-CN/contact)
- [Playground 示例](https://system-one.dev/zh-CN/demo)
- [博客](https://system-one.dev/zh-CN/blog)
- [SDK 源码](https://github.com/ziyu/system-one-sdk)
- [@system-one-ai/core (npm)](https://www.npmjs.com/package/@system-one-ai/core)
