Overview
AI agents in OpenBB Workspace come with a lot of capabilities out-of-the-box. Particularly when it comes to interacting with data available in the workspace. The advantage is that the agent lives right where all your context is and where actual work gets done.
The OpenBB Workspace comes with OpenBB Copilot, the default AI agent, which relies on OpenAI as the underlying model provider. You can bring your own OpenAI API key to use with the Copilot without a standalone deployment. For enterprise deployments, we support connecting to your Azure OpenAI model, allowing firms to leverage their existing relationship with Azure/OpenAI.
When the default OpenBB Copilot isn't a perfect fit for your financial institution - especially when proprietary data and tools are involved - OpenBB Workspace offers the 'Bring Your Own AI Agent' feature. This allows you to integrate your own custom AI agents, which can be powered by Large Language Models (LLMs) from any vendor.
With this integration, you can use all of OpenBB's features while leveraging your firm's custom agent and preferred LLM provider. This enhances the efficiency of analysts and researchers by aligning with your unique data and models, all while keeping research queries and data securely within your firm's infrastructure.
Bring Your Own AI Agent
You can integrate your proprietary AI agent, powered by an LLM from any vendor, into OpenBB Workspace. Custom agents can be built using the OpenBB AI SDK, which provides comprehensive tools and helper functions for agent development.
Key Features
Custom AI agents in OpenBB Workspace can leverage several powerful features:
- Streaming Conversations: Real-time response streaming using Server-Sent Events (SSEs)
- Widget Data Access: Direct access to primary, secondary, and extra widgets in the workspace
- Reasoning Steps: Show intermediate thinking and processing steps to users
- Data Citations: Provide sources and references for information
- Chart Generation: Create interactive visualizations
- Table Production: Generate structured data tables
- PDF Data Handling: Process and extract information from PDF documents
Architecture Overview
Custom agents follow a stateless backend design with two essential endpoints:
- Query Endpoint (
/query
): The main interaction point that handles user queries and returns responses via Server-Sent Events - Agents Configuration Endpoint (
/agents.json
): Provides agent metadata and capabilities
Getting Started
To help you get started with custom agent development, we provide several open-source examples that demonstrate the communication protocol between agents and the workspace:
- Raw Widget Data Agent: Shows how to retrieve and process widget data
- Reasoning Steps Agent: Demonstrates showing intermediate processing steps
- Citation Agent: Examples of providing data sources and references
- Chart Agent: Creating visualizations from financial data
- Table Agent: Generating structured data tables
- PDF Agent: Processing PDF documents
The example code is available here.
Development Requirements
To build a custom agent, you'll need:
- Python with a web framework (FastAPI recommended)
- The OpenBB AI SDK (
openbb-ai
package) - An LLM provider of your choice (OpenAI, Anthropic, Azure, etc.)
- Proper endpoint configuration for SSE support
Agent Implementation Example
Here's a minimal example of a custom agent structure:
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
from openbb_ai import QueryRequest
app = FastAPI()
@app.get("/agents.json")
async def agents_json():
return {
"my-custom-agent": {
"name": "My Custom Financial Agent",
"description": "Specialized agent for financial analysis",
"image": "https://example.com/agent-logo.png",
"endpoints": {
"query": "/query"
},
"features": {
"streaming": True,
"widget-dashboard-select": True,
"widget-filter": True
}
}
}
@app.post("/query")
async def query(request: QueryRequest):
# Your agent logic here
# Access widgets, process data, generate responses
pass
Adding a Custom AI Agent to OpenBB Workspace
After deploying your custom AI agent, you can add it to OpenBB Workspace.
To do this, navigate to the "Add AI agent" section and follow the prompts:
- Click on the "Add AI agent" button.

- Enter the API endpoint of your custom AI agent.

- Confirm the addition.
- You are now ready to use your custom AI agent.
Best Practices
- Stateless Design: Keep your agent stateless to ensure scalability
- Error Handling: Implement robust error handling for API failures
- Response Streaming: Use SSE for real-time response delivery
- Widget Filtering: Respect user widget selections and filters
- Security: Implement proper authentication and authorization
- Performance: Optimize for low latency responses
Resources
For more detailed information about agent configuration, see the agents.json Reference documentation.