OpenAI
Using Recall with OpenAI's API and tools
This guide shows you how to integrate the Recall Agent Toolkit with OpenAI's APIs to build agents with persistent memory and storage capabilities.
Overview
The OpenAI integration for Recall Agent Toolkit allows you to:
- Create agents using OpenAI models (GPT-3.5, GPT-4, etc.)
- Enable function calling for persistent memory management
- Store and retrieve information between sessions
- Build agents that can learn from past interactions
- Deploy agents as part of your OpenAI-powered applications
Installation
Basic integration
The simplest way to integrate Recall with OpenAI is using the RecallAgentToolkit
for OpenAI:
This basic example demonstrates how to set up the OpenAI integration and enable function calling for Recall operations.
Conversation management
For multi-turn conversations with memory, you'll need to maintain the conversation state:
OpenAI assistants API integration
You can also integrate Recall with OpenAI's Assistants API:
Advanced usage
Streaming responses
You can use streaming responses with Recall for more responsive applications:
Function calling patterns
Here are some effective patterns for controlling function calling behavior:
Integration with Express
Here's how to build a simple API with Express that uses Recall and OpenAI:
Best practices
When integrating Recall with OpenAI, follow these best practices:
- Structured data storage: Always store data in a structured format (like JSON) to make retrieval and processing easier
- Optimized prompting: Be specific in your system instructions about when and how to use Recall
- Error handling: Implement robust error handling for both API calls and function execution
- Conversation management: Keep track of messages and function calls in a way that maintains context
- Token optimization: Be mindful of token usage, especially with longer conversations
- Secure credentials: Never expose your private keys or API keys in client-side code
- Logging: Implement proper logging for API calls and tool usage to debug issues and track performance
Troubleshooting
Here are some common issues and their solutions:
Issue | Cause | Solution |
---|---|---|
"Function execution failed" | Invalid parameters or permissions | Check function parameters and toolkit configuration |
Timeout errors | Network issues or slow operations | Implement retries or longer timeouts |
"Unknown function" errors | Function not properly registered | Ensure toolkit is initialized correctly |
"Unable to parse arguments" | Malformed JSON in function arguments | Validate function arguments format |
Empty responses | Token limit exceeded | Reduce conversation history or use a more concise format |
Next steps
- Explore the core concepts to better understand Recall's capabilities
- Check the tools reference for detailed documentation on available tools
- Learn about bucket monitoring to track your agent's activity
- See the MCP integration guide for a different approach to agent development