Swarm is an experimental framework by OpenAI for building multi-agent systems. It showcases the handoff & routines pattern, making agent coordination and execution lightweight, highly controllable, and easily testable. Obiguard integration extends Swarm’s capabilities with production-ready features like observability, reliability, and more.

Getting Started

1

Install the Obiguard SDK

pip install -U obiguard
2

Configure the LLM Client used in OpenAI Swarm

To build Swarm Agents with Obiguard, you’ll need either one of these keys:

  • Obiguard API Key: Sign up on the Obiguard app and copy your API key.

  • Virtual Key: Virtual Keys are a secure way to manage your LLM API KEYS in one place. Instead of handling multiple API keys in your code, you can store your LLM provider API Keys securely in Obiguard’s vault

Create a Virtual Key in the Obiguard app

from swarm import Swarm, Agent
from obiguard import Obiguard

obiguard_client = Obiguard(
  obiguard_api_key="vk-obg***", # Your Obiguard virtual key
)

client = Swarm(client=obiguard_client)
3

Create and Run an Agent

In this example we are building a simple Weather Agent using OpenAI Swarm with Obiguard.

def get_weather(location) -> str:
  return "{'temp':67, 'unit':'F'}"

agent = Agent(
  name="Agent",
  instructions="You are a helpful agent.",
  functions=[get_weather],
)

messages = [{"role": "user", "content": "What's the weather in NYC?"}]

response = client.run(agent=agent, messages=messages)
print(response.messages[-1]["content"])

E2E example with Function Calling in OpenAI Swarm

Here’s a complete example showing function calling and agent interaction:

from swarm import Swarm, Agent
from obiguard import Obiguard

obiguard_client = Obiguard(
    obiguard_api_key="vk-obg***",  # Your Obiguard virtual key
)

client = Swarm(client=obiguard_client)

def get_weather(location) -> str:
    return "{'temp':67, 'unit':'F'}"

agent = Agent(
    name="Agent",
    instructions="You are a helpful agent.",
    functions=[get_weather],
)

messages = [{"role": "user", "content": "What's the weather in NYC?"}]

response = client.run(agent=agent, messages=messages)
print(response.messages[-1]["content"])

The current temperature in New York City is 67°F.

Enabling Obiguard Features

By routing your OpenAI Swarm requests through Obiguard, you get access to the following production-grade features:

1. Interoperability - Calling Different LLMs

When building with Swarm, you might want to experiment with different LLMs or use specific providers for different agent tasks. Obiguard makes this seamless - you can switch between OpenAI, Anthropic, Gemini, Mistral, or cloud providers without changing your agent code.

Instead of managing multiple API keys and provider-specific configurations, Obiguard’s Virtual Keys give you a single point of control. Here’s how you can use different LLMs with your Swarm agents:

obiguard_client = Obiguard(
  obiguard_api_key="vk-obg***", # Your Obiguard virtual key
)

client = Swarm(client=obiguard_client)

2. Observability - Understand Your Agents

Building agents is the first step - but how do you know they’re working effectively? Obiguard provides comprehensive visibility into your agent operations through multiple lenses:

Metrics Dashboard: Track 40+ key performance indicators like:

  • Cost per agent interaction
  • Response times and latency
  • Token usage and efficiency
  • Success/failure rates
  • Cache hit rates

3. Logs and Traces

Logs are essential for understanding agent behavior, diagnosing issues, and improving performance. They provide a detailed record of agent activities and tool use, which is crucial for debugging and optimizing processes.

Access a dedicated section to view records of agent executions, including parameters, outcomes, function calls, and errors. Filter logs based on multiple parameters such as trace ID, model, tokens used, and metadata.

4. Security & Compliance - Enterprise-Ready Controls

When deploying agents in production, security is crucial. Obiguard provides enterprise-grade security features:

Budget Controls

Set and monitor spending limits per Virtual Key. Get alerts before costs exceed thresholds.

Access Management

Control who can access what. Assign roles and permissions for your team members.

Audit Logging

Track all changes and access. Know who modified agent settings and when.

Data Privacy

Configure data retention and processing policies to meet your compliance needs.

Configure these settings in the Obiguard Dashboard.