{"name":"openai-agents-sdk","url":"https://skills.sh/laguagu/claude-code-nextjs-skills/openai-agents-sdk","install":"npx skills add laguagu/claude-code-nextjs-skills --skill openai-agents-sdk","sdk":"openai-agents","key":"openai-agents/openai-agents-sdk","description":"OpenAI Agents SDK (Python) development. Use when building AI agents, multi-agent handoffs, function tools, guardrails, sessions, streaming, or tracing with the `openai-agents` / `agents` Python package — including Azure OpenAI via LiteLLM. Triggers on imports from `agents`, uses of `Runner.run_sync`/`Runner.run_streamed`, `@function_tool`, `AgentOutputSchema`, `SQLiteSession`, or questions about the openai-agents-python SDK.","hasContent":true,"content":"---\nname: openai-agents-sdk\nargument-hint: \"[question or feature]\"\ndescription: OpenAI Agents SDK (Python) development. Use when building AI agents, multi-agent handoffs, function tools, guardrails, sessions, streaming, or tracing with the `openai-agents` / `agents` Python package — including Azure OpenAI via LiteLLM. Triggers on imports from `agents`, uses of `Runner.run_sync`/`Runner.run_streamed`, `@function_tool`, `AgentOutputSchema`, `SQLiteSession`, or questions about the openai-agents-python SDK.\n---\n\n# OpenAI Agents SDK (Python)\n\nUse this skill when developing AI agents using OpenAI Agents SDK (`openai-agents` package).\n\n## Quick Reference\n\n### Installation\n\n```bash\npip install openai-agents\n```\n\n### Environment Variables\n\n```bash\nOPENAI_API_KEY=sk-...\n```\n\nUsing Azure or another provider instead? See [agents.md](references/agents.md#other-providers-litellm) — don't hardcode provider env vars here, they vary and go stale.\n\n### Basic Agent\n\n```python\nfrom agents import Agent, Runner\n\nagent = Agent(\n    name=\"Assistant\",\n    instructions=\"You are a helpful assistant.\",\n    model=\"gpt-5.6\",  # or \"gpt-5.6-terra\" / \"gpt-5.6-luna\" (cheaper tiers); verify current IDs from the model catalog\n)\n\n# Synchronous\nresult = Runner.run_sync(agent, \"Tell me a joke\")\nprint(result.final_output)\n\n# Asynchronous\nresult = await Runner.run(agent, \"Tell me a joke\")\n```\n\n### Key Patterns\n\n| Pattern | Purpose |\n|---------|---------|\n| Basic Agent | Simple Q&A with instructions |\n| Azure/LiteLLM | Azure OpenAI integration |\n| AgentOutputSchema | Strict JSON validation with Pydantic |\n| Function Tools | External actions (@function_tool) |\n| Streaming | Real-time UI (Runner.run_streamed) |\n| Handoffs | Specialized agents, delegation |\n| Agents as Tools | Orchestration (agent.as_tool) |\n| LLM as Judge | Iterative improvement loop |\n| Guardrails | Input/output validation |\n| Sessions | Automatic conversation history |\n| Multi-Agent Pipeline | Multi-step workflows |\n| Sandboxing | Isolated execution environment for agents |\n| Subagents | Spawn specialized subordinate agents (Python; TS in beta/development) |\n| Observability | Built-in execution graph recording |\n\n## Preferred: Live Docs via MCP\n\nModel names and API details change frequently. When available, consult the **OpenAI Developer Docs MCP server** (`openaiDeveloperDocs`) before relying on the static references below.\n\nSetup (Codex CLI):\n```bash\ncodex mcp add openaiDeveloperDocs --url https://developers.openai.com/mcp\n```\n\nOr config (`~/.codex/config.toml`, VS Code `.vscode/mcp.json`, Cursor `~/.cursor/mcp.json`):\n```toml\n[mcp_servers.openaiDeveloperDocs]\nurl = \"https://developers.openai.com/mcp\"\n```\n\nKey tools: `mcp__openaiDeveloperDocs__search_openai_docs`, `fetch_openai_doc`, `list_api_endpoints`, `get_openapi_spec`.\n\n**Rules:** Cite fetched docs. Never speculate on field names, defaults, or current model IDs — fetch first. Keep quotes under 125 chars.\n\nFallback when MCP is unavailable: `https://developers.openai.com/api/docs/llms.txt` (plain-text index of all API docs; each entry has a `.md` twin at `/api/docs/<slug>.md`).\n\n## Reference Documentation\n\nOffline/quick-lookup snippets. Verify model names and API signatures against the MCP or docs when accuracy matters.\n\n- [agents.md](references/agents.md) - Agent creation, multi-provider setup via LiteLLM\n- [tools.md](references/tools.md) - Function tools, hosted tools, agents as tools\n- [structured-output.md](references/structured-output.md) - Pydantic output, AgentOutputSchema\n- [streaming.md](references/streaming.md) - Streaming patterns, SSE with FastAPI\n- [handoffs.md](references/handoffs.md) - Agent delegation\n- [guardrails.md](references/guardrails.md) - Input/output validation\n- [sessions.md](references/sessions.md) - Sessions, conversation history\n- [patterns.md](references/patterns.md) - Multi-agent workflows, LLM as judge, tracing\n\n## Official Documentation\n\n- **Docs:** https://openai.github.io/openai-agents-python/\n- **Examples:** https://github.com/openai/openai-agents-python/tree/main/examples\n- **Major update:** https://openai.com/index/the-next-evolution-of-the-agents-sdk/\n- **Docs MCP setup:** https://developers.openai.com/learn/docs-mcp\n- **Docs index (llms.txt):** https://developers.openai.com/api/docs/llms.txt\n- **Current model IDs:** https://platform.openai.com/docs/models\n","contentSource":"https://raw.githubusercontent.com/laguagu/claude-code-nextjs-skills/main/skills/openai-agents-sdk/SKILL.md","contentFetchedAt":"2026-07-27T09:00:57.801Z"}