capture-api-response-test-fixture by vercel/ai
npx skills add https://github.com/vercel/ai --skill capture-api-response-test-fixture对于提供者响应解析测试,我们的目标是存储包含来自提供者的真实响应的测试固件(除非它们太大,在这种情况下建议进行一些不改变语义的裁剪)。
固件存储在 __fixtures__ 子文件夹中,例如 packages/openai/src/responses/__fixtures__。有关命名约定,请参阅 packages/openai/src/responses/__fixtures__ 中的文件名;有关如何设置测试助手,请参阅 packages/openai/src/responses/openai-responses-language-model.test.ts。
您可以使用 /examples/ai-functions 下的示例来生成测试固件。
对于 generateText,将原始响应输出记录到控制台,并将其复制到新的测试固件中。
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
import { run } from '../lib/run';
run(async () => {
const result = await generateText({
model: openai('gpt-5-nano'),
prompt: 'Invent a new holiday and describe its traditions.',
});
console.log(JSON.stringify(result.response.body, null, 2));
});
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
对于 streamText,您需要将 includeRawChunks 设置为 true 并使用特殊的 saveRawChunks 助手。通过 pnpm tsx src/stream-text/script-name.ts 从 /example/ai-functions 文件夹运行脚本。结果将存储在 /examples/ai-functions/output 文件夹中。您可以将其复制到您的固件文件夹并重命名。
import { openai } from '@ai-sdk/openai';
import { streamText } from 'ai';
import { run } from '../lib/run';
import { saveRawChunks } from '../lib/save-raw-chunks';
run(async () => {
const result = streamText({
model: openai('gpt-5-nano'),
prompt: 'Invent a new holiday and describe its traditions.',
includeRawChunks: true,
});
await saveRawChunks({ result, filename: 'openai-gpt-5-nano' });
});
每周安装量
417
代码仓库
GitHub 星标数
23.0K
首次出现
Jan 23, 2026
安全审计
安装于
claude-code350
cursor309
opencode293
codex285
gemini-cli277
github-copilot254
For provider response parsing tests, we aim at storing test fixtures with the true responses from the providers (unless they are too large in which case some cutting that does not change semantics is advised).
The fixtures are stored in a __fixtures__ subfolder, e.g. packages/openai/src/responses/__fixtures__. See the file names in packages/openai/src/responses/__fixtures__ for naming conventions and packages/openai/src/responses/openai-responses-language-model.test.ts for how to set up test helpers.
You can use our examples under /examples/ai-functions to generate test fixtures.
For generateText, log the raw response output to the console and copy it into a new test fixture.
import { openai } from '@ai-sdk/openai';
import { generateText } from 'ai';
import { run } from '../lib/run';
run(async () => {
const result = await generateText({
model: openai('gpt-5-nano'),
prompt: 'Invent a new holiday and describe its traditions.',
});
console.log(JSON.stringify(result.response.body, null, 2));
});
For streamText, you need to set includeRawChunks to true and use the special saveRawChunks helper. Run the script from the /example/ai-functions folder via pnpm tsx src/stream-text/script-name.ts. The result is then stored in the /examples/ai-functions/output folder. You can copy it to your fixtures folder and rename it.
import { openai } from '@ai-sdk/openai';
import { streamText } from 'ai';
import { run } from '../lib/run';
import { saveRawChunks } from '../lib/save-raw-chunks';
run(async () => {
const result = streamText({
model: openai('gpt-5-nano'),
prompt: 'Invent a new holiday and describe its traditions.',
includeRawChunks: true,
});
await saveRawChunks({ result, filename: 'openai-gpt-5-nano' });
});
Weekly Installs
417
Repository
GitHub Stars
23.0K
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code350
cursor309
opencode293
codex285
gemini-cli277
github-copilot254
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
54,900 周安装
Cloudflare Images 图像托管与转换 API 使用指南 | 支持 AI 人脸裁剪与内容凭证
328 周安装
Swift iOS HomeKit Matter 开发指南:控制智能家居与设备配网
329 周安装
iOS WeatherKit 使用指南:获取天气数据、预报与警报的 Swift 实现
329 周安装
Microsoft Agent Framework 开发指南:统一Semantic Kernel与AutoGen的AI智能体框架
329 周安装
Spring缓存单元测试指南:@Cacheable、@CacheEvict、@CachePut测试方法与内存缓存管理器
329 周安装
React Native 升级指南:使用 upgrade-react-native 技能轻松升级项目版本
329 周安装