Overview
Create sophisticated AI agents using OpenAI’s Assistants API. Build agents with code interpretation, file search, and custom function calling capabilities.Prerequisites
OpenAI Account
Sign up at platform.openai.com
API Key
Generate API key with Assistants access
Assistant Created
Build assistant via OpenAI Playground or API
AgentFlow Admin
Admin access required
Step 1: Create OpenAI Assistant
Using OpenAI Playground
1
Access Playground
- Go to platform.openai.com/playground
- Select Assistants mode
2
Configure Assistant
- Name:
Research & Analysis Agent - Model:
gpt-4-turbo - Instructions:
3
Enable Tools
- ✅ Code Interpreter: For data analysis and calculations
- ✅ File Search: For document analysis
- ✅ Functions: For custom integrations
4
Add Functions
Define custom functions:
5
Save Assistant
Click Save and copy the Assistant ID
Using OpenAI API
Create programmatically:Step 2: Create AI Connection in AgentFlow
Manual Setup
- Admin Dashboard → AI Models → Add Model
-
Configuration:
- Name:
OpenAI Research Assistant - Model ID:
openai-agent-builder - Description:
Research agent with code interpretation and file search
- Name:
-
API Settings:
- Endpoint:
https://api.openai.com/v1/assistants/{{assistant_id}}/runs - Method: POST
- Endpoint:
-
Headers:
-
Request Schema:
-
Response Path:
data.run_result - Save
Step 3: Import via YAML
YAML Configuration
Createopenai-agent-builder-config.yaml:
Import Process
- Update
assistant_idwith your actual ID - Admin Dashboard → AI Models → Import Model
- Upload YAML
- Enter OpenAI API key
- Import
Step 4: Assign to Group
- Admin Dashboard → Groups
- Select group (e.g., “Analytics Team”)
- Manage Models → Enable OpenAI Assistant
- Configure:
- Code Interpreter: Enabled
- File Upload: 20 files max
- Custom Functions: Enabled
- Max Tokens: 4000
- Save
Step 5: Use in Chat
Interacting with Assistant
- Chat → New Conversation
- Select OpenAI Research Assistant
- Start conversation
Example Interactions
Tool Capabilities
Code Interpreter
Execute Python code for analysis:File Search
Upload and analyze documents:1
Upload Files
Via API or Playground:
2
Query Documents
Ask questions about uploaded files:
3
Get Citations
Assistant provides source references:
Function Calling
Integrate with external systems:1
Define Function
2
Handle Function Calls
Advanced Configuration
Thread Management
Manage conversation threads:Streaming Responses
Enable real-time streaming:Custom Instructions
Dynamic instruction override:Use Cases
1. Data Analysis Agent
2. Document Research Agent
3. Customer Support Agent
Monitoring & Debugging
Run Status Tracking
Monitor assistant execution:Error Handling
Handle common errors:Usage Tracking
Monitor token usage:Troubleshooting
Assistant Not Responding
Assistant Not Responding
Check:
- Assistant is not deleted
- API key has Assistants beta access
- Thread ID is valid
- No rate limits hit
Function Not Called
Function Not Called
Check:
- Function definition is correct
- Description is clear
- Parameters match expected format
File Search Not Working
File Search Not Working
Check:
- Files are uploaded successfully
- File IDs are attached to assistant
- Supported file types (PDF, TXT, DOCX)
Code Execution Failed
Code Execution Failed
Cause: Invalid Python code or timeoutFix:
- Validate code syntax
- Reduce computation complexity
- Check for infinite loops
Cost Management
Pricing Structure
| Component | Cost |
|---|---|
| GPT-4-turbo | 0.03/1K output |
| Code Interpreter | $0.03/session |
| File Search | $0.10/GB/day |
| Storage | $0.20/GB/month |
Optimization Tips
Model Selection
Use GPT-3.5-turbo for simple tasks
File Management
Delete unused files regularly
Thread Cleanup
Archive old threads
Token Limits
Set max_tokens appropriately
Best Practices
- Clear Instructions: Be specific about assistant behavior
- Tool Selection: Only enable necessary tools
- Error Handling: Implement robust error handling
- Testing: Test with various inputs before deployment
- Monitoring: Track usage and costs regularly
- Security: Validate all function inputs/outputs