Skip to main content

Python SDK for AgentRPC

Project description

AgentRPC Python SDK

A universal RPC layer for AI agents. Connect to any function, any language, any framework, in minutes.

⚠️ The AgentRPC Python SDK does not currently support registering tools.

Installation

pip install agentrpc

Registering Tools

Creating an AgentRPC Client

from agentrpc import AgentRPC

agentrpc = AgentRPC(
  api_secret="YOUR_API_SECRET"
)

OpenAI Tools

AgentRPC provides integration with OpenAI's function calling capabilities, allowing you to expose your registered RPC functions as tools for OpenAI models to use.

Agents SDK

client.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=agentrpc.openai.agents.get_tools())

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

print(result.final_output)

Completions SDK

client.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 = agentrpc.openai.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"
)

client.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:
    client.openai.execute_tool(tool_call)

API

AgentRPC(options?)

Creates a new AgentRPC client.

Options:

Option Type Default Description
api_secret str Required The API secret key.
endpoint str https://api.agentrpc.com Custom API endpoint.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentrpc-0.0.7.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentrpc-0.0.7-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file agentrpc-0.0.7.tar.gz.

File metadata

  • Download URL: agentrpc-0.0.7.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for agentrpc-0.0.7.tar.gz
Algorithm Hash digest
SHA256 dbbe9a3874e17cbd441460b63cffba4c342b2b0bd190628b626240038d3fba9e
MD5 d62a2b674b39f4d46b391978bb6125ce
BLAKE2b-256 470d4951e801147828fc7052a81b05a801f6d6c06137fb566098ef4e98efdaa9

See more details on using hashes here.

File details

Details for the file agentrpc-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: agentrpc-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for agentrpc-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9cf8969ef6ce497b2576a91b91e61c19d54f25a60a54ef435f2c13b832ed0eb9
MD5 4b423e7155335ad325bd8606ee99fb1f
BLAKE2b-256 3130232aafe8815f7c361def2eb05b2eaa5a63d1b098167c319ca62a5980a6b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page