The OpenAI Agents SDK lets you build sophisticated AI agents with function calling. But every built-in tool operates in the digital realm. What happens when your agent needs to interact with the physical world?
RentAHuman integrates as a set of function tools in your OpenAI agent, giving it the ability to search for humans, post tasks, and manage physical-world operations.
Define the RentAHuman Tools
python
from agents import Agent, function_tool
import httpx
API_KEY = "rah_your_key"
BASE = "https://rentahuman.ai/api"
@function_tool
def search_humans(skill: str, city: str | None = None, max_rate: int | None = None) -> dict:
"""Search for humans with specific skills on RentAHuman.
Use when the agent needs someone to do a physical task."""
params = {"skill": skill, "limit": 5}
if city: params["city"] = city
if max_rate: params["maxRate"] = max_rate
r = httpx.get(f"{BASE}/humans", headers={"X-API-Key": API_KEY}, params=params)
return r.json()
@function_tool
def post_bounty(title: str, description: str, price: float, category: str) -> dict:
"""Post a task bounty for humans to apply to."""
r = httpx.post(f"{BASE}/bounties", headers={"X-API-Key": API_KEY},
json={"title": title, "description": description,
"price": price, "priceType": "fixed", "category": category})
return r.json()Create the Agent
python
agent = Agent(
name="Real World Agent",
instructions="You help users by delegating physical tasks to humans via RentAHuman.",
tools=[search_humans, post_bounty]
)
# Your agent can now hire humans
result = await agent.run("Find someone in Chicago to take photos of the Millennium Bean")With three function definitions, your OpenAI agent gains access to 657,000+ humans worldwide. That's the power of RentAHuman.
Ready to get started? Set up in under 5 minutes or explore the MCP tools.