Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const plugins = [
paths: ['api/**'],
},
],
exclude: ['ja/**'],
exclude: ['ja/**', 'zh/**'],
}),
];

Expand All @@ -97,131 +97,150 @@ const sidebar = [
link: '/',
translations: {
ja: '概要',
zh: '概述',
},
},
{
label: 'Quickstart',
link: '/guides/quickstart',
translations: {
ja: 'クイックスタート',
zh: '快速开始',
},
},
{
label: 'Guides',
translations: {
ja: 'ガイド',
zh: '指南',
},
items: [
{
label: 'Agents',
link: '/guides/agents',
translations: {
ja: 'エージェント',
zh: '智能体',
},
},
{
label: 'Running Agents',
link: '/guides/running-agents',
translations: {
ja: 'エージェントの実行',
zh: '运行智能体',
},
},
{
label: 'Results',
link: '/guides/results',
translations: {
ja: 'エージェントの実行結果',
zh: '执行结果',
},
},
{
label: 'Tools',
link: '/guides/tools',
translations: {
ja: 'ツール',
zh: '工具',
},
},
{
label: 'Orchestrating multiple agents',
link: '/guides/multi-agent',
translations: {
ja: 'マルチエージェント',
zh: '多智能体编排',
},
},
{
label: 'Handoffs',
link: '/guides/handoffs',
translations: {
ja: 'ハンドオフ',
zh: '交接',
},
},
{
label: 'Context management',
link: '/guides/context',
translations: {
ja: 'コンテキスト管理',
zh: '上下文管理',
},
},
{
label: 'Models',
link: '/guides/models',
translations: {
ja: 'モデル',
zh: '模型',
},
},
{
label: 'Guardrails',
link: '/guides/guardrails',
translations: {
ja: 'ガードレール',
zh: '护栏',
},
},
{
label: 'Streaming',
link: '/guides/streaming',
translations: {
ja: 'ストリーミング',
zh: '流式传输',
},
},
{
label: 'Human-in-the-loop',
link: '/guides/human-in-the-loop',
translations: {
ja: '人間の介入(HITL)',
zh: '人机协作',
},
},
{
label: 'Model Context Protocol (MCP)',
link: '/guides/mcp',
translations: {
ja: 'MCP 連携',
zh: 'MCP 集成',
},
},
{
label: 'Tracing',
link: '/guides/tracing',
translations: {
ja: 'トレーシング',
zh: '追踪',
},
},
{
label: 'Configuring the SDK',
link: '/guides/config',
translations: {
ja: 'SDK の設定',
zh: 'SDK 配置',
},
},
{
label: 'Troubleshooting',
link: '/guides/troubleshooting',
translations: {
ja: 'トラブルシューティング',
zh: '故障排除',
},
},
{
label: 'Release process',
link: '/guides/release',
translations: {
ja: 'リリースプロセス',
zh: '发布流程',
},
},
],
Expand All @@ -230,34 +249,39 @@ const sidebar = [
label: 'Voice Agents',
translations: {
ja: '音声エージェント',
zh: '语音智能体',
},
items: [
{
label: 'Overview',
link: '/guides/voice-agents',
translations: {
ja: '音声エージェントの概要',
zh: '语音智能体概述',
},
},
{
label: 'Quickstart',
link: '/guides/voice-agents/quickstart',
translations: {
ja: 'クイックスタート',
zh: '快速开始',
},
},
{
label: 'Building Voice Agents',
link: '/guides/voice-agents/build',
translations: {
ja: '音声エージェントの構築',
zh: '构建语音智能体',
},
},
{
label: 'Transport Mechanisms',
link: '/guides/voice-agents/transport',
translations: {
ja: 'リアルタイムトランスポート',
zh: '传输机制',
},
},
],
Expand All @@ -266,20 +290,23 @@ const sidebar = [
label: 'Extensions',
translations: {
ja: '拡張機能',
zh: '扩展',
},
items: [
{
label: 'Use any model with the AI SDK',
link: '/extensions/ai-sdk',
translations: {
ja: 'AI SDK で任意モデルを指定',
zh: '使用 AI SDK 指定任意模型',
},
},
{
label: 'Connect Realtime Agents to Twilio',
link: '/extensions/twilio',
translations: {
ja: 'Realtime Agent を Twilio に接続',
zh: '将实时智能体连接到 Twilio',
},
},
],
Expand All @@ -288,6 +315,7 @@ const sidebar = [
label: 'API Reference',
translations: {
ja: 'APIリファレンス',
zh: 'API 参考',
},
collapsed: false,
items: [
Expand Down Expand Up @@ -350,6 +378,10 @@ export default defineConfig({
label: '日本語',
lang: 'ja',
},
zh: {
label: '中文',
lang: 'zh',
},
},
social: [
{
Expand Down
85 changes: 85 additions & 0 deletions docs/src/content/docs/zh/extensions/ai-sdk.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
title: 使用任何模型与 Vercel 的 AI SDK
description: Connect your Agents SDK agents to any model through the Vercel's AI SDK
---

import { Aside, Steps, Code } from '@astrojs/starlight/components';
import aiSdkSetupExample from '../../../../../../examples/docs/extensions/ai-sdk-setup.ts?raw';

<Aside type="caution">
该适配器仍处于测试阶段。您在使用某些模型提供方时可能会遇到问题,尤其是较小的提供方。请通过
[GitHub issues](https://github.com/openai/openai-agents-js/issues)
报告任何问题,我们会尽快修复。
</Aside>

开箱即用,Agents SDK 可通过 Responses API 或 Chat Completions API 与 OpenAI 模型配合使用。不过,如果您希望使用其他模型,[Vercel 的 AI SDK](https://sdk.vercel.ai/) 提供了多种受支持的模型,可通过此适配器接入 Agents SDK。

## 设置

<Steps>

1. 通过安装扩展包来安装 AI SDK 适配器:

```bash
npm install @openai/agents-extensions
```

2. 从 [Vercel 的 AI SDK](https://ai-sdk.dev/docs/foundations/providers-and-models) 选择所需的模型包并进行安装:

```bash
npm install @ai-sdk/openai
```

3. 导入适配器和模型以连接到您的智能体:

```typescript
import { openai } from '@ai-sdk/openai';
import { aisdk } from '@openai/agents-extensions';
```

4. 初始化模型实例,供该智能体使用:

```typescript
const model = aisdk(openai('o4-mini'));
```

</Steps>

<Aside type="caution">
我们目前支持 ai-sdk 的模型提供方的 v2 模块,与 Vercel AI SDK v5
兼容。如果您有特定原因需要继续使用 v1 模型提供方,可以从
[examples/ai-sdk-v1](https://github.com/openai/openai-agents-js/tree/main/examples/ai-sdk-v1)
复制该模块并将其包含到您的项目中。
</Aside>

## 示例

<Code lang="typescript" code={aiSdkSetupExample} title="AI SDK 设置" />

## 提供方元数据传递

如果您需要随消息发送提供方特定的选项,请通过 `providerMetadata` 传递。这些值会直接转发给底层的 AI SDK 模型。例如,在 Agents SDK 中如下的 `providerData`

```ts
providerData: {
anthropic: {
cacheControl: {
type: 'ephemeral';
}
}
}
```

将会变为

```ts
providerMetadata: {
anthropic: {
cacheControl: {
type: 'ephemeral';
}
}
}
```

在使用 AI SDK 集成时。
Loading