Basic Agent
Code
1from kern.agent import Agent, RunOutput # noqa2from kern.models.portkey import Portkey34# Create model using Portkey5model = Portkey(6 id="@first-integrati-707071/gpt-5-nano",7)89agent = Agent(model=model, markdown=True)1011# Get the response in a variable12# run: RunOutput = agent.run("What is Portkey and why would I use it as an AI gateway?")13# print(run.content)1415# Print the response in the terminal16agent.print_response("What is Portkey and why would I use it as an AI gateway?")Usage
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API keys
1export PORTKEY_API_KEY=***2export PORTKEY_VIRTUAL_KEY=***Install dependencies
1uv pip install -U kern-aiRun Agent
1python cookbook/11_models/portkey/basic.py