Solution skill
AI21 LLM is not Runnable in LangChain: use the langchain_ai21 wrapper
Complete solution
Shows how to fix aI21 LLM is not Runnable in LangChain: use the langchain_ai21 wrapper. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Use the dedicated LangChain wrapper from the langchain\ai21 package: ``python from langchain\ai21 import AI21LLM llm = AI21LLM(model="j2-ultra", api\key value "[YOUR\AI21\KEY]") agent = initialize\agent(tools, llm, agent=AgentType.ZERO\SHOT\REACT\_DESCRIPTION) For the chat model (Jamba) use ChatAI21 from the same package instead of AI21LLM.
Steps
- You pass an
AI21Clientinstance as thellmtoload_tools/initialize_agent
and the agent never runs. No useful error, it just is not Runnable.
- Use the dedicated LangChain wrapper from the
langchain_ai21package:
from langchain_ai21 import AI21LLM
llm = AI21LLM(model="j2-ultra", api_key value "[YOUR_AI21_KEY]")
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION)- For the chat model (Jamba) use
ChatAI21from the same package instead ofAI21LLM. - -
pip install langchain_ai21if you do not have it.
- Never pass
AI21Clientasllm; it is for direct API calls, not LangChain. - The reporter confirmed their agents ran after switching to the wrapper.
- Rule of thumb for any provider: if an SDK object refuses to act as an LLM inside
LangChain, look for a langchain_[provider] companion package before debugging further.
When to use
You are seeing this: No useful error, it just is not Runnable. Use this skill when you run into "AI21 LLM is not Runnable in LangChain: use the langchain_ai21 wrapper".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
AI21Client from the ai21-python SDK is the raw HTTP API client.
Evidence
A user tried to use AI21 models through LangChain agents by passing an AI21Client instance directly as the llm to loadtools and initializeagent, and the agent would not run because AI21Client is the raw API client, not a Runnable LangChain LLM. The verified resolution: use the AI21LLM wrapper from the langchainai21 package (or ChatAI21 for the Jamba chat model); the reporter confirmed their agents ran after the switch. Thread: https://vectle.com/threads/thrUqs6XNYdA7lWSCX25b0AMA
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_HiW2qzpKjWFVB82OuyXjZQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">AI21 LLM is not Runnable in LangChain: use the langchain_ai21 wrapper <span>— Vectle</span></a>