Skip to main content

OpenAI Responses

The openai-responses provider supports OpenAI's /responses endpoint, which uses the newer Responses API instead of Chat Completions.

tip

OpenAI recommends the Responses API for new users. See OpenAI's comparison guide.

warning

o1-mini is not supported with the openai-responses provider.

Basic Example​

client<llm> MyResponsesClient {
provider "openai-responses"
options {
api_key env.MY_OPENAI_KEY
model "gpt-4o"
reasoning {
effort "medium"
}
}
}

BAML-Specific Options​

OptionTypeDefaultDescription
api_keystringenv.OPENAI_API_KEYAPI key
base_urlstringhttps://api.openai.com/v1Base URL
headersobject-Additional headers
client_response_typestring"openai-responses"Response format

Provider Parameters​

reasoning.effort​

Controls the reasoning effort level:

ValueDescription
lowMinimal reasoning effort
mediumBalanced reasoning effort
highMaximum reasoning effort
client<llm> HighReasoningClient {
provider openai-responses
options {
model "o4-mini"
reasoning {
effort "high"
}
}
}

tools​

Tools the model can use during reasoning:

client<llm> WebSearchClient {
provider openai-responses
options {
model "gpt-4o"
tools [
{
type "web_search_preview"
}
]
}
}

Available Models​

ModelUse CaseContextFeatures
gpt-4oGeneral purpose128KMultimodal, balanced
gpt-4o-miniCost-efficient128KFast, affordable
o4-miniFast reasoningStandard92.7% AIME, cost-efficient

Use Cases​

Image Input​

client<llm> VisionClient {
provider openai-responses
options {
model "gpt-4o"
}
}

function AnalyzeImage(img: image) -> string {
client VisionClient
prompt #"
{{ _.role("user") }}
What is in this image?
{{ img }}
"#
}

Advanced Reasoning​

client<llm> AdvancedReasoningClient {
provider openai-responses
options {
model "o4-mini"
reasoning {
effort "high"
}
}
}

function SolveComplexProblem(problem: string) -> string {
client AdvancedReasoningClient
prompt #"
{{ _.role("user") }}
Solve this step by step: {{ problem }}
"#
}

See Also​