Output Schema

This example shows how to use the output_model parameter to specify the model that will be used to generate the final response.

1"""
2Output Schema
3=============================
4
5This example shows how to use the output_model parameter to specify the model that will be used to generate the final response.
6"""
7
8from kern.agent import Agent
9from kern.models.openai import OpenAIResponses
10from kern.tools.websearch import WebSearchTools
11
12# ---------------------------------------------------------------------------
13# Create Agent
14# ---------------------------------------------------------------------------
15agent = Agent(
16 model=OpenAIResponses(id="gpt-5.2"),
17 output_model=OpenAIResponses(id="gpt-5-mini"),
18 tools=[WebSearchTools()],
19)
20
21# ---------------------------------------------------------------------------
22# Run Agent
23# ---------------------------------------------------------------------------
24if __name__ == "__main__":
25 agent.print_response("Latest news from France?", stream=True)

Run the Example

1# Clone and setup repo
2git clone https://github.com/kern-ai/kern.git
3cd kern/cookbook/02_agents/02_input_output
4
5# Create and activate virtual environment
6./scripts/demo_setup.sh
7source .venvs/demo/bin/activate
8
9python output_schema.py