vercel avatar

Capture Api Response Test Fixture

vercel/aiOfficial

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-code

Installs 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

More from vercel/ai

All 8
1lovartai avatarlovart-apilovartai/lovart-skilllovart api1.7Kskills.sh installs
2affaan-m avatarredis-patternsaffaan-m/everything-claude-coderedis patterns1.7Kskills.sh installs
3intellectronica avatartodoist-apiintellectronica/agent-skillsThis skill provides instructions for interacting with Todoist using the td CLI tool. It covers CRUD operations for tasks/projects/sections/labels/comments, and 1.7Kskills.sh installs
4nvidia avatarcuopt-numerical-optimization-api-pythonnvidia/skillsSolve LP, MILP, QP (beta) with cuOpt Python API — linear/quadratic objectives, integer variables, scheduling, portfolio, least squares.1.7Kskills.sh installs
5getsentry avatartyping-exclusion-workergetsentry/skillsPython typing exclusion worker: remove assigned mypy exclusion modules in small scoped batches, fix typing issues, run validation, and produce a structured comp1.7Kskills.sh installs
6affaan-m avataruspto-databaseaffaan-m/everything-claude-codeuspto database1.6Kskills.sh installs