Skip to main content
Aion provides helper functions to create LangChain chat models that are automatically configured for use within the Aion framework. These helpers handle authentication, endpoint selection, and runtime principal attribution transparently, so you can focus on your LangGraph logic.

Overview

Both helpers connect to the Aion control-plane model service and work in LangGraph nodes:

Functions

aion_chat_model(...)

Create a LangChain chat model configured for Aion using langchain.chat_models.init_chat_model. This is the generic approach that auto-detects the provider. For most use cases with Aion, you’ll use OpenAI models, so it behaves the same as aion_chat_openai. Parameters: Note: Do not pass api_key, base_url, default_headers, http_async_client, or http_client. These are managed by Aion. Returns: A LangChain chat model (typically ChatOpenAI) ready to use. Raises:
  • ImportError — If LangChain is not installed
  • ValueError — If any reserved parameter is provided
Example:

aion_chat_openai(...)

Create a langchain-openai ChatOpenAI model configured for Aion. Use this when you need explicit control or want to be specific about using OpenAI models. Parameters: Note: Do not pass api_key, base_url, default_headers, http_async_client, or http_client. These are managed by Aion. Returns: A ChatOpenAI instance backed by Aion’s model proxy. Raises:
  • ImportError — If langchain-openai is not installed
  • ValueError — If any reserved parameter is provided
Example:

Usage in LangGraph Nodes

Models are typically created per-node invocation to ensure fresh authentication and principal context:

Streaming

Both helpers return standard LangChain models that support streaming: