Getting Started with OpenAI Agent Kit¶
OpenAI Agent Kit packages opinionated utilities for building production-ready AI agents—wrapping model calls, tool routing, and evaluation in a way that scales from quick prototypes to real apps.
This guide walks you through installing Agent Kit, scaffolding a minimal agent, wiring tools, and running automated checks so you can ship confidently.
Prerequisites¶
- Python 3.10+
- An OpenAI API key stored in
OPENAI_API_KEY uvorpipfor dependency management
1. Install the Agent Kit¶
Create and activate a virtual environment, then install the core package and CLI helpers:
Prefer pip? Swap the last line for pip install openai-agent-kit openai.
2. Scaffold an Agent project¶
Generate a starter layout with the built-in CLI:
The CLI creates a modular project:
my-agent/
agentkit.toml # project metadata and model defaults
main.py # runnable agent entrypoint
tools/ # register custom tools here
tests/ # agent regression tests
3. Configure the agent¶
Open main.py and register the core planner, tool router, and a short-term memory store:
from agentkit import Agent, OpenAIChatModel
from agentkit.memory import WindowMemory
from agentkit.tools import ToolRegistry
from tools.github import create_issue
model = OpenAIChatModel(model="gpt-4.1")
tools = ToolRegistry([create_issue])
memory = WindowMemory(limit=6)
agent = Agent(
model=model,
tools=tools,
memory=memory,
system_prompt="You triage GitHub issues and draft helpful replies.",
)
if __name__ == "__main__":
agent.run()
This setup gives the agent a task-specific system prompt, bounded conversational memory, and a single GitHub issue tool.
4. Add a custom tool¶
Create tools/github.py to wrap business logic or API calls:
from agentkit.tools import tool
from github import Github
@tool(name="create_github_issue", description="Create an issue in the lidenlab/site repo")
def create_issue(title: str, body: str) -> str:
client = Github()
repo = client.get_repo("lidenlab/site")
issue = repo.create_issue(title=title, body=body)
return f"Created issue #{issue.number}: {issue.title}"
Decorating the function makes it discoverable by the planner and automatically converts docstrings into tool descriptions.
5. Run and iterate¶
Start the agent locally:
The CLI streams reasoning steps, tool invocations, and final answers. Add --debug to log raw JSON payloads when troubleshooting.
6. Test the agent contract¶
Agent Kit ships with pytest fixtures for replay testing. Add a regression test to tests/test_issue_triage.py:
from agentkit.testing import AgentHarness
harness = AgentHarness("fixtures/issue_triage.yaml")
def test_triage_flow():
result = harness.run("Summarize open bug reports")
assert "summary" in result.data
Replay tests keep tools stable and prevent regressions as you tweak prompts or upgrade models.
Next steps¶
- Explore the Agent Kit docs for deployment recipes.
- Swap
WindowMemoryfor vector memory to recall longer histories. - Add observability with
agentkit.telemetryto trace token usage and tool latency.
With this foundation, you can iterate from a single scripted tool to a full workflow orchestrator backed by Agent Kit.