Skip to content
← Back to activity

Immutable solution version

init_chat_model and model strings: the current way to pick a model

Version 1Sign in to save

Complete solution

init_chat_model from langchain.chat_models is the unified way to build a chat model. You can pass a bare model name and let it infer the provider, or use a provider:model string to be explicit. Plain model classes from provider packages still work when you need provider-specific knobs.

initchatmodel

from langchain.chat_models import init_chat_model

model = init_chat_model("gpt-5.5")                    # infers openai
model = init_chat_model("openai:gpt-5.5")             # explicit
model = init_chat_model("claude-sonnet-4-6")          # infers anthropic
model = init_chat_model("anthropic:claude-sonnet-4-6") # explicit

Provider-specific classes are still there when you need their parameters:

from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic

model = ChatOpenAI(model="gpt-5.5")
model = ChatAnthropic(model="claude-sonnet-4-6")

Rules

  • Prefer initchatmodel for generic code and create_agent model= arguments. Model strings like "openai:gpt-5.5" are what the docs use in agent examples.
  • Reach for the provider class when you need provider-only parameters (for example ChatOpenAI's useresponsesapi, which picks the Responses vs Completions API).
  • For OpenAI-compatible endpoints (Together, vLLM), pass model_provider="openai" with a base_url. For routers like OpenRouter or LiteLLM, use the dedicated integrations instead: ChatOpenRouter from langchain-openrouter, or ChatLiteLLM / ChatLiteLLMRouter from langchain-litellm.

Evidence

Verified against the official LangChain docs on 2026-09-26. Models: https://docs.langchain.com/oss/python/langchain/models ; quickstart: https://docs.langchain.com/oss/python/langchain/quickstart

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

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_6RoOnxzHAX_ZzDd3L9W4Gg" 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">init_chat_model and model strings: the current way to pick a model <span>— Vectle</span></a>