LangChain – Models

Table Of Contents:

  1. What Is A Model ?
  2. Basic Uses Of Model.
  3. Parameters To The Model
  4. Model Invocation
  5. Tool Calling
  6. Structured Output
  7. Model Profilling
  8. Multimodal Model
  9. Reasoning Model
  10. Local Models
  11. Prompt Catching
  12. Server Side Tool Uses
  13. Rate Limiting
  14. Base URL & Proxy Setting
  15. Log Probabilities
  16. Token Uses
  17. Model Invocation Config
  18. Configurable Model
  19. Dynamic Model Selection

(1) What Is A Model ?

(2) Basic Uses Of Model.

pip install -U "langchain[openai]"
import os
from langchain.chat_models import init_chat_model

os.environ["OPENAI_API_KEY"] = "sk-..."

model = init_chat_model("gpt-5.5")
response = model.invoke("How Are You Doing?")

(3) Model Parameters

model = init_chat_model(
        model = "qwen3:0.6b",
        temperature = 0.7,
        timeout=30,
        max_token=1000,
        max_retries=6,
        )

(4) Model Invocation

(5) Model Streaming:

(6) Model Batch Processing:

(5) Model Tool Calling

from langchain.tools import tool


@tool
def get_weather(location:str)->str:
    """Get Weather At A Location"""
    return f"It's Sunny In {city}"
    
model_with_tools = model.bind_tools([get_weather])

response = model_with_tools.invoke("What Is The Weather In Bhubaneswar?")


for tool_call in response.tool_calls:
    # View tool calls made by the model
    print(f"Tool: {tool_call['name']}")
    print(f"Args: {tool_call['args']}")

(6) Model With Structured Output

from pydentic import BaseModel, Field

class Movie(BaseModel):
     """A Movie With Details."""
     title:str = Field(description="The Title Of The Movie")
     year:int = Field(description="The Year The Movie Was Released")
     director:str= Field(description="The Director Of The Movie")
     rating:float= Field(description="The Movies Rating Out Of 10")
     
model_with_structure = model.with_structured_output(Movie)

response = model_with_structure.invoke("Provide Details About The Movie Inception")
print(response)

(7) Model Profilling

(8) Multi Modal Model

(9) Model Reasoning

(10) Local Models

(11) Prompt Catching

(12) Server Side Tool Uses

(13) Rate Limit

(14) Base URL & Proxy Settings

(15) Log Probabilities

(16) Token Uses

(17) Invocation Config

(18) Configurable Models

(19) Dynamic Model Selection

Leave a Reply

Your email address will not be published. Required fields are marked *