ResponsesHostServer(
self,
graph: 'CompiledStateGraph',
*,
app: Optional[ResponsesAgentServerHost] = None,
options| Name | Type | Description |
|---|---|---|
graph* | 'CompiledStateGraph' | The compiled LangGraph state graph to host. By default the
state schema must declare a |
| Name | Type |
|---|---|
| graph | 'CompiledStateGraph' |
| app | Optional[ResponsesAgentServerHost] |
| options | Optional[ResponsesServerOptions] |
| store | Optional[ResponseProviderProtocol] |
| conversation_chain_store | Optional[ConversationChainStoreProtocol] |
| prefix | str |
| applicationinsights_connection_string | Optional[str] |
| graceful_shutdown_timeout | Optional[int] |
Host a LangGraph CompiledStateGraph as the Azure AI Responses API.
Example:
Create a LangChain agent graph and host it on POST /responses::
import os
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI
from langchain_azure_ai.agents.hosting import ResponsesHostServer
model = ChatOpenAI(
model=os.environ.get("AZURE_AI_MODEL_DEPLOYMENT_NAME", "gpt-4o"),
)
graph = create_agent(model, tools=[])
ResponsesHostServer(graph).run(port=8088)
A minimal non-streaming request is {"input": "Hello!"}.
Streaming requests use {"input": "Hello!", "stream": true}.
The host owns an internal :class:ResponsesAgentServerHost and
registers a default request → graph → events conversion pipeline
against it. For advanced scenarios (custom routes, multi-protocol
composition, custom converter), users may either:
handle_create, orResponsesAgentServerHost directly and write
their own @response_handler.