Skip to content

API Reference

LangGraphApp

LangGraphApp(auth_level=func.AuthLevel.ANONYMOUS, max_stream_response_bytes=1024 * 1024, max_request_body_bytes=1024 * 1024, max_input_depth=32, max_input_nodes=10000, platform_compat=False, _registrations=dict()) dataclass

Wraps LangGraph compiled graphs into Azure Functions HTTP endpoints.

Usage::

from azure_functions_langgraph import LangGraphApp

app = LangGraphApp()
app.register(graph=compiled_graph, name="my_agent")
func_app = app.function_app

This auto-registers:

  • POST /api/graphs/{name}/invoke — synchronous invocation
  • POST /api/graphs/{name}/stream — buffered SSE response (not true streaming)
  • GET /api/health — health check with registered graph list
  • GET /api/graphs/{name}/threads/{thread_id}/state — thread state (StatefulGraph only)
Note

The graph argument must satisfy the :class:LangGraphLike protocol (i.e. have .invoke() and .stream() methods). This avoids a hard import dependency on langgraph at the library level.

Note

v0.1 streams are buffered — all chunks are collected and returned in a single SSE-formatted HTTP response. True streaming (chunked transfer encoding) is planned for a future release once Azure Functions Python HTTP streaming stabilises.

Note

The default auth_level is ANONYMOUS for local development convenience. This will change to FUNCTION in v1.0. For production deployments, always pass auth_level explicitly.

function_app property

Return an azure.functions.FunctionApp with all routes registered.

register(graph, name, description=None, stream=True, auth_level=None, *, request_model=None, response_model=None)

Register a compiled LangGraph graph.

Parameters:

Name Type Description Default
graph Any

Any object satisfying :class:~protocols.LangGraphLike (typically a CompiledStateGraph from langgraph).

required
name str

Unique name for this graph (used in URL routes).

required
description Optional[str]

Optional human-readable description.

None
stream bool

Whether to enable the stream endpoint for this graph.

True
auth_level Optional[AuthLevel]

Override app-level auth for this graph's endpoints. When None (default), the app-level auth_level is used.

None
request_model Optional[type[Any]]

Optional Pydantic model class for request body (used by the metadata / bridge API, not for runtime validation).

None
response_model Optional[type[Any]]

Optional Pydantic model class for response body (used by the metadata / bridge API, not for runtime validation).

None

Raises:

Type Description
TypeError

If graph does not satisfy the required protocol.

ValueError

If name is already registered or invalid.

Source code in src/azure_functions_langgraph/app.py
def register(
    self,
    graph: Any,
    name: str,
    description: Optional[str] = None,
    stream: bool = True,
    auth_level: Optional[func.AuthLevel] = None,
    *,
    request_model: Optional[type[Any]] = None,
    response_model: Optional[type[Any]] = None,
) -> None:
    """Register a compiled LangGraph graph.

    Args:
        graph: Any object satisfying :class:`~protocols.LangGraphLike`
            (typically a ``CompiledStateGraph`` from ``langgraph``).
        name: Unique name for this graph (used in URL routes).
        description: Optional human-readable description.
        stream: Whether to enable the stream endpoint for this graph.
        auth_level: Override app-level auth for this graph's endpoints.
            When ``None`` (default), the app-level ``auth_level`` is used.
        request_model: Optional Pydantic model class for request body
            (used by the metadata / bridge API, not for runtime validation).
        response_model: Optional Pydantic model class for response body
            (used by the metadata / bridge API, not for runtime validation).

    Raises:
        TypeError: If *graph* does not satisfy the required protocol.
        ValueError: If *name* is already registered or invalid.
    """
    if not isinstance(graph, InvocableGraph):
        raise TypeError(f"Graph must have an invoke() method. Got {type(graph).__name__}")
    name_err = validate_graph_name(name)
    if name_err:
        raise ValueError(name_err)
    if name in self._registrations:
        raise ValueError(f"Graph {name!r} is already registered")
    self._registrations[name] = _GraphRegistration(
        graph=graph,
        name=name,
        description=description,
        stream_enabled=stream,
        auth_level=auth_level,
        request_model=request_model,
        response_model=response_model,
    )
    # Reset cached function app so routes are re-generated
    self._function_app = None

Request models

InvokeRequest

InvokeRequest

Bases: BaseModel

Request body for graph invocation.

StreamRequest

StreamRequest

Bases: BaseModel

Request body for graph streaming.

Response models

InvokeResponse

InvokeResponse

Bases: BaseModel

Response body for graph invocation.

HealthResponse

HealthResponse

Bases: BaseModel

Health check response.

ErrorResponse

ErrorResponse

Bases: BaseModel

Error response body.

GraphInfo

GraphInfo

Bases: BaseModel

Information about a registered graph.

Protocol interfaces

InvocableGraph

InvocableGraph

Bases: Protocol

Protocol for a graph that supports synchronous invocation.

StreamableGraph

StreamableGraph

Bases: Protocol

Protocol for a graph that supports synchronous streaming.

LangGraphLike

LangGraphLike

Bases: InvocableGraph, StreamableGraph, Protocol

Protocol combining invoke and stream — matches LangGraph's CompiledStateGraph.