AI Model Integrations
Relevant source files
The following files were used as context for generating this wiki page:
AI Model Integrations form the core intelligence layer of the Recoup API, providing strategic assistance for the music industry. The system integrates multiple Large Language Model (LLM) providers, including Anthropic, Google, OpenAI, and Perplexity, to handle tasks ranging from fan data analysis and marketing optimization to deep web research.
The architecture is built on a "Sandbox-First" approach, where the AI agent (Recoup) primarily utilizes a persistent environment for complex, multi-step tasks like release management and content generation, while delegating specific capabilities like search or scraping to specialized tools and models.
Sources: lib/chat/const.ts:3-12, package.json:34-40
Multi-Provider Architecture
The project leverages a diverse stack of AI SDKs and providers to ensure high performance and specialized capabilities for different domains.
Integrated Providers and SDKs
The system uses the Vercel AI SDK as a unified interface to interact with various models. Key dependencies include:
- Anthropic: Used for high-reasoning tasks.
- Google Gemini: Integrated for specific tool-chain steps, specifically using
gemini-2.5-pro. - OpenAI: Standard provider for general completions and potentially image/video generation.
- Perplexity: Utilized specifically for deep web research and grounding AI responses in real-time data.
- Model Context Protocol (MCP): Used to integrate external tools and services into the LLM context.
Sources: package.json:34-40, lib/chat/toolChains/toolChains.ts:133-136
Model Mapping and Selection
The system dynamically selects models based on the specific tool being invoked or the complexity of the request.
| Tool / Use Case | Default Model | Provider |
|---|---|---|
| General Chat | DEFAULT_MODEL | Defined in constants |
| Deep Research | sonar-deep-research | Perplexity |
| Account Updates | gemini-2.5-pro | |
| Standard Search | sonar-pro | Perplexity |
| Sources: lib/perplexity/chatWithPerplexity.ts:25-50, lib/chat/toolChains/toolChains.ts:133-136, lib/evals/scorers/CatalogAvailability.ts:1-5 |
Deep Research and Perplexity Integration
A significant component of the AI integration is the "Deep Research" capability powered by Perplexity AI. This allows the assistant to perform exhaustive web searches and return cited information.
The following sequence diagram illustrates the flow of a deep research request:
The integration handles API communication, error states, and formatted output generation, ensuring that every research finding is tied to a specific source URL.
Sources: lib/perplexity/chatWithPerplexity.ts:13-75, lib/mcp/tools/tests/registerWebDeepResearchTool.test.ts:45-75
Tool Chains and Step Execution
The system implements "Tool Chains" which are predefined sequences of AI actions required to complete complex workflows.
Tool Chain Structure
A ToolChainItem defines a specific step in a process, allowing for custom system prompts and message overrides for that specific model call.
Sources: lib/chat/toolChains/toolChains.ts:7-15
Example: Artist Creation Chain
The create_new_artist chain involves over 10 steps, including:
- get_spotify_search: Finding the artist on music platforms.
- update_account_info: Using
gemini-2.5-proto process data. - generate_txt_file: Creating knowledge base reports.
- youtube_login: Finalizing integration steps.
Sources: lib/chat/toolChains/toolChains.ts:125-132, lib/chat/toolChains/tests/toolChains.test.ts:75-110
System Prompting and Personality
The "Recoup" AI personality is defined through a comprehensive system prompt that establishes its role as a strategic music industry advisor.
Core Persona Characteristics
- Strategic: Focuses on fan data, marketing funnels, and monetization.
- Proactive: Surfaces trends and opportunities without waiting for user prompts.
- Industry-Specific: Tailors advice based on genre and career stage (e.g., underground rapper vs. legacy pop act).
- Action-Oriented: Instructed to continue until a task is accomplished without asking for permission.
Sources: lib/chat/const.ts:3-32
Context Assembly
Before a model is called, the setupChatRequest function assembles a rich context including:
- Account Details: Professional context of the user.
- Artist/Workspace Context: Specific instructions or knowledge base text related to an artist.
- Knowledge Base: Text extracted from uploaded files (CSV, Markdown, JSON).
- Tool Availability: Logic to exclude specific tools if requested.
Sources: lib/chat/setupChatRequest.ts:10-50, lib/chat/tests/integration/chatEndToEnd.test.ts:250-290
Conclusion
The AI Model Integration system in the Recoup API is a sophisticated orchestration layer that balances general-purpose LLM capabilities with specialized tools and domain-specific logic. By utilizing a multi-model approach—ranging from Google's Gemini for structured updates to Perplexity for real-time research—the system provides a robust framework for music industry analysis and artist management.