{"record":{"id":"4b055a115eb5d754","repo":"BoundaryML/baml","slug":"openai-transcription-field-field-must-be-a-string","errorCode":null,"errorMessage":"OpenAI transcription field `{field}` must be a string","messagePattern":"OpenAI transcription field `(.+?)` 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":168,"sourceCode":"}\n\nfn reject_reserved_request_fields(properties: &BamlMap<String, Value>) -> Result<()> {\n    for key in [\"messages\", \"stream\"] {\n        if properties.contains_key(key) {\n            bail!(\"OpenAI transcriptions do not support reserved request field `{key}`\")\n        }\n    }\n    Ok(())\n}\n\nfn required_string_field(properties: &BamlMap<String, Value>, field: &str) -> Result<String> {\n    let value = properties\n        .get(field)\n        .with_context(|| format!(\"OpenAI transcriptions require string field `{field}`\"))?;\n\n    match value {\n        Value::String(value) => Ok(value.clone()),\n        _ => bail!(\"OpenAI transcription field `{field}` must be a string\"),\n    }\n}\n\nfn optional_string_field(\n    properties: &BamlMap<String, Value>,\n    field: &str,\n) -> Result<Option<String>> {\n    match properties.get(field) {\n        Some(Value::String(value)) => Ok(Some(value.clone())),\n        Some(_) => bail!(\"OpenAI transcription field `{field}` must be a string\"),\n        None => Ok(None),\n    }\n}\n\nfn optional_response_format(\n    properties: &BamlMap<String, Value>,\n    model: &str,\n) -> Result<Option<String>> {","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/primitive/openai/types.rs#L150-L186","documentation":"BAML builds an OpenAI transcription request from your BAML client config's properties map. A required transcription field (e.g. `model` or `input`) is present but is not a JSON string (it is a number, bool, object, etc.), so BAML rejects it before calling OpenAI. This validation exists because the OpenAI transcriptions API only accepts string values for these fields.","triggerScenarios":"Calling a BAML client of provider openai/transcription where a required field in the client's properties (e.g. `model`) is set to a non-string literal such as a number, boolean, array, or nested object.","commonSituations":"Typos in BAML config where the value is unquoted (e.g. model 4o-mini-transcribe instead of \"gpt-4o-mini-transcribe\"), templating expressions that resolve to non-strings, or copy-pasted config from a non-transcription client.","solutions":["Quote the field value so it is a JSON string in the BAML client config (e.g. model \"gpt-4o-transcribe\").","Check which required field is named in the error and ensure the properties map in your BAML client block defines it as a string.","If the value comes from an expression or environment variable, coerce it to a string before interpolation."],"exampleFix":"// before (BAML client properties)\nmodel 4o-mini-transcribe\n\n// after\nmodel \"gpt-4o-mini-transcribe\"","handlingStrategy":"validation","validationCode":"const required = ['model', 'input'];\nfor (const f of required) {\n  const v = props[f];\n  if (v !== undefined && typeof v !== 'string') {\n    throw new Error(`Field \"${f}\" must be a string, got ${typeof v}`);\n  }\n}","typeGuard":"const isString = (v: unknown): v is string => typeof v === 'string';","tryCatchPattern":"try {\n  await baml.transcribe(...);\n} catch (e) {\n  if (String(e).includes('must be a string')) {\n    console.error('Check transcription client config: quote all field values');\n  }\n  throw e;\n}","preventionTips":["Always quote string values in BAML client properties blocks.","Validate config with a schema checker before deploying.","Coerce interpolated env vars to strings."],"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"}