Skip to main content

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

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

  1. Go to platform.openai.com/playground
  2. 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

  1. Admin DashboardAI ModelsAdd Model
  2. Configuration:
    • Name: OpenAI Research Assistant
    • Model ID: openai-agent-builder
    • Description: Research agent with code interpretation and file search
  3. API Settings:
    • Endpoint: https://api.openai.com/v1/assistants/{{assistant_id}}/runs
    • Method: POST
  4. Headers:
  5. Request Schema:
  6. Response Path: data.run_result
  7. Save

Step 3: Import via YAML

YAML Configuration

Create openai-agent-builder-config.yaml:

Import Process

  1. Update assistant_id with your actual ID
  2. Admin DashboardAI ModelsImport Model
  3. Upload YAML
  4. Enter OpenAI API key
  5. Import

Step 4: Assign to Group

  1. Admin DashboardGroups
  2. Select group (e.g., “Analytics Team”)
  3. Manage Models → Enable OpenAI Assistant
  4. Configure:
    • Code Interpreter: Enabled
    • File Upload: 20 files max
    • Custom Functions: Enabled
    • Max Tokens: 4000
  5. Save

Step 5: Use in Chat

Interacting with Assistant

  1. ChatNew Conversation
  2. Select OpenAI Research Assistant
  3. Start conversation

Example Interactions


Tool Capabilities

Code Interpreter

Execute Python code for analysis:
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

Check:
  • Assistant is not deleted
  • API key has Assistants beta access
  • Thread ID is valid
  • No rate limits hit
Fix: Recreate assistant or thread
Check:
  • Function definition is correct
  • Description is clear
  • Parameters match expected format
Fix: Improve function description
Check:
  • Files are uploaded successfully
  • File IDs are attached to assistant
  • Supported file types (PDF, TXT, DOCX)
Fix: Verify file upload and attachment
Cause: Invalid Python code or timeoutFix:
  • Validate code syntax
  • Reduce computation complexity
  • Check for infinite loops

Cost Management

Pricing Structure

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

  1. Clear Instructions: Be specific about assistant behavior
  2. Tool Selection: Only enable necessary tools
  3. Error Handling: Implement robust error handling
  4. Testing: Test with various inputs before deployment
  5. Monitoring: Track usage and costs regularly
  6. Security: Validate all function inputs/outputs

Next Steps

LangChain Agents

Alternative agent framework

Cloud Functions

Custom serverless logic

Workflow Automation

Combine with Make.com

Analytics

Monitor assistant performance