LangChain
LangChain works against ai& through ChatOpenAI — point it at the ai& base URL and your existing chains, agents, and graphs work unchanged.
pip install langchain langchain-openaifrom langchain_openai import ChatOpenAI
llm = ChatOpenAI( model="openai/gpt-oss-120b", base_url="https://api.aiand.com/v1", api_key="sk-your-api-key",)
print(llm.invoke("Hello").content)In a chain
Section titled “In a chain”from langchain_core.prompts import ChatPromptTemplate
prompt = ChatPromptTemplate.from_messages([ ("system", "Translate the user's input to {language}."), ("user", "{text}"),])
chain = prompt | llm
print(chain.invoke({"language": "Japanese", "text": "Hello, world!"}).content)With tools
Section titled “With tools”from langchain_core.tools import tool
@tooldef get_weather(city: str) -> str: """Get current weather for a city.""" return f"Sunny in {city}, 22°C"
llm_with_tools = llm.bind_tools([get_weather])response = llm_with_tools.invoke("What's the weather in Tokyo?")print(response.tool_calls)LangGraph
Section titled “LangGraph”LangGraph nodes that wrap ChatOpenAI work the same way — there’s nothing ai&-specific. See LangGraph docs.