Classify support tickets

A focused BAML example that maps an incoming message to one known support category.

Source

examples/classify-support-tickets.baml
enum Category {
  Refund
  CancelOrder
  TechnicalSupport
  AccountIssue
  Question
}

function ClassifyMessage(input: string) -> Category {
  client: "openai/gpt-4o-mini"
  prompt: `
    Classify the following message into one category:

    ${input}

    ${ctx.output_format()}
  `
}
enum Category {
  Refund
  CancelOrder
  TechnicalSupport
  AccountIssue
  Question
}

function ClassifyMessage(input: string) -> Category {
  client: "openai/gpt-4o-mini"
  prompt: `
    Classify the following message into one category:

    ${input}

    ${ctx.output_format()}
  `
}

Call it

import { b } from "./baml_client"

const category = await b.ClassifyMessage(
  "I was charged twice for my order",
)

Why this shape

An enum makes the output space explicit and gives generated clients a named result type. The application can switch on known values instead of normalizing arbitrary model text.

Read the function reference for syntax details or expand the same pattern in the structured extraction tutorial.