BoundaryML/baml · error

Completion prompts are not supported by this provider

Error message

Completion prompts are not supported by this provider

What it means

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.

Source

Thrown at engine/baml-runtime/src/internal/llm_client/traits/completion.rs:26

    fn completion_options(&self, ctx: &RuntimeContext) -> Result<CompletionOptions>;

    #[allow(async_fn_in_trait)]
    async fn completion(&self, ctx: &impl HttpContext, prompt: &str) -> LLMResponse;
}

pub trait WithStreamCompletion: Sync + Send {
    #[allow(async_fn_in_trait)]
    async fn stream_completion(&self, ctx: &impl HttpContext, prompt: &str) -> StreamResponse;
}

pub trait WithNoCompletion {}

impl<T> WithCompletion for T
where
    T: WithNoCompletion + Send + Sync,
{
    fn completion_options(&self, _ctx: &RuntimeContext) -> Result<CompletionOptions> {
        anyhow::bail!("Completion prompts are not supported by this provider")
    }

    #[allow(async_fn_in_trait)]
    async fn completion(&self, _: &impl HttpContext, _: &str) -> LLMResponse {
        LLMResponse::InternalFailure("Completion prompts are not supported by this provider".into())
    }
}

impl<T> WithStreamCompletion for T
where
    T: WithNoCompletion + Send + Sync,
{
    #[allow(async_fn_in_trait)]
    async fn stream_completion(&self, _: &impl HttpContext, _: &str) -> StreamResponse {
        Err(LLMResponse::InternalFailure(
            "Completion prompts are not supported by this provider".to_string(),
        ))
    }

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Convert the function's prompt to a chat prompt using `prompt #"..."#` with `{{ ctx.output_format }}` style syntax.
  2. Use a provider that supports completion prompts (e.g. openai with a string prompt) if raw completion is required.
  3. Check the function's client binding and pick a client whose provider matches the prompt style.
  4. Regenerate after changing the prompt block.

Example fix

// before (chat-only provider, completion prompt)
function F() {
  prompt "Summarize this: {{ input }}"
}

// after
function F() {
  prompt #"
    Summarize this: {{ input }}
    {{ ctx.output_format }}
  "#
}
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the function uses a chat prompt for chat-only providers
const fn = bamlFunctions.find(f => f.name === 'F');
if (providerSupportsCompletionOnly(fn.client.provider) === false && typeof fn.prompt === 'string') {
  throw new Error(`Provider ${fn.client.provider} requires a chat prompt (prompt #"..."#)`);
}

Type guard

function isChatPrompt(fn) { return typeof fn.prompt === 'object' && fn.prompt.kind === 'chat'; }

Try / catch

try { await b.F({ input }); } catch (e) { if (String(e).includes('Completion prompts are not supported')) convertPromptToChat(); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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