ConnectOnion

ConnectOnion

The simplest way to build AI agents with Python functions

2 Lines of Code
Turn any Python function into an AI tool
🔍
Built-in Debugging
@xray decorator shows agent thinking
📊
Auto Tracking
Automatic behavior recording and history

Installation

Terminal
$ pip install connectonion

Simple Example

That's it! Agents need just: name + tools (your existing Python functions). Everything else is optional.
simple_example.py
from connectonion import Agent

def get_weather(city: str) -> str:
    """Get current weather for a city."""
    return f"Weather in {city}: sunny, 72°F"

# Create agent
agent = Agent("assistant", tools=[get_weather])

# Use the agent
response = agent.run("What's the weather in NYC?")
print(response)  # Output: "Weather in NYC: sunny, 72°F"

Advanced Configuration

ConnectOnion agents support multiple configuration options for different use cases:

advanced_config.py
from connectonion import Agent

# Full configuration example
agent = Agent(
    name="advanced_assistant",
    model="gpt-5-mini",           # Model selection (default)
    api_key="sk-...",              # Optional API key
    system_prompt="Be concise",    # Custom personality
    tools=[calculate, search],    # Multiple tools
)

# Available Models:
# - gpt-5-nano: Fastest, most cost-effective
# - gpt-5-mini: Balanced performance (default)
# - gpt-5: Most capable, highest quality

# API Key Options:
# 1. Environment variable (recommended):
#    export OPENAI_API_KEY="sk-..."
# 2. Pass directly:
#    agent = Agent(api_key="sk-...")

# System Prompt Options:
# 1. Inline string:
#    system_prompt="You are helpful"
# 2. File path:
#    system_prompt="prompts/agent.md"
# 3. None (uses default):
#    system_prompt=None

🚀 Model Selection

Choose based on your needs:

  • gpt-5-nano: Fast responses
  • gpt-5-mini: Balanced (default)
  • gpt-5: Best quality

🔑 API Key Setup

Two ways to configure:

  • • Environment variable
  • • Direct parameter
  • • Custom LLM provider

💬 System Prompts

Define agent personality:

  • • Inline strings
  • • External files (.md, .txt)
  • • Dynamic loading

Next Steps