{"record":{"id":"b269c2267796330f","repo":"BoundaryML/baml","slug":"completion-prompts-are-not-supported-by-this-provider","errorCode":null,"errorMessage":"Completion prompts are not supported by this provider","messagePattern":"Completion prompts are not supported by this provider","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/internal/llm_client/traits/completion.rs","lineNumber":26,"sourceCode":"    fn completion_options(&self, ctx: &RuntimeContext) -> Result<CompletionOptions>;\n\n    #[allow(async_fn_in_trait)]\n    async fn completion(&self, ctx: &impl HttpContext, prompt: &str) -> LLMResponse;\n}\n\npub trait WithStreamCompletion: Sync + Send {\n    #[allow(async_fn_in_trait)]\n    async fn stream_completion(&self, ctx: &impl HttpContext, prompt: &str) -> StreamResponse;\n}\n\npub trait WithNoCompletion {}\n\nimpl<T> WithCompletion for T\nwhere\n    T: WithNoCompletion + Send + Sync,\n{\n    fn completion_options(&self, _ctx: &RuntimeContext) -> Result<CompletionOptions> {\n        anyhow::bail!(\"Completion prompts are not supported by this provider\")\n    }\n\n    #[allow(async_fn_in_trait)]\n    async fn completion(&self, _: &impl HttpContext, _: &str) -> LLMResponse {\n        LLMResponse::InternalFailure(\"Completion prompts are not supported by this provider\".into())\n    }\n}\n\nimpl<T> WithStreamCompletion for T\nwhere\n    T: WithNoCompletion + Send + Sync,\n{\n    #[allow(async_fn_in_trait)]\n    async fn stream_completion(&self, _: &impl HttpContext, _: &str) -> StreamResponse {\n        Err(LLMResponse::InternalFailure(\n            \"Completion prompts are not supported by this provider\".to_string(),\n        ))\n    }","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/internal/llm_client/traits/completion.rs#L8-L44","documentation":"The blanket `WithCompletion` implementation for providers without completion support rejects any attempt to get completion options or perform a completion request. It is thrown when `render_prompt` calls `completion_options` on a provider that only supports chat prompts.","triggerScenarios":"Using `prompt \"...\"` (string completion prompt) with a client whose provider only implements chat — e.g. chat-only providers like anthropic — so BAML tries `completion_options` and immediately fails.","commonSituations":"Migrating a BAML function between providers while keeping a raw-string completion prompt, or defining `prompt \"\"` instead of `prompt #\"...\"#` (chat) for providers like Anthropic/Gemini that have no completion mode.","solutions":["Convert the function's prompt to a chat prompt using `prompt #\"...\"#` with `{{ ctx.output_format }}` style syntax.","Use a provider that supports completion prompts (e.g. openai with a string prompt) if raw completion is required.","Check the function's client binding and pick a client whose provider matches the prompt style.","Regenerate after changing the prompt block."],"exampleFix":"// before (chat-only provider, completion prompt)\nfunction F() {\n  prompt \"Summarize this: {{ input }}\"\n}\n\n// after\nfunction F() {\n  prompt #\"\n    Summarize this: {{ input }}\n    {{ ctx.output_format }}\n  \"#\n}","handlingStrategy":"validation","validationCode":"// Ensure the function uses a chat prompt for chat-only providers\nconst fn = bamlFunctions.find(f => f.name === 'F');\nif (providerSupportsCompletionOnly(fn.client.provider) === false && typeof fn.prompt === 'string') {\n  throw new Error(`Provider ${fn.client.provider} requires a chat prompt (prompt #\"...\"#)`);\n}","typeGuard":"function isChatPrompt(fn) { return typeof fn.prompt === 'object' && fn.prompt.kind === 'chat'; }","tryCatchPattern":"try { await b.F({ input }); } catch (e) { if (String(e).includes('Completion prompts are not supported')) convertPromptToChat(); }","preventionTips":["Use `prompt #\"...\"#` (chat) for anthropic/gemini and other chat-only providers","Never use plain string prompts when migrating functions between providers","Include `{{ ctx.output_format }}` in chat prompts for structured output"],"tags":["baml","prompt","provider","unsupported"],"backgroundTag":"operation-not-supported","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"}