OpenAIClassifier()| Name | Type | Description |
|---|---|---|
model* | unknown | Decisions model used to answer questions. |
api_key* | unknown | OpenAI API key. If omitted, reads |
base_url* | unknown | Base URL for API requests. If omitted, reads |
organization* | unknown | OpenAI organization ID. If omitted, reads |
timeout* | unknown | Request timeout passed to the OpenAI client. |
max_retries* | unknown | Maximum number of retries passed to the OpenAI client. |
default_headers* | unknown | |
default_query* | unknown | |
http_client* | unknown | |
http_async_client* | unknown |
Base URL for API requests.
Resolution order (first match wins):
base_url kwarg.OPENAI_API_BASE (read by LangChain at init).LANGSMITH_GATEWAY is set.OPENAI_BASE_URL (read by the underlying openai SDK client).Ask typed questions about text, messages, or images with OpenAI Decisions.
A single request can combine Noul probabilities, Choice selections, and
Score ratings over shared state. The response preserves probabilities,
confidence, and token usage so application code can decide whether to act,
route, or request human review.
Messages are sent as native Decisions API input items, so tool calls and tool results keep their roles. Other structured state is sent as JSON.
This is a best-effort integration with the TypeSafe-compatible
BaseDecisionModel interface. For an integration with the native OpenAI
Decisions API, use OpenAIDecisions.
Box questions raise ValueError.Choice needs at least two labels.predicate question has no outcome descriptions, so Noul
criteria are appended to the instructions as text.invoke raises ModelRefusalError and the other answers are discarded.safety_identifier, and cache breakpoints are
not exposed.http(s) URLs; files and audio raise ValueError.from langchain_core.decisions import Choice, Noul, Score
from langchain_openai.decisions import OpenAIClassifier
classifier = OpenAIClassifier(model="gpt-6-luna")
response = classifier.invoke(
{
"state": "Stripe has failed to connect for three days. Help ASAP.",
"questions": {
"department": Choice(
instructions="Which team should handle this request?",
criteria={
"billing": "Payment or subscription issues.",
"technical": "Product bugs or integration failures.",
},
),
"urgent": Noul(instructions="Is this request urgent?"),
"frustration": Score(
instructions="How frustrated does the customer appear?",
criteria=["Calm.", "Concerned but civil.", "Very angry."],
),
},
}
)
print(response.choices["department"].choice)
print(response.nouls["urgent"].noul)
print(response.scores["frustration"].score)Headers sent with every request.
Query parameters sent with every request.
Optional httpx.Client used by sync invocations.
Optional httpx.AsyncClient used by async invocations.