BoundaryML/baml · error

OpenAI transcription response_format

Error message

OpenAI transcription response_format `{value}` is not supported by model `{model}` in BAML; use `json`

What it means

For the gpt-4o-transcribe family of models, BAML only supports response_format "json"; any other string value (e.g. "text" or "verbose_json") is rejected at client-construction time because BAML cannot parse those responses. This is a BAML-side restriction, not an OpenAI API error.

Solutions

  1. Set response_format "json" in the client properties.
  2. Remove the response_format property entirely so BAML uses its default handling.
  3. If you need plain text, keep response_format json and extract the text field from the parsed result.

Example fix

// before
model "gpt-4o-transcribe"
response_format "text"

// after
model "gpt-4o-transcribe"
response_format "json"
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = new Set(['gpt-4o-transcribe', 'gpt-4o-mini-transcribe', 'gpt-4o-mini-transcribe-2025-12-15', 'gpt-4o-transcribe-diarize']);
if (SUPPORTED.has(props.model) && props.response_format !== undefined && props.response_format !== 'json') {
  throw new Error(`response_format must be "json" for ${props.model}`);
}

Try / catch

try {
  await baml.transcribe(...);
} catch (e) {
  if (String(e).includes('response_format') && String(e).includes('not supported')) {
    console.error('Switch response_format to "json" for gpt-4o transcription models');
  }
  throw e;
}

Prevention

When it happens

Trigger: Setting response_format to a string other than "json" while the model is one of gpt-4o-transcribe, gpt-4o-mini-transcribe, gpt-4o-mini-transcribe-2025-12-15, or gpt-4o-transcribe-diarize.

Common situations: Copying a whisper-style config that used response_format "text" or "verbose_json" and switching the model to gpt-4o-transcribe, or explicitly requesting plain-text output from a diarize model.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/0dd46512011cbe84. Report an issue: GitHub.

Appendix: source

Thrown at engine/baml-runtime/src/internal/llm_client/primitive/openai/types.rs:198

    }
}

fn optional_response_format(
    properties: &BamlMap<String, Value>,
    model: &str,
) -> Result<Option<String>> {
    match properties.get("response_format") {
        Some(Value::String(value))
            if value == "json"
                || (value == "verbose_json"
                    && !matches!(
                        model,
                        "gpt-4o-transcribe"
                            | "gpt-4o-mini-transcribe"
                            | "gpt-4o-mini-transcribe-2025-12-15"
                            | "gpt-4o-transcribe-diarize"
                    )) => Ok(Some(value.clone())),
        Some(Value::String(value)) => bail!(
            "OpenAI transcription response_format `{value}` is not supported by model `{model}` in BAML; use `json`"
        ),
        Some(_) => bail!("OpenAI transcription field `response_format` must be a string"),
        None => Ok(None),
    }
}

fn optional_temperature(properties: &BamlMap<String, Value>) -> Result<Option<String>> {
    match properties.get("temperature") {
        Some(Value::Number(value)) => Ok(Some(value.to_string())),
        Some(Value::String(value)) => Ok(Some(value.clone())),
        Some(_) => bail!("OpenAI transcription field `temperature` must be a number or string"),
        None => Ok(None),
    }
}

fn filename_for_mime(mime: &str) -> String {
    let subtype = mime

View on GitHub (pinned to bd85ce9dee)