{"record":{"id":"7bc861473bec5dfd","repo":"BoundaryML/baml","slug":"bamlerror-bamlclienterror-something-went-wrong-with-the-llm-7bc861","errorCode":null,"errorMessage":"BamlError: BamlClientError: Something went wrong with the LLM client: {err}","messagePattern":"BamlError: BamlClientError: Something went wrong with the LLM client: (.+?)","errorType":"exception","errorClass":"BamlClientError","httpStatus":null,"severity":"error","filePath":"engine/language_client_typescript/src/errors.rs","lineNumber":122,"sourceCode":"                | baml_runtime::internal::llm_client::ErrorCode::NotSupported\n                | baml_runtime::internal::llm_client::ErrorCode::RateLimited\n                | baml_runtime::internal::llm_client::ErrorCode::ServerError\n                | baml_runtime::internal::llm_client::ErrorCode::ServiceUnavailable\n                | baml_runtime::internal::llm_client::ErrorCode::UnsupportedResponse(_) => {\n                    throw_baml_client_http_error(\n                        failed.client.as_str(),\n                        failed.message.as_str(),\n                        &failed.code,\n                        None,\n                        failed.raw_response.as_deref(),\n                    )\n                }\n            },\n            LLMResponse::UserFailure(msg) => napi::Error::new(\n                napi::Status::GenericFailure,\n                format!(\"BamlError: BamlInvalidArgumentError: {msg}\"),\n            ),\n            LLMResponse::InternalFailure(_) => napi::Error::new(\n                napi::Status::GenericFailure,\n                format!(\n                    \"BamlError: BamlClientError: Something went wrong with the LLM client: {err}\"\n                ),\n            ),\n            LLMResponse::Cancelled(msg) => napi::Error::new(\n                napi::Status::GenericFailure,\n                format!(\"BamlAbortError: Operation was aborted: {msg}\"),\n            ),\n        }\n    } else {\n        napi::Error::new(napi::Status::GenericFailure, format!(\"BamlError: {err:?}\"))\n    }\n}\n\nfn throw_baml_validation_error(\n    prompt: &str,\n    raw_output: &str,","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_typescript/src/errors.rs#L104-L140","documentation":"BAML throws a generic BamlClientError when an LLM response comes back as LLMResponse::InternalFailure. It means the underlying LLM client failed for a reason not classified as HTTP, timeout, or cancellation, so only the anyhow error string is surfaced. It is the catch-all client-failure variant in the NAPI error mapping for the TypeScript client.","triggerScenarios":"Calling a generated BAML function (or the runtime client) when the LLM provider returns an internal failure — e.g. provider client construction fails, streaming/serialization errors, or an unclassified client error in from_anyhow_error.","commonSituations":"Misconfigured model provider in baml_config (bad client definition, unsupported model), SDK/network failures inside the provider crate, or an unexpected provider response that isn't mapped to a specific error type.","solutions":["Inspect the {err} text appended to the message — it names the underlying provider failure","Check that the LLM client in your BAML config names a supported provider with valid model/credentials","Retry the request; transient provider or network failures surface here","Upgrade BAML to the latest version — many internal failures get reclassified into specific errors (HTTP/timeout) over time"],"exampleFix":"// before\nclient GPT4 {\n  provider openai\n  options {\n    model gpt-4\n    api_key env.OPENAI_API_KEY_MISSING\n  }\n}\n// after\nclient GPT4 {\n  provider openai\n  options {\n    model gpt-4\n    api_key env.OPENAI_API_KEY\n  }\n}","handlingStrategy":"try-catch","validationCode":"if (!process.env.OPENAI_API_KEY) throw new Error('OPENAI_API_KEY not set before calling BAML');","typeGuard":"const isBamlClientError = (e: unknown): boolean => String(e).includes('BamlClientError');","tryCatchPattern":"try {\n  const result = await b.MyFunction(args);\n} catch (e) {\n  if (String(e).includes('BamlClientError')) {\n    console.error('LLM client failed:', String(e));\n    return fallbackResponse;\n  }\n  throw e;\n}","preventionTips":["Validate provider credentials and client config before calls","Add a retry_policy to LLM clients in baml_src","Pin and update the BAML runtime version regularly","Log the full error string — the {err} payload names the root cause"],"tags":["llm","napi","typescript","client-error"],"backgroundTag":"api-error-response","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}