概览
@arizeai/ax-client 是Arize AX REST API 的 TypeScript 客户端。 它仍在积极发展之中,并可能发生变化.
Arize是一个AI工程平台. 它帮助工程师开发,评价和观察AI应用和代理.
阿里兹有企业和开放源码软件产品支持这一目标:
关键特性
- 追踪 - 追踪你的LLM应用的运行时间 使用基于OpenTelemetry的仪器.
- 评价 - 利用 LLMs 来使用响应和检索 evals 来衡量您的应用程序的性能.
- 数据集 - 建立用于实验、评价和微调的例子的版本数据集.
- 实验 - 跟踪和评估对提示、LLMs和检索的更改.
- 游戏场- 优化提示,比较模型,调整参数,并重放追踪的LLM呼叫.
- 快速管理- 使用版本控制、标记和实验系统管理和测试快速变化.
目录
- 概览
- 关键特性
- 安装
- 配置
- 数据集
- 实验
- 提示
- 评价员
- 任务
- 西班牙语
- 追踪
- 注释配置
- 注释队列
- AI 一体化
- 一体化
- 项目
- API 密钥
- 作用
- 作用约束
- 资源限制
- 组织
- 组织成员
- 用户
- 空间
- 空间成员
- 网络呼号
- Webhook 订阅
- REST 终点
安装
# or yarn, pnpm, bun, etc.
npm install @arizeai/ax-client
配置
如果有的话,客户端会自动读取环境变量.
使用了下列环境变量:
ARIZE_API_KEY- 用于认证的 API 密钥 .ARIZE_BASE_URL- 阿里泽AX API的基础URL.
或者,你可以直接将配置选项传递给客户端, 并且它们将优先于环境变量和默认值.
数据集
这个 @arizeai/ax-client 软件包允许您创建和管理数据集及其示例.
列出数据集
import { listDatasets } from "@arizeai/ax-client";
const datasets = await listDatasets({ space: "my-space" });
console.log(datasets);
创建数据集
通过提供一个空格(名称或ID),名称,和示例阵列(每个都包含至少一个属性)来创建数据集.
import { createDataset } from "@arizeai/ax-client";
const dataset = await createDataset({
name: "my-dataset",
space: "my-space",
examples: [{ question: "What is 2+2?", answer: "4", topic: "math" }],
});
获取数据集
import { getDataset } from "@arizeai/ax-client";
const dataset = await getDataset({ dataset: "my-dataset", space: "my-space" });
console.log(dataset);
更新数据集
import { updateDataset } from "@arizeai/ax-client";
const dataset = await updateDataset({
dataset: "my-dataset",
space: "my-space",
name: "my-renamed-dataset",
});
删除数据集
import { deleteDataset } from "@arizeai/ax-client";
await deleteDataset({ dataset: "my-dataset", space: "my-space" });
列出数据集实例
列出数据集的实例. filter 是可选 SQL 类表达式
用于更复杂的查询.
import { listDatasetExamples } from "@arizeai/ax-client";
const examples = await listDatasetExamples({
dataset: "my-dataset",
space: "my-space",
});
console.log(examples);
const filtered = await listDatasetExamples({
dataset: "my-dataset",
space: "my-space",
filter: "question = 'What is 2+2?'",
});
console.log(filtered);
补充数据集示例
import { appendExamples } from "@arizeai/ax-client";
const result = await appendExamples({
dataset: "my-dataset",
space: "my-space",
examples: [{ question: "What is 2+2?", answer: "4", topic: "math" }],
});
console.log(result.exampleIds); // IDs of the inserted examples
更新数据集实例
更新示例创建了数据集的新版本.
import { updateExamples } from "@arizeai/ax-client";
const dataset = await updateExamples({
dataset: "my-dataset",
space: "my-space",
examples: [{ id: "your_example_id", question: "What is 2+2?", answer: "4" }],
newVersionName: "your_new_version_name",
});
注释数据集示例
import { annotateDatasetExamples } from "@arizeai/ax-client";
await annotateDatasetExamples({
space: "my-space",
dataset: "my-dataset",
annotations: [
{
recordId: "example_id_abc123",
values: [
{ name: "quality", score: 0.9 },
{ name: "topic", label: "science" },
],
},
],
});
删除数据集示例
实例从给定版本中删除;没有创建出新版本. 删除是部分容忍的,是一意孤行的——结果报告删除了身份证,但没有.
import { deleteDatasetExamples } from "@arizeai/ax-client";
const result = await deleteDatasetExamples({
dataset: "my-dataset",
space: "my-space",
datasetVersionId: "your_dataset_version_id",
examples: ["example_id_1", "example_id_2"],
});
console.log(
result.completed,
result.deletedExampleIds,
result.notDeletedExampleIds,
);
实验
这个 @arizeai/ax-client 软件包允许您创建和管理实验及其运行.
列出试验
import { listExperiments } from "@arizeai/ax-client";
const experiments = await listExperiments({
dataset: "my-dataset",
space: "my-space",
});
console.log(experiments);
创建实验
import { createExperiment } from "@arizeai/ax-client";
const experiment = await createExperiment({
experimentName: "my-experiment",
dataset: "my-dataset",
space: "my-space",
experimentRuns: [],
});
console.log(experiment);
进行实验
import { getExperiment } from "@arizeai/ax-client";
// Using names
const experiment = await getExperiment({
experiment: "my-experiment",
dataset: "my-dataset",
space: "my-space",
});
// Using an ID directly
const byId = await getExperiment({ experiment: "your_experiment_id" });
删除实验
import { deleteExperiment } from "@arizeai/ax-client";
await deleteExperiment({
experiment: "my-experiment",
dataset: "my-dataset",
space: "my-space",
});
列表实验运行
通过提供实验名称或ID(在使用名称时需要空间和数据集上下文)进行列表运行的实验,可选择由类似 SQL 的缩入 filter 超编栏、评价eval.<name>.score)和说明(a/cn.9/wg.iii/wp.30)annotation.<name>.*) (中文(简体) ). 运行以稳定的ID升序返回——通过 pagination.nextCursor 恢复为 cursor 以获取下页,在呼求时保持过滤器不变.
import { listExperimentRuns } from "@arizeai/ax-client";
const experimentRuns = await listExperimentRuns({
experiment: "my-experiment",
dataset: "my-dataset",
space: "my-space",
});
const filtered = await listExperimentRuns({
experiment: "my-experiment",
dataset: "my-dataset",
space: "my-space",
filter: "eval.quality.score < 0.5",
limit: 50,
});
console.log(filtered.data);
辅助实验运行
将1到1000个新运行的线路附加到现有的实验中. 每次运行必须包括 exampleId (实验数据集示例的标识)和 output。响应包括更新的实验和以输入顺序生成的运行的ID.
import { appendExperimentRuns } from "@arizeai/ax-client";
const result = await appendExperimentRuns({
space: "my-space",
dataset: "my-dataset",
experiment: "my-experiment",
experimentRuns: [{ exampleId: "ex_abc123", output: "The answer is 42" }],
});
console.log(result.runIds); // IDs of the appended runs
注释实验运行
import { annotateExperimentRuns } from "@arizeai/ax-client";
await annotateExperimentRuns({
space: "my-space",
dataset: "my-dataset",
experiment: "my-experiment",
annotations: [
{
recordId: "run_id_abc123",
values: [
{ name: "accuracy", label: "correct", score: 1.0 },
{ name: "notes", text: "Well-structured output" },
],
},
],
});
提示
这个 @arizeai/ax-client 软件包允许您创建和管理提示、其版本和标签.
创建提示
一个提示与其初始版本一起创建.
import { createPrompt } from "@arizeai/ax-client";
const prompt = await createPrompt({
space: "my-space",
name: "customer-support",
description: "A prompt for customer support interactions",
version: {
commitMessage: "Initial version",
inputVariableFormat: "F_STRING",
provider: "OPEN_AI",
model: "gpt-4",
messages: [
{ role: "SYSTEM", content: "You are a helpful assistant." },
{ role: "USER", content: "Hello, {name}!" },
],
},
});
获得及时
默认情况下返回最新版本 。 过 versionId 或者说 label 用于解决特定版本.
import { getPrompt } from "@arizeai/ax-client";
// Latest version
const prompt = await getPrompt({
prompt: "customer-support",
space: "my-space",
});
// Version tagged with the "production" label
const productionPrompt = await getPrompt({
prompt: "customer-support",
space: "my-space",
label: "production",
});
列出提示
import { listPrompts } from "@arizeai/ax-client";
const { data, pagination } = await listPrompts({ space: "my-space" });
console.log(data.map((p) => p.name));
更新提示
import { updatePrompt } from "@arizeai/ax-client";
const updated = await updatePrompt({
prompt: "customer-support",
space: "my-space",
description: "Updated description for the prompt",
});
删除提示
import { deletePrompt } from "@arizeai/ax-client";
await deletePrompt({ prompt: "customer-support", space: "my-space" });
提示版本
您可以列出一个快件的所有版本,通过它的ID检索一个特定版本,并创建新版本.
import {
listPromptVersions,
getPromptVersion,
createPromptVersion,
} from "@arizeai/ax-client";
// List versions
const { data: versions } = await listPromptVersions({
prompt: "customer-support",
space: "my-space",
});
// Get a specific version by its ID (pure ID, no name resolution)
const version = await getPromptVersion({ versionId: "your-version-id" });
// Create a new version
const newVersion = await createPromptVersion({
prompt: "customer-support",
space: "my-space",
commitMessage: "Updated system prompt",
inputVariableFormat: "F_STRING",
provider: "OPEN_AI",
model: "gpt-4",
messages: [
{ role: "SYSTEM", content: "You are a helpful assistant." },
{ role: "USER", content: "Hello, {name}!" },
],
});
提示标签
标签允许您标记一个带有所命名的别名的特定即时版本(例如. "production", (中文(简体) ), "staging") (中文(简体) ).
import {
getPromptVersionByLabel,
setPromptVersionLabels,
deletePromptVersionLabel,
} from "@arizeai/ax-client";
// Resolve the version a label currently points to
const version = await getPromptVersionByLabel({
prompt: "customer-support",
space: "my-space",
labelName: "production",
});
// Set labels on a version (replaces all existing labels)
const { labels } = await setPromptVersionLabels({
versionId: "your-version-id",
labels: ["production", "staging"],
});
// Remove a single label from a version
await deletePromptVersionLabel({
versionId: "your-version-id",
labelName: "staging",
});
评价员
这个 @arizeai/ax-client 软件包允许您创建和管理 LLM-as-a-judge(模板),代码,远程评估者及其版本.
列入评价人员名单
import { listEvaluators } from "@arizeai/ax-client";
const evaluators = await listEvaluators({ space: "my-space" });
console.log(evaluators);
创建模板评估器
import { createTemplateEvaluator } from "@arizeai/ax-client";
const evaluator = await createTemplateEvaluator({
name: "Relevance",
space: "my-space",
commitMessage: "Initial version",
templateConfig: {
name: "Relevance",
template:
"Is the response relevant?\nQuery: {{query}}\nResponse: {{response}}",
includeExplanations: true,
useFunctionCalling: true,
classificationChoices: { relevant: 1, irrelevant: 0 },
direction: "MAXIMIZE",
llmConfig: {
aiIntegrationId: "QUlJbnRlZ3JhdGlvbjphYmMxMjM=",
modelName: "gpt-4o",
invocationParameters: { temperature: 0 },
providerParameters: {},
},
},
});
创建代码评估器
import { createCodeEvaluator } from "@arizeai/ax-client";
const evaluator = await createCodeEvaluator({
name: "JSON Parseable",
space: "my-space",
commitMessage: "Initial version",
codeConfig: {
type: "MANAGED",
name: "json_parseable",
managedEvaluator: "JSON_PARSEABLE",
variables: ["output"],
},
});
创建远程评价器
一名远程评价员通过EVALUATOR集成调用客户托管的HTTP端点.
要求 enableRemoteEvalTasks 账户上的特征标记.
import { createRemoteEvaluator } from "@arizeai/ax-client";
const evaluator = await createRemoteEvaluator({
name: "My Remote Eval",
space: "my-space",
commitMessage: "Initial version",
integrationId: "<evaluator-integration-id>",
});
聘用评估人员
import { getEvaluator } from "@arizeai/ax-client";
const evaluator = await getEvaluator({
evaluator: "Relevance",
space: "my-space",
});
console.log(evaluator);
更新评价员
import { updateEvaluator } from "@arizeai/ax-client";
const evaluator = await updateEvaluator({
evaluator: "Relevance",
space: "my-space",
name: "Updated Evaluator Name",
});
删除评价员
import { deleteEvaluator } from "@arizeai/ax-client";
await deleteEvaluator({ evaluator: "Relevance", space: "my-space" });
评价员版本
您可以列出一个评估者的所有版本,通过它的ID检索一个特定版本,并创建新版本.
import {
listEvaluatorVersions,
getEvaluatorVersion,
createTemplateEvaluatorVersion,
} from "@arizeai/ax-client";
// List versions
const versions = await listEvaluatorVersions({
evaluator: "Relevance",
space: "my-space",
});
// Get a specific version by its ID
const version = await getEvaluatorVersion({ versionId: "your-version-id" });
// Create a new template version (use createCodeEvaluatorVersion for code evaluators,
// or createRemoteEvaluatorVersion for remote evaluators)
const newVersion = await createTemplateEvaluatorVersion({
evaluator: "Relevance",
space: "my-space",
commitMessage: "Updated prompt template",
templateConfig: {
name: "Relevance",
template: "Rate the relevance.\nQuery: {{query}}\nResponse: {{response}}",
includeExplanations: true,
useFunctionCalling: true,
classificationChoices: { relevant: 1, irrelevant: 0 },
direction: "MAXIMIZE",
llmConfig: {
aiIntegrationId: "QUlJbnRlZ3JhdGlvbjphYmMxMjM=",
modelName: "gpt-4o",
invocationParameters: { temperature: 0 },
providerParameters: {},
},
},
});
// Create a new remote version (switches to a different EVALUATOR integration)
import { createRemoteEvaluatorVersion } from "@arizeai/ax-client";
const remoteVersion = await createRemoteEvaluatorVersion({
evaluator: "My Remote Eval",
space: "my-space",
commitMessage: "Switch endpoint",
integrationId: "<evaluator-integration-id>",
});
删除评估器版本
import { deleteEvaluatorVersions } from "@arizeai/ax-client";
await deleteEvaluatorVersions({
evaluator: "Relevance",
space: "my-space",
versionIds: ["your_version_id_1", "your_version_id_2"],
});
任务
这个 @arizeai/ax-client 软件包允许您创建和管理预定任务或点播任务(服务器侧评价和实验)并监视其运行.
提示 : 偏爱狭义的型号
createEvaluationTask财务报告和审定财务报表createRunExperimentTask以下为助手。 低级createTask如果需要直接构造请求的有效载荷,也输出.
列出任务
import { listTasks } from "@arizeai/ax-client";
const tasks = await listTasks({ space: "my-space", name: "prod" });
console.log(tasks);
创建评价任务
每个评估员要么是一个跨形状的条目(与 columnMappings 编号 : queryFilter或一个
微量/会话形状条目(与 queryMappings) (中文(简体) ). 每个评价者提供一种形状
双方通过 SpanEvaluatorInput | TraceOrSessionEvaluatorInput 工会.
宽角任务 :
import { createEvaluationTask } from "@arizeai/ax-client";
const task = await createEvaluationTask({
name: "Weekly Quality Check",
type: "TEMPLATE_EVALUATION",
space: "my-space",
project: "my-project",
queryFilter: "span_kind = 'LLM'",
evaluators: [
{
evaluatorId: "your_evaluator_id",
columnMappings: {
input: "attributes.input.value",
output: "attributes.output.value",
},
},
],
});
追踪/ 会话- 宽度任务( 多宽度查询) :
const task = await createEvaluationTask({
name: "Trace Quality Check",
type: "TEMPLATE_EVALUATION",
space: "my-space",
project: "my-project",
queryFilters: {
filters: [
{ id: "A", filter: "span_kind = 'LLM'" },
{ id: "B", filter: "span_kind = 'RETRIEVER'" },
],
expression: "A AND B",
},
evaluators: [
{
evaluatorId: "your_evaluator_id",
queryMappings: [
{
variableName: "input",
queryIds: ["A"],
attributePath: "attributes.input.value",
},
{
variableName: "output",
queryIds: ["B"],
attributePath: "attributes.output.value",
},
],
},
],
});
创建运行实验任务
import { createRunExperimentTask } from "@arizeai/ax-client";
const task = await createRunExperimentTask({
name: "GPT-4o Baseline Task",
dataset: "my-dataset",
space: "my-space",
runConfiguration: {
experiment_type: "LLM_GENERATION",
aiIntegration: "my-openai-integration",
model_name: "gpt-4o",
input_variable_format: "F_STRING",
messages: [
{ role: "SYSTEM", content: "You are a helpful assistant." },
{ role: "USER", content: "Answer: {question}" },
],
},
});
获得任务
import { getTask } from "@arizeai/ax-client";
// By ID
const task = await getTask({ task: "your_task_id" });
// By name (requires space)
const byName = await getTask({ task: "My Task", space: "my-space" });
更新和删除任务
import { updateTask, deleteTask } from "@arizeai/ax-client";
// Basic update — rename and adjust sampling rate
await updateTask({
task: "your_task_id",
name: "Renamed Task",
samplingRate: 0.5,
});
// Switch to trace/session shape (multi-span query)
await updateTask({
task: "your_task_id",
queryFilters: {
filters: [{ id: "A", filter: "span_kind = 'LLM'" }],
expression: "A",
},
evaluators: [
{
evaluatorId: "your_evaluator_id",
queryMappings: [
{
variableName: "input",
queryIds: ["A"],
attributePath: "attributes.input.value",
},
],
},
],
});
await deleteTask({ task: "your_task_id" });
触发和监测任务
import {
triggerTaskRun,
waitForTaskRun,
listTaskRuns,
getTaskRun,
cancelTaskRun,
} from "@arizeai/ax-client";
// Trigger a run, then poll until it finishes
const run = await triggerTaskRun({ task: "My Task", space: "my-space" });
const finalRun = await waitForTaskRun({
runId: run.id,
pollInterval: 3_000, // poll every 3 seconds
timeout: 5 * 60_000, // give up after 5 minutes
});
console.log(finalRun.status); // "COMPLETED" | "FAILED" | "CANCELLED"
// List, inspect, or cancel runs
const { data: runs } = await listTaskRuns({
task: "My Task",
space: "my-space",
});
const single = await getTaskRun({ runId: run.id });
await cancelTaskRun({ runId: run.id });
西班牙语
这个 @arizeai/ax-client 软件包允许您在工程中列出、注释并删除跨度.
列表跨度
import { listSpans } from "@arizeai/ax-client";
// By project ID
const spans = await listSpans({ project: "your_project_id" });
// By project name (requires space)
const byName = await listSpans({ project: "My Project", space: "my-space" });
列投影
设定 includedColumns 仅返回选定的列。 设定 excludedColumns
以省去选定的列,例如大型嵌入向量。 不设置两者.
固定的间距字段总是返回。 设定 truncateStringLength 缩短
每个跨度内的长字符串值 attributes 对象。 字符串更长
而不是限制被剪接并结束 …这点很重要 宽度
身份证、姓名、状况、时间戳、说明、评价和事件不是
被截断了.
const spans = await listSpans({
project: "your_project_id",
excludedColumns: ["attributes.embedding.vectors"],
truncateStringLength: 200,
});
注释横跨
granularity 选择每个 recordId 表示: 跨度 (SPAN,则
默认值),一个痕量的根跨度(TRACE),或某会(SESSION,写给
(b) 届会最早追踪的根段。 最多可达1000个记录
按请求说明 SPAN编号 :TRACE; 最多100个 SESSION。 。 。 .
import { annotateSpans } from "@arizeai/ax-client";
await annotateSpans({
space: "my-space",
project: "my-project",
annotations: [
{
recordId: "c3Bhbl9pZF9hYmMxMjM=", // base64-encoded span ID
values: [
{ name: "quality", score: 0.9 },
{ name: "topic", label: "science" },
],
},
],
});
startTime编号 :endTime 绑定搜索窗口, 并且都是可选的: 当
删去, endTime 默认为现在和 startTime 默认时间为31天前
(7天用于 SESSION) (中文(简体) ). 如果记录比默认窗口长,
通过 startTime 明确或不会找到记录.
// Session-granularity example
await annotateSpans({
space: "my-space",
project: "my-project",
granularity: "SESSION",
startTime: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
endTime: new Date(),
annotations: [
{
recordId: "20144", // session ID
values: [{ name: "quality", label: "good" }],
},
],
});
删除跨度
import { deleteSpans } from "@arizeai/ax-client";
// By project name (requires space)
await deleteSpans({
project: "My Project",
space: "my-space",
spanIds: ["a1b2c3d4e5f6a7b8", "f8e7d6c5b4a39281"],
});
追踪
这个 @arizeai/ax-client 软件包允许您在工程中列出痕迹。 每个跟踪都包含其完整的(平面)跨度列表加上轻量级滚动元数据;利用每个跨度重建跟踪树客户端 parentId。 。 。 .
列出痕迹
import { listTraces } from "@arizeai/ax-client";
// By project ID
const { data: traces, pagination } = await listTraces({
project: "your_project_id",
});
// By project name (requires space), with a filter and time range
const filtered = await listTraces({
project: "My Project",
space: "my-space",
filter: "status_code = 'ERROR'",
startTime: new Date("2024-01-01T00:00:00Z"),
endTime: new Date("2024-01-02T00:00:00Z"),
limit: 50,
});
// Page through results using the opaque cursor
const next = await listTraces({
project: "your_project_id",
cursor: pagination.nextCursor,
});
这个 filter 使用与 SQL 相似的语法 listSpans但语义是
痕量相匹配: 当 任意 周期与
过滤器(匹配跨度通常是一个孩子,而不是根).
每个响应页也有总的跨度限制,所以追踪的跨度列表可以
即使在 spansTruncated 实值 false。缩小时间窗口或
调用 listSpans 带有 trace_id 过滤器可以直接取回追踪的跨度 .
注释配置
这个 @arizeai/ax-client 软件包允许您创建和管理注释配置,它定义了可用于跨度和示例的说明.
列出注释配置
import { listAnnotationConfigs } from "@arizeai/ax-client";
const annotationConfigs = await listAnnotationConfigs({ space: "my-space" });
console.log(annotationConfigs);
创建注释配置
import { createAnnotationConfig } from "@arizeai/ax-client";
const annotationConfig = await createAnnotationConfig({
name: "Accuracy",
space: "my-space",
type: "CATEGORICAL",
values: [
{ label: "accurate", score: 1 },
{ label: "inaccurate", score: 0 },
],
optimizationDirection: "MAXIMIZE",
});
获取注释配置
import { getAnnotationConfig } from "@arizeai/ax-client";
const annotationConfig = await getAnnotationConfig({
annotationConfig: "Accuracy",
space: "my-space",
});
更新注释配置
每个注释配置类型都有专门的更新功能. 每一个 必须使用存储的配置类型调用 无法改变。 您省略的任何字段都保持不变.
import { updateCategoricalAnnotationConfig } from "@arizeai/ax-client";
const annotationConfig = await updateCategoricalAnnotationConfig({
annotationConfig: "Accuracy",
space: "my-space",
name: "Accuracy v2",
values: [
{ label: "accurate", score: 1 },
{ label: "inaccurate", score: 0 },
],
optimizationDirection: "MAXIMIZE",
});
import { updateContinuousAnnotationConfig } from "@arizeai/ax-client";
const annotationConfig = await updateContinuousAnnotationConfig({
annotationConfig: "Accuracy",
space: "my-space",
name: "Accuracy v2",
minimumScore: 0,
maximumScore: 10,
optimizationDirection: "MAXIMIZE",
});
import { updateFreeformAnnotationConfig } from "@arizeai/ax-client";
const annotationConfig = await updateFreeformAnnotationConfig({
annotationConfig: "Notes",
space: "my-space",
name: "Notes v2",
});
删除注释配置
import { deleteAnnotationConfig } from "@arizeai/ax-client";
await deleteAnnotationConfig({
annotationConfig: "Accuracy",
space: "my-space",
});
注释队列
这个 @arizeai/ax-client 软件包允许您创建并管理注释队列,在其中添加记录,并对这些记录进行注释或指定.
列出注释队列
import { listAnnotationQueues } from "@arizeai/ax-client";
const annotationQueues = await listAnnotationQueues({ space: "my-space" });
console.log(annotationQueues);
创建注释队列
import { createAnnotationQueue } from "@arizeai/ax-client";
const queue = await createAnnotationQueue({
name: "Quality Review Queue",
spaceId: "your_space_id",
annotationConfigIds: ["ac_abc123"],
assignmentMethod: "ALL",
});
获取、更新和删除队列
import {
getAnnotationQueue,
updateAnnotationQueue,
deleteAnnotationQueue,
} from "@arizeai/ax-client";
const queue = await getAnnotationQueue({
annotationQueue: "my_queue",
space: "my-space",
});
await updateAnnotationQueue({
annotationQueue: "my_queue",
space: "my-space",
name: "Updated Queue Name",
});
await deleteAnnotationQueue({ annotationQueue: "my_queue", space: "my-space" });
管理队列记录
import {
addAnnotationQueueRecords,
listAnnotationQueueRecords,
deleteAnnotationQueueRecords,
annotateAnnotationQueueRecord,
assignAnnotationQueueRecord,
} from "@arizeai/ax-client";
// Add records to the queue from span and session sources
await addAnnotationQueueRecords({
annotationQueue: "my_queue",
space: "my-space",
recordSources: [
{
recordType: "SPAN",
projectId: "proj_abc123",
startTime: "2024-01-15T00:00:00Z",
endTime: "2024-01-15T23:59:59Z",
spanIds: ["span_abc123"],
},
{
recordType: "SESSION",
projectId: "proj_abc123",
startTime: "2024-01-15T00:00:00Z",
endTime: "2024-01-15T23:59:59Z",
sessionIds: ["session_abc123"],
},
],
});
// List records
const records = await listAnnotationQueueRecords({
annotationQueue: "my_queue",
space: "my-space",
});
// Assign a record to the current user
await assignAnnotationQueueRecord({
annotationQueue: "my_queue",
space: "my-space",
annotationQueueRecordId: "aqr_abc123",
});
// Submit annotations for a record
await annotateAnnotationQueueRecord({
annotationQueue: "my_queue",
space: "my-space",
annotationQueueRecordId: "aqr_abc123",
annotations: [
{ name: "accuracy", label: "correct", score: 1.0 },
{ name: "quality", text: "Well-structured response" },
],
});
// Remove records
await deleteAnnotationQueueRecords({
annotationQueue: "my_queue",
space: "my-space",
recordIds: ["aqr_abc123", "aqr_def456"],
});
AI 一体化
这个 @arizeai/ax-client 软件包允许您创建和管理AI集成(评估人员使用的LLM提供者证书、任务和操场).
列出AI集成
import { listAiIntegrations } from "@arizeai/ax-client";
const integrations = await listAiIntegrations({ space: "my-space" });
console.log(integrations);
建立AI一体化
import { createAiIntegration } from "@arizeai/ax-client";
const integration = await createAiIntegration({
name: "Production OpenAI",
provider: "OPEN_AI",
apiKey: "sk-...",
modelNames: ["gpt-4o", "gpt-4o-mini"],
enableDefaultModels: true,
});
获得AI整合
import { getAiIntegration } from "@arizeai/ax-client";
// By ID
const integration = await getAiIntegration({
integration: "your_integration_id",
});
// By name (requires space)
const byName = await getAiIntegration({
integration: "Production OpenAI",
space: "my-space",
});
更新AI集成
import { updateAiIntegration } from "@arizeai/ax-client";
const integration = await updateAiIntegration({
integration: "Production OpenAI",
space: "my-space",
name: "Updated OpenAI",
modelNames: ["gpt-4o"],
});
删除AI集成
import { deleteAiIntegration } from "@arizeai/ax-client";
await deleteAiIntegration({
integration: "Production OpenAI",
space: "my-space",
});
一体化
这个 @arizeai/ax-client 软件包允许您在多态上创建和管理集成 /v2/integrations 表面,涵盖LLM(模型提供者)和AGENT(客户托管的终点)集成。 整合名称是每个账户和类型独有的,所以 type 在解决某个名字时需要; ID总是靠自己。 这些功能在α中并发出一次性的释放前警告.
列出合并情况
type 是一个可选的过滤器。 让它在一次呼叫中列出各种类型的集成;每个项目都带有其 type 歧视者.
import { listIntegrations } from "@arizeai/ax-client";
// Only agent integrations
const agents = await listIntegrations({ type: "AGENT", space: "my-space" });
// Every type, discriminated by `integration.type`
const all = await listIntegrations({});
建立一体化
这个 type 字段选择配置形状.
import { createIntegration } from "@arizeai/ax-client";
// LLM integration
const llm = await createIntegration({
type: "LLM",
name: "Production OpenAI",
config: { provider: "OPEN_AI", apiKey: "sk-..." },
});
// Agent integration
const agent = await createIntegration({
type: "AGENT",
name: "My Support Agent",
config: {
endpoint: "https://agent.example.com/replay",
inputSchema: { type: "object", properties: { input: { type: "string" } } },
requestPresets: [{ name: "default", config: { input: "hello" } }],
},
});
config.provider 选择 LLM 配置形状。 秘密是只写着的,再也没有回来.
| 提供者 | 所需字段 | 可选字段 |
|---|---|---|
OPEN_AI, (中文(简体) ), ANTHROPIC, (中文(简体) ), GEMINI | apiKey | isFunctionCallingEnabled |
AWS_BEDROCK | auth | modelNames, (中文(简体) ), isDefaultModelsEnabled |
VERTEX_AI | projectId, (中文(简体) ), location, (中文(简体) ), projectAccessLabel | |
CUSTOM | baseUrl | apiKey, (中文(简体) ), headers, (中文(简体) ), modelNames, (中文(简体) ), isDefaultModelsEnabled, (中文(简体) ), isFunctionCallingEnabled |
NVIDIA_NIM | 无 | baseUrl, (中文(简体) ), apiKey, (中文(简体) ), headers, (中文(简体) ), modelNames, (中文(简体) ), isDefaultModelsEnabled, (中文(简体) ), isFunctionCallingEnabled |
LITELLM | baseUrl, (中文(简体) ), apiKey | headers, (中文(简体) ), modelNames, (中文(简体) ), isFunctionCallingEnabled |
FIREWORKS, (中文(简体) ), TOGETHER_AI | apiKey | modelNames, (中文(简体) ), isDefaultModelsEnabled, (中文(简体) ), isFunctionCallingEnabled |
// Self-hosted LiteLLM proxy: the endpoint and virtual key are both required.
const litellm = await createIntegration({
type: "LLM",
name: "Team LiteLLM",
config: {
provider: "LITELLM",
baseUrl: "https://litellm.internal:4000",
apiKey: "sk-...",
},
});
// Hosted providers such as Fireworks AI and Together AI need only the API key.
// Arize resolves the models the key can reach; list `modelNames` for
// fine-tunes or dedicated deployments that cannot be discovered.
const together = await createIntegration({
type: "LLM",
name: "Together AI",
config: { provider: "TOGETHER_AI", apiKey: "..." },
});
实现一体化
import { getIntegration } from "@arizeai/ax-client";
// By ID
const integration = await getIntegration({
integration: "your_integration_id",
});
// By name (requires type)
const byName = await getIntegration({
integration: "Production OpenAI",
type: "LLM",
});
更新整合
type 需要(它选择更新形状),并且是不可改变的服务器侧。 提供至少一个可更新字段; 省略字段被保存 .
import { updateIntegration } from "@arizeai/ax-client";
const integration = await updateIntegration({
integration: "Production OpenAI",
type: "LLM",
config: { provider: "OPEN_AI", apiKey: "sk-new-key" },
});
删除整合
import { deleteIntegration } from "@arizeai/ax-client";
await deleteIntegration({
integration: "My Support Agent",
type: "AGENT",
});
项目
这个 @arizeai/ax-client 软件包允许您创建和管理项目.
创建项目
import { createProject } from "@arizeai/ax-client";
const project = await createProject({
space: "my-space",
name: "my-project",
});
console.log(project);
获取项目
import { getProject } from "@arizeai/ax-client";
const project = await getProject({
project: "my-project",
space: "my-space",
});
console.log(project);
列出项目
import { listProjects } from "@arizeai/ax-client";
const { projects } = await listProjects({ space: "my-space" });
console.log(projects);
更新项目
import { updateProject } from "@arizeai/ax-client";
const project = await updateProject({
project: "my-project",
space: "my-space",
name: "my-renamed-project",
});
console.log(project);
删除项目
import { deleteProject } from "@arizeai/ax-client";
await deleteProject({ project: "my-project", space: "my-space" });
API 密钥
这个 @arizeai/ax-client 软件包允许您创建、列表、删除、撤销和刷新 API 密钥.
创建 API 密钥
import { createApiKey } from "@arizeai/ax-client";
const apiKey = await createApiKey({ keyType: "USER", name: "CI pipeline key" });
// Store apiKey.key securely — the full key value is only returned once
console.log(apiKey.key);
服务密钥由一个或多个组织和空间的专用机器人用户支持:
const apiKey = await createApiKey({
keyType: "SERVICE",
name: "service-key",
organizations: [
{
orgId: "T3JnMTIz",
spaces: [{ spaceId: "U3BhY2UxMjM", role: { name: "MEMBER" } }],
},
],
expiresAt: new Date("2027-01-01"),
});
// apiKey.botUser — the bot user created for this key, with resolved role assignments
列出 API 密钥
import { listApiKeys } from "@arizeai/ax-client";
const { data } = await listApiKeys();
console.log(data.map((k) => k.name));
// Filter by key type or status
const { data: userKeys } = await listApiKeys({ keyType: "USER" });
// List service keys for a specific space
const { data: serviceKeys } = await listApiKeys({
keyType: "SERVICE",
spaceId: "U3BhY2U6MTIzNDU=",
});
// List service keys created by a specific user (any caller with space access)
const { data: byUser } = await listApiKeys({
spaceId: "U3BhY2U6MTIzNDU=",
userId: "VXNlcjoxMjM0NQ==",
});
// Each service key entry carries the same botUser detail createApiKey returns —
// use botUser.id as the userId when creating a role binding for the key.
for (const key of serviceKeys) {
console.log(key.botUser?.id);
}
撤销 API 密钥
设置密钥状态为 revoked 并立即关闭它。 这个操作是不可逆的;撤销一个已经撤销的密钥是不可操作的,仍然成功.
import { revokeApiKey } from "@arizeai/ax-client";
await revokeApiKey({ apiKeyId: "your-api-key-id" });
刷新 API 密钥
原子取消一个已存在的密钥,并用相同的元数据(名称,描述,密钥类型)进行替换. 旧密钥被作废,新密钥在一个单项交易中被激活.
import { refreshApiKey } from "@arizeai/ax-client";
const refreshed = await refreshApiKey({ apiKeyId: "your-api-key-id" });
// Store refreshed.key securely — the full key value is only returned once
console.log(refreshed.key);
供应 expiresAt 以替换键设定过期 :
const refreshed = await refreshApiKey({
apiKeyId: "your-api-key-id",
expiresAt: new Date("2027-01-01"),
});
供应 gracePeriodSeconds 在刷新后保持旧密钥对窗口有效, 在旧密钥失效前给予您使用新密钥的时间 :
const refreshed = await refreshApiKey({
apiKeyId: "your-api-key-id",
gracePeriodSeconds: 3600, // old key stays valid for 1 hour
});
// Store refreshed.key securely — the full key value is only returned once
console.log(refreshed.key);
作用
这个 @arizeai/ax-client 软件包允许您创建和管理自定义角色.
创造作用
import { createRole } from "@arizeai/ax-client";
const role = await createRole({
name: "AI Engineer",
permissions: ["PROJECT_READ", "DATASET_READ", "DATASET_CREATE"],
description: "Can read and create datasets and experiments.",
});
列出角色
import { listRoles } from "@arizeai/ax-client";
const { data } = await listRoles();
console.log(data.map((r) => r.name));
// Filter to only predefined (system) roles
const { data: predefined } = await listRoles({ isPredefined: true });
获得角色
import { getRole } from "@arizeai/ax-client";
const role = await getRole({ roleId: "your-role-id" });
更新角色
import { updateRole } from "@arizeai/ax-client";
const role = await updateRole({
roleId: "your-role-id",
permissions: ["PROJECT_READ", "DATASET_READ"],
});
删除一个角色
import { deleteRole } from "@arizeai/ax-client";
await deleteRole({ roleId: "your-role-id" });
作用约束
这个 @arizeai/ax-client 软件包允许您在一个特定资源(如工程或空间)上绑定一个角色给用户.
创建具有约束力的角色
import { createRoleBinding } from "@arizeai/ax-client";
const binding = await createRoleBinding({
userId: "VXNlcjoxMjM0NQ==",
roleId: "Um9sZTphYmMxMjM=",
resourceType: "PROJECT",
resourceId: "UHJvamVjdDphYmMxMjM=",
});
console.log(binding);
userId 是用户将角色绑定的ID。 绑定 服务密钥,通过它的机器人
用户的ID 而不是自己的 —— 返回为 botUser.id 从 createApiKey (见
创建 API 密钥 (见上文).
列出角色约束
import { listRoleBindings } from "@arizeai/ax-client";
const bindings = await listRoleBindings({ resourceType: "SPACE" });
console.log(bindings);
获得角色约束
import { getRoleBinding } from "@arizeai/ax-client";
const binding = await getRoleBinding({ bindingId: "Um9sZUJpbmRpbmc6YWJjMTIz" });
更新角色约束
import { updateRoleBinding } from "@arizeai/ax-client";
const binding = await updateRoleBinding({
bindingId: "Um9sZUJpbmRpbmc6YWJjMTIz",
roleId: "Um9sZTphYmMxMjM=",
});
删除装订的角色
import { deleteRoleBinding } from "@arizeai/ax-client";
await deleteRoleBinding({ bindingId: "Um9sZUJpbmRpbmc6YWJjMTIz" });
资源限制
这个 @arizeai/ax-client 软件包允许您限制对资源的访问,这样只有明确绑定的用户才能访问,并解除该限制.
import { restrictResource, unrestrictResource } from "@arizeai/ax-client";
// Restrict a resource
const restriction = await restrictResource({ resourceId: "your_project_id" });
console.log(restriction);
// Lift the restriction
await unrestrictResource({ resourceId: "your_project_id" });
组织
这个 @arizeai/ax-client 软件包允许您管理组织.
列名组织
import { listOrganizations } from "@arizeai/ax-client";
const result = await listOrganizations();
console.log(result.organizations);
建立组织
import { getOrganization } from "@arizeai/ax-client";
const org = await getOrganization({ organization: "your-organization-name" });
console.log(org);
建立组织
import { createOrganization } from "@arizeai/ax-client";
const org = await createOrganization({
name: "your-organization-name",
description: "Optional description",
});
console.log(org);
更新一个组织
import { updateOrganization } from "@arizeai/ax-client";
const org = await updateOrganization({
organization: "your-organization-name",
name: "your-organization-name-updated",
});
console.log(org);
删除一个组织
警告: 此操作不可逆并删除组织 以及属于它的所有资源,包括所有空间及其内容.
import { deleteOrganization } from "@arizeai/ax-client";
await deleteOrganization({ organization: "your-organization-name" });
组织成员
向一个组织添加用户
import { addOrganizationUser } from "@arizeai/ax-client";
const membership = await addOrganizationUser({
organizationId: "org_abc123",
userId: "VXNlcjoxMjM0NQ==",
role: { type: "PREDEFINED", name: "MEMBER" },
});
console.log(membership);
从一个组织中删除一个用户
import { removeOrganizationUser } from "@arizeai/ax-client";
await removeOrganizationUser({
organizationId: "org_abc123",
userId: "VXNlcjoxMjM0NQ==",
});
用户
这个 @arizeai/ax-client 软件包允许您管理用户.
说明: 与组织不同的是,用户仅通过不透明的ID识别,而不是 以名为相. 用户显示名称在账户中并不独有, 因此所有函数 需要用户的ID.
列出用户
import { listUsers } from "@arizeai/ax-client";
const result = await listUsers();
console.log(result.data);
获取用户
import { getUser } from "@arizeai/ax-client";
const user = await getUser({ userId: "VXNlcjoxMjM0NQ==" });
console.log(user);
创建用户
这个 inviteMode 参数控制如何邀请用户 :
"EMAIL_LINK"– 向用户发送带有验证链接的电子邮件."TEMPORARY_PASSWORD"——发布一次性密码回回回回复."NONE"—— 直接提供SSO用户;没有发出邀请 用户立即通过配置的身份提供者活动.
回返a UserCreated 用于新用户的对象(HTTP 201),或 User 对象
(HTTP 200) 当存在时 invited 用户返回为- is(dimpolitent – the)
请柬不是怨恨).
import { createUser } from "@arizeai/ax-client";
const user = await createUser({
name: "Jane Smith",
email: "[email protected]",
role: { type: "PREDEFINED", name: "MEMBER" },
inviteMode: "EMAIL_LINK",
});
console.log(user);
更新用户
import { updateUser } from "@arizeai/ax-client";
const user = await updateUser({
userId: "VXNlcjoxMjM0NQ==",
name: "Jane Smith Updated",
isDeveloper: true,
});
console.log(user);
删除用户
警告: 此操作永久地将用户从账户中阻断 . 被屏蔽的用户不能再次被邀请——不活动是一个终端状态. 这个 操作级联为组织成员、空间成员、API键、, 和角色约束.
import { deleteUser } from "@arizeai/ax-client";
await deleteUser({ userId: "VXNlcjoxMjM0NQ==" });
重新发送用户邀请
import { resendInvitation } from "@arizeai/ax-client";
await resendInvitation({ userId: "VXNlcjoxMjM0NQ==" });
重置用户密码
import { resetPassword } from "@arizeai/ax-client";
await resetPassword({ userId: "VXNlcjoxMjM0NQ==" });
批量删除用户
通过ID和/或电子邮件删除多个用户。 每个条目的结果都单独退回.
import { bulkDeleteUsers } from "@arizeai/ax-client";
const results = await bulkDeleteUsers({
userIds: ["VXNlcjoxMjM0NQ=="],
emails: ["[email protected]"],
});
for (const r of results) {
console.log(r.userId, r.status, r.error ?? "");
}
空间
这个 @arizeai/ax-client 软件包允许您创建和管理空格.
列表中的空间响应、获取、创建和更新包括 organizationId, (中文(简体) ),
当服务器支持此字段时,由母组织的ID.
旧服务器版本可能会省略.
列出空格
import { listSpaces } from "@arizeai/ax-client";
const spaces = await listSpaces({
organizationId: "QWNjb3VudE9yZ2FuaXphdGlvbjox",
});
console.log(spaces);
奥米 organizationId 以列出所有组织的无障碍空间。 SDK这个
作为 REST 查询参数发送此值 org_id。 。 。 .
获得空间
import { getSpace } from "@arizeai/ax-client";
const space = await getSpace({ space: "my-space" });
console.log(space);
创建空格
import { createSpace } from "@arizeai/ax-client";
const space = await createSpace({
organizationId: "T3JnYW5pemF0aW9uOmFiYzEyMw==",
name: "your_space_name",
isPrivate: true, // omit or set false for a public space (default)
});
私人空间只能为其成员和账户/org/space admins所看到.
警告被记录到 isPrivate: true 提醒您先添加成员
其他用户无法访问该空间.
更新空格
import { updateSpace } from "@arizeai/ax-client";
const space = await updateSpace({
space: "my-space",
name: "updated_space_name",
isPrivate: false, // omit to preserve the current visibility
});
删除空格
import { deleteSpace } from "@arizeai/ax-client";
await deleteSpace({ space: "my-space" });
空间成员
将用户添加到空格
import { addSpaceUser } from "@arizeai/ax-client";
const membership = await addSpaceUser({
spaceId: "spc_abc123",
userId: "VXNlcjoxMjM0NQ==",
role: { type: "PREDEFINED", name: "MEMBER" },
});
console.log(membership);
从空格中删除用户
import { removeSpaceUser } from "@arizeai/ax-client";
await removeSpaceUser({
spaceId: "spc_abc123",
userId: "VXNlcjoxMjM0NQ==",
});
网络呼号
Webhooks为alpha:每个调用日志都会发出一次性警告,API可能会被更改. 一个Webhook是一个组织拥有的HTTPS目的地. 传递一个网签ID,或一个名字一起 organization。 。 。 .
列出网点
import { listWebhooks } from "@arizeai/ax-client";
const webhooks = await listWebhooks({ organization: "my-org" });
console.log(webhooks.data);
创建网点
import { createWebhook } from "@arizeai/ax-client";
const webhook = await createWebhook({
organization: "my-org",
name: "deploy-notifier",
url: "https://example.com/hooks/arize",
authType: "HMAC_SHA256",
});
// Only returned here. Store it now; afterwards only signingSecretHint is readable.
console.log(webhook.signingSecret);
authToken 财务报告和审定财务报表 headers 只写字,再也没有回音.
获取、更新、测试和删除一个 Webhook
import {
getWebhook,
updateWebhook,
testWebhook,
deleteWebhook,
} from "@arizeai/ax-client";
const webhook = await getWebhook({
webhook: "deploy-notifier",
organization: "my-org",
});
// Omitted fields keep their value; pass `description: null` to clear it.
await updateWebhook({
webhook: "deploy-notifier",
organization: "my-org",
timeoutMs: 10000,
});
const outcome = await testWebhook({
webhook: "deploy-notifier",
organization: "my-org",
});
console.log(outcome.statusCode, outcome.errorMessage);
await deleteWebhook({ webhook: "deploy-notifier", organization: "my-org" });
列出交货尝试
import { listWebhookDeliveryAttempts } from "@arizeai/ax-client";
const attempts = await listWebhookDeliveryAttempts({
webhook: "deploy-notifier",
organization: "my-org",
limit: 100, // up to 500
});
console.log(attempts.data);
Webhook 订阅
订阅可提供一次活动,从一次即时或评价者到一次网约车。 订阅没有名称,用身份证办理.
订阅一个事件的 Webhook
import { createWebhookSubscription } from "@arizeai/ax-client";
const subscription = await createWebhookSubscription({
webhook: "deploy-notifier",
organization: "my-org",
sourceType: "PROMPT",
sourceId: "your_prompt_id",
event: "PROMPT_VERSION_CREATED",
});
列出、获取和删除订阅
import {
listWebhookSubscriptions,
getWebhookSubscription,
deleteWebhookSubscription,
} from "@arizeai/ax-client";
// sourceType and sourceId go together; omit both to list every readable subscription.
const subscriptions = await listWebhookSubscriptions({
sourceType: "PROMPT",
sourceId: "your_prompt_id",
});
const subscription = await getWebhookSubscription({
subscriptionId: "your_subscription_id",
});
await deleteWebhookSubscription({ subscriptionId: "your_subscription_id" });
REST 终点
建议采用这一套中的方法。 如果需要更多的控制,可以直接使用客户端. 该客户端为整个Arize AX REST API提供了一种类型安全获取.
import { createClient } from "@arizeai/ax-client";
const client = createClient();
// Get all datasets
const response = await client.GET("/v2/datasets");