Skip to content

Latest commit

 

History

History
80 lines (58 loc) · 2.35 KB

File metadata and controls

80 lines (58 loc) · 2.35 KB

openai-agenium-bridge

OpenAI Function Calling bridge for the Agenium agent:// protocol.

Automatically discovers agent capabilities via DNS + agent cards, converts them to OpenAI-compatible tool definitions, and executes tool calls against agent endpoints.

Installation

pip install openai-agenium-bridge

Quick Start

import asyncio
from openai import OpenAI
from openai_agenium import AgeniumBridge

async def main():
    bridge = AgeniumBridge()

    # Discover agents → OpenAI tool definitions
    tools = await bridge.discover_tools([
        "agent://search.agenium",
        "agent://weather.agenium",
    ])

    # Use with OpenAI
    client = OpenAI()
    response = client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": "Search for AI papers"}],
        tools=tools,
    )

    # Execute any tool calls
    if response.choices[0].message.tool_calls:
        results = await bridge.execute(response.choices[0].message.tool_calls)
        for r in results:
            print(f"{r.skill}: {'✓' if r.success else '✗'} {r.result or r.error}")

asyncio.run(main())

How It Works

  1. DNS Resolution — Resolves agent:// URIs via Agenium DNS (185.204.169.26:3000)
  2. Agent Card Fetch — Gets /.well-known/agent-card from each agent's endpoint
  3. Tool Conversion — Maps agent skills → OpenAI function-calling tool definitions
  4. Execution — Sends Agenium protocol frames to agent endpoints with retries

API

AgeniumBridge

Method Description
discover_tools(uris) Resolve agents and return OpenAI tool defs
execute(tool_calls) Execute OpenAI tool calls against agents
clear_cache() Clear DNS resolver cache

Configuration

bridge = AgeniumBridge(
    dns_server="185.204.169.26",  # Agenium DNS server
    dns_port=3000,                 # DNS HTTP port
    request_timeout=30.0,          # Per-request timeout
    max_retries=3,                 # Retry count on failure
)

Domain Registration

Supports optional domain registration on the Agenium DNS system using a marketplace API key (dom_<64 hex>). Pass api_key parameter to auto-register your agent on startup. Get your API key from the Telegram Domain Marketplace.

License

MIT