Back to Icho Home Icho v0.8.0

Structured Outputs Support

Many LLM applications require structured, schema-conforming outputs (such as Pydantic models). Icho natively supports recording and replaying structured outputs generated via LangChain's .with_structured_output() mechanism.

LangChain Structured Output Example:

from pydantic import BaseModel, Field
from langchain_groq import ChatGroq
from icho import cassette

class Person(BaseModel):
    name: str = Field(description="The name of the person")
    age: int = Field(description="The age of the person")

model = ChatGroq(model_name="openai/gpt-oss-120b")
structured_llm = model.with_structured_output(Person, method="json_schema")

# Intercept structured calls within this context block
with cassette("tests/cassettes"):
    result = structured_llm.invoke("Alice is 30 years old. Extract her name and age.")
    print(result.name, result.age)
    # Output: Alice 30