ai icon indicating copy to clipboard operation
ai copied to clipboard

response_format set to verbose_json in provider/openai causes gpt-4o-transcribe being unusable

Open jie-lyu opened this issue 1 year ago • 4 comments

Description

In PR #8011, response_format is always set to verbose_json

causing the following error

response_format 'verbose_json' is not compatible with model 'gpt-4o-transcribe'. Use 'json' or 'text' instead.

AI SDK Version

"@ai-sdk/openai": "^2.0.19", "ai": "^5.0.21",

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

jie-lyu avatar Aug 22 '25 06:08 jie-lyu

We probably need to special case gpt-4o-transcribe

lgrammel avatar Aug 22 '25 06:08 lgrammel

Was able to reproduce with

import { readFile } from 'node:fs/promises';

import { openai } from '@ai-sdk/openai';
import { experimental_transcribe as transcribe } from 'ai';

import 'dotenv/config';

async function main() {
  const result = await transcribe({
    model: openai.transcription('gpt-4o-transcribe'),
    // https://github.com/vercel/ai/blob/741ca51abfd401fa92ce69298555c338e5994c89/examples/ai-core/data/galileo.mp3
    audio: await readFile('data/galileo.mp3'),
    providerOptions: {
      openai: {
        timestampGranularities: ['word']
      }
    }
  });
}

main().catch(console.error);

gr2m avatar Aug 24 '25 02:08 gr2m

Identify issue type

Identified as Bug
Confidence: High

Rationale

This is a reproducible failure in existing transcription behavior caused by the provider sending an incompatible response format.

Evidence

  • The OpenAI provider always sets response_format to verbose_json, which is incompatible with the supported gpt-4o-transcribe model and causes an API error.
  • A maintainer indicated the model likely needs special handling.
  • A commenter reproduced the failure using experimental_transcribe with openai.transcription('gpt-4o-transcribe').

lgrammel avatar Jul 22 '26 13:07 lgrammel

The fix in #8246 works for the undated aliases, but the two supported gpt-4o-mini-transcribe snapshots still select verbose_json when providerOptions.openai is present—even an empty object.

For example, adding language: 'en' changes these requests from no explicit format to the unsupported verbose_json. OpenAI lists both IDs as snapshots of the model family, whose documented response format is json.

Reproduction

In an empty directory:

npm init -y
npm install --save-exact [email protected] @ai-sdk/[email protected]

Save as repro.mjs and run node repro.mjs. The injected fetch records the actual request and returns synthetic JSON; no API key or network call is needed.

import { transcribe } from 'ai';
import { createOpenAI } from '@ai-sdk/openai';

const openai = createOpenAI({
  apiKey: 'synthetic-not-a-real-key',
  fetch: async (_url, init) => {
    if (!(init?.body instanceof FormData)) throw new Error('Expected FormData');
    console.log(init.body.get('model'), init.body.get('response_format'));
    return Response.json({ text: 'Synthetic transcript.' });
  },
});

// One silent PCM sample in a valid WAV container. No network calls are made.
const audio = 'UklGRiYAAABXQVZFZm10IBAAAAABAAEAwF0AAIC7AAACABAAZGF0YQIAAAAAAA==';
for (const modelId of [
  'gpt-4o-mini-transcribe',
  'gpt-4o-mini-transcribe-2025-03-20',
  'gpt-4o-mini-transcribe-2025-12-15',
]) {
  await transcribe({
    model: openai.transcription(modelId),
    audio,
    providerOptions: { openai: { language: 'en' } },
    maxRetries: 0,
  });
}

Actual:

gpt-4o-mini-transcribe json
gpt-4o-mini-transcribe-2025-03-20 verbose_json
gpt-4o-mini-transcribe-2025-12-15 verbose_json

Expected: all three select json.

The cause is the exact-name check in getArgs: only gpt-4o-transcribe and gpt-4o-mini-transcribe enter the JSON branch. Both dated IDs are already listed in OpenAITranscriptionModelId.

I verified this through both transcribe() and the provider's doGenerate() on Node 22.20.0 and 24.13.0. Each run has 8 failing assertions for the snapshots and 16 passing controls covering the undated models, absent options, explicit JSON, Whisper, and diarization. The same selection code is present on current main (12845693). I did not make live provider calls.

Workaround: add responseFormat: 'json' to providerOptions.openai.

I used AI assistance to investigate and prepare the reproduction and tests.

brennanbutler01 avatar Sep 18 '26 04:09 brennanbutler01