GPT-5 preset (ApplyPatchTool)
The GPT-5 preset is an opt-in agent preset for patch-based file editing. Calling get_gpt5_agent(llm) creates an agent that uses ApplyPatchTool instead of the standard FileEditorTool, while leaving the default preset unchanged for everything else.
Ready-to-run example
"""Example: Using GPT-5 preset with ApplyPatchTool for file editing.
This example demonstrates how to enable the GPT-5 preset, which swaps the
standard claude-style FileEditorTool for ApplyPatchTool.
Usage:
export OPENAI_API_KEY=... # or set LLM_API_KEY
# Optionally set a model (we recommend a mini variant if available):
# export LLM_MODEL=(
# "openai/gpt-5.2-mini" # or fallback: "openai/gpt-5.1-mini" or "openai/gpt-5.1"
# )
uv run python examples/04_llm_specific_tools/01_gpt5_apply_patch_preset.py
"""
import os
from faheemcode.sdk import LLM, Agent, Conversation
from faheemcode.tools.preset.gpt5 import get_gpt5_agent
# Resolve API key from env
api_key = os.getenv("LLM_API_KEY") or os.getenv("OPENAI_API_KEY")
if not api_key:
raise SystemExit("Please set OPENAI_API_KEY or LLM_API_KEY to run this example.")
model = os.getenv("LLM_MODEL", "openai/gpt-5.1")
base_url = os.getenv("LLM_BASE_URL", None)
llm = LLM(model=model, api_key=api_key, base_url=base_url)
# Build an agent with the GPT-5 preset (ApplyPatchTool-based editing)
agent: Agent = get_gpt5_agent(llm)
# Run in the current working directory
cwd = os.getcwd()
conversation = Conversation(agent=agent, workspace=cwd)
conversation.send_message(
"Create (or update) a file named GPT5_DEMO.txt at the repo root with "
"two short lines describing this repository."
)
conversation.run()
# Report cost
cost = llm.metrics.accumulated_cost
print(f"EXAMPLE_COST: {cost}")
You can run the example code as-is.
Bring your own provider key
export LLM_API_KEY="your-api-key"
export LLM_MODEL="anthropic/claude-sonnet-4-5-20250929" # or openai/gpt-4o, etc.
cd software-agent-sdk
uv run python examples/04_llm_specific_tools/01_gpt5_apply_patch_preset.py
Faheem Code Cloud key
# https://app.faheemcode.ai/settings/api-keys
export LLM_API_KEY="example-user-api-key"
export LLM_MODEL="faheemcode/claude-sonnet-4-5-20250929"
cd software-agent-sdk
uv run python examples/04_llm_specific_tools/01_gpt5_apply_patch_preset.py
What this preset changes
- Replaces the standard
FileEditorToolwithApplyPatchTool - Keeps the GPT-5-specific configuration explicit via
get_gpt5_agent(llm) - Leaves the default preset unchanged unless you opt into this one
See also
- LLM Reasoning - Learn more about newer OpenAI model behavior and the Responses API
- LLM Subscriptions - Use supported OpenAI subscription-backed models without API credits
- Custom Tools - Understand the standard SDK tool system and presets