Python

Agents SDK

Connect AgentRPC tools to the OpenAI Agents SDK.

rpc.openai.agents.get_tools()

The get_tools() method returns your registered AgentRPC functions as OpenAI Agent tools.

# First register your functions with AgentRPC (Locally or on another machine)

# Attach the tools to the Agent
agent = Agent(name="AgentRPC Agent", tools=rpc.openai.agents.get_tools())

result = await Runner.run(
    agent,
    input="What is the weather in Melbourne?",
)

print(result.final_output)

Completions SDK

Connect AgentRPC tools to the OpenAI Completions SDK.

rpc.openai.completions.get_tools()

The get_tools() method returns your registered AgentRPC functions formatted as OpenAI tools, ready to be passed to OpenAI’s API.

# First register your functions with AgentRPC (Locally or on another machine)

# Then get the tools formatted for OpenAI
tools = rpc.openai.completions.get_tools()

# Pass these tools to OpenAI
chat_completion = openai.chat.completions.create(
  model="gpt-4-1106-preview",
  messages=messages,
  tools=tools,
  tool_choice="auto"
)

rpc.openai.completions.execute_tool(tool_call)

The execute_tool() method executes an OpenAI tool call against your registered AgentRPC functions.

# Process tool calls from OpenAI's response
if chat_completion.choices[0].tool_calls:
  for tool_call in response_message.tool_calls:
    rpc.openai.completions.execute_tool(tool_call)

For more details, visit the Python SDK GitHub repository.

TypeScript

Connect AgentRPC tools to the OpenAI Completions SDK.

You can use the rpc.OpenAI object to get tools formatted for the OpenAI Completions SDK.

// Get tools formatted for OpenAI completions SDK
const tools = await rpc.OpenAI.getTools();

// Pass these tools to OpenAI
const completion = await openai.chat.completions.create({
  model: "gpt-4o",
  messages: messages,
  tools: tools,
  tool_choice: "auto",
});

const responseMessage = completion.choices[0]?.message;

// Execute tool calls from OpenAI's response
if (responseMessage.tool_calls && responseMessage.tool_calls.length > 0) {
  for (const toolCall of responseMessage.tool_calls) {
    const result = await rpc.OpenAI.executeTool(toolCall);
    // Use the result...
  }
}

For more details, visit the NodeJS SDK GitHub repository.