{"record":{"id":"65bf3d317a09bfd6","repo":"BoundaryML/baml","slug":"openai-transcription-field-response-format-must-be-a-string","errorCode":null,"errorMessage":"OpenAI transcription field `response_format` must be a string","messagePattern":"OpenAI transcription field `response_format` must be a string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/internal/llm_client/primitive/openai/types.rs","lineNumber":201,"sourceCode":"fn optional_response_format(\n    properties: &BamlMap<String, Value>,\n    model: &str,\n) -> Result<Option<String>> {\n    match properties.get(\"response_format\") {\n        Some(Value::String(value))\n            if value == \"json\"\n                || (value == \"verbose_json\"\n                    && !matches!(\n                        model,\n                        \"gpt-4o-transcribe\"\n                            | \"gpt-4o-mini-transcribe\"\n                            | \"gpt-4o-mini-transcribe-2025-12-15\"\n                            | \"gpt-4o-transcribe-diarize\"\n                    )) => Ok(Some(value.clone())),\n        Some(Value::String(value)) => bail!(\n            \"OpenAI transcription response_format `{value}` is not supported by model `{model}` in BAML; use `json`\"\n        ),\n        Some(_) => bail!(\"OpenAI transcription field `response_format` must be a string\"),\n        None => Ok(None),\n    }\n}\n\nfn optional_temperature(properties: &BamlMap<String, Value>) -> Result<Option<String>> {\n    match properties.get(\"temperature\") {\n        Some(Value::Number(value)) => Ok(Some(value.to_string())),\n        Some(Value::String(value)) => Ok(Some(value.clone())),\n        Some(_) => bail!(\"OpenAI transcription field `temperature` must be a number or string\"),\n        None => Ok(None),\n    }\n}\n\nfn filename_for_mime(mime: &str) -> String {\n    let subtype = mime\n        .split('/')\n        .next_back()\n        .unwrap_or(\"mpeg\")","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/primitive/openai/types.rs#L183-L219","documentation":"optional_response_format accepts either a missing response_format or a string; any other JSON type (number, bool, object, array) makes BAML throw this error. It is a type check on the `response_format` property of an OpenAI transcription client before the request is sent.","triggerScenarios":"Providing response_format in the BAML transcription client properties as a non-string JSON value, e.g. response_format true or response_format 1.","commonSituations":"Boolean-style config authored without quotes, generated configs that serialize the format as a number, or mixing up response_format with a different client's option.","solutions":["Quote the response_format value so it is a string (\"json\").","Remove response_format from the properties if it is not needed.","If the value is computed, ensure it serializes to a JSON string."],"exampleFix":"// before\nresponse_format true\n\n// after\nresponse_format \"json\"","handlingStrategy":"validation","validationCode":"if (props.response_format !== undefined && typeof props.response_format !== 'string') {\n  throw new Error('response_format must be a string (e.g. \"json\")');\n}","typeGuard":"const isResponseFormat = (v: unknown): v is 'json' | undefined =>\n  v === undefined || v === 'json';","tryCatchPattern":"try {\n  await baml.transcribe(...);\n} catch (e) {\n  if (String(e).includes('response_format must be a string')) {\n    console.error('Quote response_format, e.g. response_format \"json\"');\n  }\n  throw e;\n}","preventionTips":["Always write response_format as a quoted string.","Never pass booleans or numbers as format options.","Lint BAML config for unquoted literals."],"tags":["config","openai","transcription","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}