
Capture Api Response Test Fixture
This captures real API responses from providers and saves them as test fixtures so you can validate your parsing logic without making live calls. You run example scripts with generateText or streamText, log the raw responses, and store them in a __fixtures__ folder following the naming conventions from the OpenAI package. For streaming responses, there's a saveRawChunks helper that dumps everything to the output folder automatically. It's particularly useful when you're building provider integrations and need reproducible test data. The fixtures should be actual provider responses unless they're huge, in which case you trim them down without changing the structure.
- skills.sh installs
- 1.7K
- GitHub stars
- 27.8K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add vercel/ai --skill capture-api-response-test-fixture --agent claude-codeInstalls into .claude/skills of the current project.
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));
});
Sponsors
Details
- Repository
- github.com/vercel/ai
- Categories
- Backend & APIs, Testing & QA, Cloud & Infrastructure
- First seen
- Apr 16, 2026