Current Python SDK shape
Start with the Python openai-agents package, define an Agent, and run it with Runner from an async main function.
An OpenAI Agents SDK starter generator creates copy-ready Python boilerplate for an Agent, Runner, function tools, handoffs, install commands, and environment setup so you can start from a working local agent.
import asyncio
from agents import Agent, Runner, function_tool
@function_tool
def search_docs(query: str) -> str:
"""Search internal documentation for a short answer."""
return f"Search results for: {query}"
agent = Agent(
name="Developer Onboarding Agent",
model="gpt-5.1",
instructions="You help developers set up a small agent workflow. Ask one clarifying question when the request is underspecified.",
tools=[search_docs],
)
async def main() -> None:
result = await Runner.run(agent, "Answer developer onboarding questions")
print(result.final_output)
if __name__ == "__main__":
asyncio.run(main())
mkdir agents-starter cd agents-starter uv init --python 3.11 uv add openai-agents export OPENAI_API_KEY="sk-..." uv run python agent.py
OPENAI_API_KEY=sk-... OPENAI_MODEL=gpt-5.1 # Traces are available in the OpenAI dashboard after each run.
Start with the Python openai-agents package, define an Agent, and run it with Runner from an async main function.
Generate a safe placeholder @function_tool stub first, then replace it with your real docs, ticketing, or scoring integration.
Use handoffs when a specialist should take over a turn, or use agents as tools when one manager agent should keep control.
An OpenAI Agents SDK starter generator creates copy-ready Python boilerplate for Agent, Runner, optional function tools, handoffs, install commands, and environment setup.
Install the Python SDK with the openai-agents package. You can use pip install openai-agents or uv add openai-agents in a Python 3.10 or newer project.
Use handoffs when a routing agent should delegate part of a request to a specialist agent. For one simple workflow, start with a single Agent and add tools first.
No. The generator runs entirely in your browser and only produces starter code. The generated Python code calls the API after you add your own OPENAI_API_KEY.
After you run an agent with a valid API key, review traces in the OpenAI dashboard Trace viewer to inspect turns, tools, handoffs, and final output.