Skip to main content

Unified Agent SDK

Project description

UniAgent

UniAgent provides a unified agent SDK that normalizes LLM inputs/outputs to a Claude-compatible canonical protocol, with driver adapters for multiple model providers and built-in middleware/observability hooks.

Installation

pip install -e .

Optional observability support:

pip install -e .[otel]

Quick Start

import os

from uniagent import UniAgent

agent = UniAgent(
    provider="claude",
    model="claude-sonnet-4-5-20250929",
    api_key=os.getenv("ANTHROPIC_API_KEY"),
)

response = await agent.run([agent.user("Hello")])

print(response)

Tool Registration

from uniagent import UniAgent

@UniAgent.tool
def get_weather(city: str) -> str:
    """Get weather for a city."""
    return f"Sunny in {city}"

agent = UniAgent(
    provider="claude",
    model="claude-sonnet-4-5-20250929",
    api_key="YOUR_ANTHROPIC_API_KEY",
    tools=[get_weather],
)

Streaming

async for event in agent.stream(messages):
    print(event.event, event.data)

Provider Examples

Anthropic Claude (Unified Factory)

import asyncio
import os

from uniagent import UniAgent


@UniAgent.tool
def get_weather(city: str) -> str:
    """Get weather for a city."""
    return f"Sunny in {city}"


async def main() -> None:
    agent = UniAgent(
        provider="claude",
        model="claude-sonnet-4-5-20250929",
        api_key=os.getenv("ANTHROPIC_API_KEY"),
        tools=[get_weather],
    )

    response = await agent.run(
        [agent.user("Weather in Tokyo?")],
        config={"max_tokens": 256, "enable_betas": ["structured-outputs-2025-11-13"]},
    )
    print(response)


if __name__ == "__main__":
    asyncio.run(main())

Google Gemini (Unified Factory)

import asyncio
import os

from uniagent import UniAgent


@UniAgent.tool
def multiply(a: int, b: int) -> int:
    """Multiply two integers."""
    return a * b


async def main() -> None:
    agent = UniAgent(
        provider="gemini",
        model="gemini-1.5-pro",
        api_key=os.getenv("GOOGLE_API_KEY"),
        tools=[multiply],
    )

    response = await agent.run(
        [agent.user("2 * 21")],
        config={"generation_config": {"max_output_tokens": 256}},
    )
    print(response)


if __name__ == "__main__":
    asyncio.run(main())

OpenAI (Unified Factory)

import asyncio
import os

from uniagent import UniAgent


async def main() -> None:
    agent = UniAgent(
        provider="openai",
        model="gpt-5.2",
        api_key=os.getenv("OPENAI_API_KEY"),
    )

    response = await agent.run([agent.user("Hello")])
    print(response)


if __name__ == "__main__":
    asyncio.run(main())

DeepAgents / LangGraph (Unified Factory)

import asyncio
from typing import Dict, List

from uniagent import UniAgent


def build_graph():
    from langgraph.graph import END, StateGraph

    class State(Dict):
        messages: List[UniAgent.Message]

    def final_node(state: State) -> str:
        return "DeepAgent output"

    graph = StateGraph(State)
    graph.add_node("final", final_node)
    graph.set_entry_point("final")
    graph.add_edge("final", END)
    return graph.compile()


async def main() -> None:
    agent = UniAgent(
        provider="deep_agent",
        graph_builder="examples.deep_agent_basic:build_graph",
    )

    response = await agent.run([agent.user("Run the graph")])
    print(response)


if __name__ == "__main__":
    asyncio.run(main())

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

uni_agent-0.1.1.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

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

uni_agent-0.1.1-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file uni_agent-0.1.1.tar.gz.

File metadata

  • Download URL: uni_agent-0.1.1.tar.gz
  • Upload date:
  • Size: 19.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for uni_agent-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8bff84cb1df48ca2e6d8e099a8dd8ca664de252dc3e4c9e1bffe6b9b55f62975
MD5 919b8d591862def46ce6bfe4f4103e53
BLAKE2b-256 26c5157e67670dbe22c6b40de5f4090006e63358521a5e25aff870120c8d8a6e

See more details on using hashes here.

File details

Details for the file uni_agent-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: uni_agent-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for uni_agent-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d4a5cd635321e85070558041787949811f41c13cbadcc42a54ef57a7392dbdc3
MD5 90404437200ac8fb4b96573c6497b410
BLAKE2b-256 0fb758581273f0b7069a0d0de75edeb678eeaa87933c9ceea9d70f88980c7e8b

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