> ## Documentation Index
> Fetch the complete documentation index at: https://docs.y.uno/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# Agent Toolkit

> 使用 Yuno 的多框架工具包构建 AI 驱动的支付体验。

Yuno 的 Agent Toolkit 让 AI 智能体可以通过函数调用与 Yuno 的支付编排平台交互。它基于 TypeScript 构建，连接到 Yuno 的远程 MCP 服务器，并提供可在五个 AI 框架中使用的支付工具：只需一次集成，即可接入全球 300 多家支付服务提供商。

## 包含内容

Yuno Agent Toolkit 以 npm 包（`@yuno-payments/agent-toolkit`）的形式提供，包括：

* **框架集成**：Vercel AI SDK、Google Genkit、LangChain、OpenAI Chat 和 OpenAI Agents SDK。只需导入您需要的适配器。
* **多服务提供商编排**：通过一次集成接入全球 300 多家支付服务提供商。您的 AI 智能体可直接使用 Yuno 的智能路由、多服务提供商故障转移以及各市场特有的支付方式。
* **类型安全**：完整的 TypeScript 支持，提供全面的类型定义和经过 Zod 验证的 schema。
* **模块化**：只导入您需要的工具类别（客户、支付、订阅等），并可精细地筛选操作。

## 快速入门

### 安装

```bash theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
npm install @yuno-payments/agent-toolkit
```

### 要求

* **Node.js**：18 或更高版本。
* **Yuno 账户**：拥有 API 凭证的 [Yuno 账户](https://y.uno/)。

### 凭证

从 [Yuno Dashboard](https://dashboard.y.uno/) 获取您的 API 凭证，并将其设置为环境变量：

```bash theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
YUNO_ACCOUNT_CODE=your_account_code
YUNO_PUBLIC_API_KEY=your_public_api_key
YUNO_PRIVATE_SECRET_KEY=your_private_secret_key
```

## 支持的 AI 框架

该工具包为主流 AI 框架提供专用适配器。请选择适合您技术栈的框架：

> [tab] Vercel AI SDK
>
> 使用 `@yuno-payments/agent-toolkit/ai-sdk` 导入适配器。
>
> ```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> import { generateText } from "ai";
> import { openai } from "@ai-sdk/openai";
> import { createYunoAgentToolkit } from "@yuno-payments/agent-toolkit/ai-sdk";
>
> const toolkit = await createYunoAgentToolkit({
>   accountCode: process.env.YUNO_ACCOUNT_CODE!,
>   publicApiKey: process.env.YUNO_PUBLIC_API_KEY!,
>   privateSecretKey: process.env.YUNO_PRIVATE_SECRET_KEY!,
> });
>
> const { text } = await generateText({
>   model: openai("gpt-4o"),
>   tools: toolkit.getTools(),
>   prompt: "Create a customer named Maria Garcia with email maria@example.com",
> });
>
> await toolkit.close();
> ```

> [tab] Google Genkit
>
> 使用 `@yuno-payments/agent-toolkit/genkit` 导入适配器。
>
> ```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> import { genkit, z } from "genkit";
> import { googleAI, gemini15Pro } from "@genkit-ai/googleai";
> import { createYunoGenkitToolkit } from "@yuno-payments/agent-toolkit/genkit";
>
> const ai = genkit({ plugins: [googleAI()] });
>
> const toolkit = await createYunoGenkitToolkit({
>   accountCode: process.env.YUNO_ACCOUNT_CODE!,
>   publicApiKey: process.env.YUNO_PUBLIC_API_KEY!,
>   privateSecretKey: process.env.YUNO_PRIVATE_SECRET_KEY!,
>   ai,
> });
>
> const agent = ai.definePrompt({
>   name: "paymentAgent",
>   model: gemini15Pro,
>   tools: toolkit.getToolsArray(),
>   input: { schema: z.object({ query: z.string() }) },
> });
>
> const result = await agent({ query: "Create a customer named Jane Smith" });
> await toolkit.close();
> ```

> [tab] LangChain
>
> 使用 `@yuno-payments/agent-toolkit/langchain` 导入适配器。
>
> ```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> import { YunoLangChainToolkit } from "@yuno-payments/agent-toolkit/langchain";
>
> const toolkit = await YunoLangChainToolkit.create({
>   accountCode: process.env.YUNO_ACCOUNT_CODE!,
>   publicApiKey: process.env.YUNO_PUBLIC_API_KEY!,
>   privateSecretKey: process.env.YUNO_PRIVATE_SECRET_KEY!,
> });
>
> const tools = toolkit.getTools();
> // Use with LangChain agents...
>
> await toolkit.close();
> ```

> [tab] OpenAI Chat
>
> 使用 `@yuno-payments/agent-toolkit/openai` 导入适配器。
>
> ```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> import OpenAI from "openai";
> import { createYunoOpenAIToolkit } from "@yuno-payments/agent-toolkit/openai";
>
> const toolkit = await createYunoOpenAIToolkit({
>   accountCode: process.env.YUNO_ACCOUNT_CODE!,
>   publicApiKey: process.env.YUNO_PUBLIC_API_KEY!,
>   privateSecretKey: process.env.YUNO_PRIVATE_SECRET_KEY!,
> });
>
> const client = new OpenAI();
> const response = await client.chat.completions.create({
>   model: "gpt-4o",
>   tools: toolkit.getTools(),
>   messages: [{ role: "user", content: "Create a payment link for $50 USD" }],
> });
>
> for (const toolCall of response.choices[0].message.tool_calls ?? []) {
>   const result = await toolkit.handleToolCall(
>     toolCall.function.name,
>     toolCall.function.arguments,
>   );
> }
>
> await toolkit.close();
> ```

> [tab] OpenAI Agents SDK
>
> 使用 `@yuno-payments/agent-toolkit/openai-agents` 导入适配器。
>
> ```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> import { Agent, run } from "@openai/agents";
> import { createYunoOpenAIAgentsToolkit } from "@yuno-payments/agent-toolkit/openai-agents";
>
> const toolkit = await createYunoOpenAIAgentsToolkit({
>   accountCode: process.env.YUNO_ACCOUNT_CODE!,
>   publicApiKey: process.env.YUNO_PUBLIC_API_KEY!,
>   privateSecretKey: process.env.YUNO_PRIVATE_SECRET_KEY!,
> });
>
> const agent = new Agent({
>   name: "Yuno Payment Agent",
>   instructions: "You are a payment assistant powered by Yuno.",
>   tools: toolkit.getTools(),
> });
>
> const result = await run(agent, "Create a customer named Maria Garcia");
> await toolkit.close();
> ```

## 配置

### 操作筛选

您可以精细地控制智能体可以使用哪些工具：

```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const toolkit = await createYunoAgentToolkit({
  // ...credentials
  actions: {
    customers: { create: true, retrieve: true },
    payments: { retrieve: true, refund: true },
  },
});
```

要启用所有可用工具，可以使用 `ALL_TOOLS_ENABLED` 常量：

```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import { ALL_TOOLS_ENABLED } from "@yuno-payments/agent-toolkit/ai-sdk";

const toolkit = await createYunoAgentToolkit({
  // ...credentials
  actions: ALL_TOOLS_ENABLED,
});
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.