Skip to main content

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())

Metadata

Release files for uni-agent 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uni-agent 0.1.1
File Size Uploaded
uni_agent-0.1.1.tar.gz 19.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for uni-agent 0.1.1
File Interpreter ABI Platform
uni_agent-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 45.6 kB

Release files / uni_agent-0.1.1.tar.gz

Download URL uni_agent-0.1.1.tar.gz
Size 19.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8bff84cb1df48ca2e6d8e099a8dd8ca664de252dc3e4c9e1bffe6b9b55f62975
BLAKE2b-256 checksum
How to use checksums
26c5157e67670dbe22c6b40de5f4090006e63358521a5e25aff870120c8d8a6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / uni_agent-0.1.1-py3-none-any.whl

Download URL uni_agent-0.1.1-py3-none-any.whl
Size 25.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4a5cd635321e85070558041787949811f41c13cbadcc42a54ef57a7392dbdc3
BLAKE2b-256 checksum
How to use checksums
0fb758581273f0b7069a0d0de75edeb678eeaa87933c9ceea9d70f88980c7e8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page