vercel avatar

Capture Api Response Test Fixture

vercel/aiOfficial

Guide for recording real provider API responses as test fixtures for parser tests.

CCM score
71 of 100
skills.sh installs
1.7K
GitHub stars
28.2K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers capturing raw responses for generateText (doGenerate) and streamText (doStream) provider parsing tests
  • Stores fixtures in each provider's __fixtures__ folder, following existing file naming conventions in that directory
  • Provides capture scripts using run and saveRawChunks helpers, with includeRawChunks enabled for streams
  • Designed for maintainers of AI SDK provider packages writing response-parsing tests against live model outputs

Install

$ npx -y skills add vercel/ai --skill capture-api-response-test-fixture -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

API Response Test Fixtures

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.

generateText (doGenerate testing)

For generateText, put the script under src/generate-text/<provider>/, 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));
});

Details

Repository
github.com/vercel/ai
Categories
Testing & QA, AI Agents & LLM Apps
First seen
Apr 16, 2026

More from vercel/ai

All 8

Similar to Capture Api Response Test Fixture

More Testing & QA