capture-api-response-test-fixture
SkillCloud & infraThis skill guides an AI agent through capturing real provider API responses and saving them as test fixtures. It covers both generateText and streamText flows, storing the captured output in a __fixtures__ folder so provider response parsing tests can run against true responses instead of invented ones.
Then ask your AI: use the capture-api-response-test-fixture skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Have a project with provider response parsing tests and an examples folder for AI functions.
What your AI can do with it
- Capture raw generateText responses and log them for use as fixtures
- Capture streamText responses using includeRawChunks and saveRawChunks
- Write captured stream output files to an output folder for copying
- Store fixtures in a __fixtures__ subfolder next to provider tests
- Point to example scripts under /examples/ai-functions for generating fixtures
Getting started
- Have a project with provider response parsing tests and an examples folder for AI functions.
- For generateText, add a script under src/generate-text/<provider>/ that logs result.response.body to the console.
- For streamText, add a script that sets includeRawChunks to true and calls saveRawChunks with a filename.
- Run the script, then copy the logged or saved output into a new file in the provider's __fixtures__ folder and rename it to match the naming conventions.
What this skill tells your AI
The instructions your AI receives, as published by vercel/ai in skills/capture-api-response-test-fixture/SKILL.md and read by Ahel’s review.
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));
});
streamText (doStream testing)
For streamText, you need to set includeRawChunks to true and use the special saveRawChunks helper. Put the script under the provider directory and run it from the /examples/ai-functions folder via pnpm tsx src/stream-text/<provider>/<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' });
});
Signals
- GitHub stars
- 27k
- Forks
- 5k
- Last commit
- Oct 2026
Others that do the same job
Questions
- Where are the fixtures stored?
- In a __fixtures__ subfolder, for example packages/openai/src/responses/__fixtures__. Check the file names there for naming conventions and the provider test file for how test helpers are set up.
- How do I capture a generateText response?
- Put a script under src/generate-text/<provider>/, call generateText, and log JSON.stringify(result.response.body, null, 2) to the console. Copy that output into a new test fixture.
Advanced
- Item type
- skill
- Key
capture-api-response-test-fixture-vercel- Source
- github.com/vercel/ai
Related picks
Skill · mattpocock
The pick for TypeScripttypescript-providers
Skill · composiohq
The pick for TypeScriptvercel-react-best-practices
Skill · vercel-labs
More in Cloud & infraweb-design-guidelines
Skill · vercel-labs
More in Cloud & infrawrangler
Skill · cloudflare
More in Cloud & inframicrosoft-foundry
Skill · microsoft
More in Cloud & infra