Introduction
This guide shows you how to create custom agent backends by defining ExuluAgent classes in code. Youâll learn about the agent structure, configuration options, provider setup, and how to integrate your custom agents into the Exulu IMP.Prerequisites
Before you begin, ensure you have:- A working Exulu IMP development environment (see Getting Started)
- TypeScript and Node.js knowledge
- An API key for your chosen LLM provider
- The example repository cloned locally
Understanding Backends vs Agent Instances
An important concept to understand: Backend (ExuluAgent class): The code-level definition of a language model + provider combination. This is what you create in TypeScript. Agent Instance: A UI-level configuration that uses a backend. Multiple agent instances can share the same backend with different system instructions, tools, and settings. Example: You might create oneClaude Sonnet 4.5 backend in code, then create multiple agent instances in the UI like âCustomer Service Agentâ, âFinancial Analysis Agentâ, and âCoding Assistantâ - all using the same backend but with different configurations.
Project Structure
Thereâs no required structure for organizing your agents, but we recommend this pattern:Step 1: Create an Agent File
Navigate to your agents folder and create a new TypeScript file for your agent:Step 2: Define the ExuluAgent Class
Open your new file and create an ExuluAgent instance. Hereâs a complete example:Understanding the Properties
id (Required, Immutable)
A unique string identifier for your agent backend.
Important: This ID is stored in the database and must never change after creation. Use descriptive names with underscores.
name (Required, Mutable)
The display name shown in the UI. This can be changed anytime without breaking anything.
provider (Required)
The name of the LLM provider.
description (Optional)
A brief description of what the agent does or what itâs optimized for.
type (Required)
The agent type. Currently supports:
'agent': Standard conversational agent'flow': Workflow agent (covered in another guide)
capabilities (Optional)
Defines which file types and modalities the model supports. This ensures only compatible files are sent to the agent.
config.model (Required)
A factory function that receives an API key and returns a configured language model instance.
Step 3: Understanding the AI SDK
Exulu uses the Vercel AI SDK under the hood, which provides a unified interface for multiple LLM providers.Supported Providers
The AI SDK supports many providers out of the box. Here are some popular ones: Major Providers- OpenAI
- Anthropic
- Google (Generative AI & Vertex AI)
- Azure OpenAI
- Amazon Bedrock
- Groq
- Together AI
- Mistral
- Cohere
- Fireworks
- DeepSeek
- Cerebras
- Perplexity
- Ollama
- VLLM
- Any OpenAI-compatible endpoint
Switching Providers
You can easily switch providers by changing the import and model configuration: OpenAI ExampleStep 4: Custom Instructions (Three Layers)
Exulu supports three layers of custom instructions, allowing flexibility at different levels:Layer 1: Code-Level Instructions (Global)
Defined in the agent class and applied to all instances of this backend.Layer 2: Agent Instance Instructions (Admin-Configured)
Set in the UI when creating an agent instance. Admins can add specific instructions for each agent instance.Layer 3: User Session Instructions (User-Configured)
Individual users can add their own instructions for their sessions with the agent. Instruction Priority: Layer 3 (User) > Layer 2 (Instance) > Layer 1 (Code) All layers are combined when the agent processes a request.Step 5: Export Your Agent
Add your agent to theagents/index.ts file:
Step 6: Add to ExuluApp
Import and register your agents in your main ExuluApp configuration:Step 7: Create an Agent Instance in the UI
Now that your backend is registered, create an agent instance through the UI:- Navigate to
http://localhost:3000and log in - Go to Agents in the sidebar
- Click Create New Agent
- Select your backend from the dropdown (e.g., âClaude Sonnet 4.5â)
- Give it a name (e.g., âFinancial Analysis Agentâ)
- Add a description
- Set a category
- Configure an API key (see next section)
- Toggle Active to ON
- Click Save
Step 8: Configure the API Key
Before your agent can make API calls, you need to add an encrypted API key:- Navigate to Variables in the sidebar
- Click Add Variable
- Enter a name (e.g.,
ANTHROPIC_API_KEY) - Paste your API key
- Enable âEncrypt this variableâ (required for security)
- Click Save
Step 9: Test Your Agent
Test your newly created agent:- Navigate to Chat in the sidebar
- Click Start New Session
- Select your agent from the dropdown
- Send a test message
- You should see a streaming response from your agent
Your custom agent backend is now live and working!
Advanced Configuration
Multiple Agents with Same Backend
You can create multiple agent instances using the same backend:Model-Specific Settings
Some providers support additional configuration:TypeScript Autocomplete
The ExuluAgent class is fully typed. Use your IDEâs autocomplete to explore available options:Next Steps
Now that you have a custom agent backend, enhance it further:Add Tools
Give your agent capabilities beyond conversation. See the ExuluTool guidesAdd Context
Provide domain-specific knowledge through vector databases. See the ExuluContext guidesCreate Workflows
Build automated workflows using your agents. See the ExuluApp guidesAPI Integration
Interact with your agents programmatically via GraphQL. See the API ReferenceTroubleshooting
âAgent backend not showing in UIâ
Make sure you have added the agent to the ExuluApp agents array and restarted the development server. Check the server logs for any errors during startup.âModule not foundâ errors
Ensure you have installed the required AI SDK provider package:âInvalid API keyâ errors
Verify that the API key variable is encrypted and contains a valid key. Check that you have selected the correct variable in the agent configuration.TypeScript errors
Make sure you have the latest version of the Exulu backend package and that yourtsconfig.json is properly configured.
Agent responds but output is incorrect
Check the custom instructions at all three layers. They might be conflicting or poorly defined. Review the modelâs capabilities to ensure youâre not requesting unsupported features.Best Practices
Naming Conventions
For agent IDs:- Use underscores, not hyphens
- Include the model version
- Be descriptive
- Never change after creation
- User-friendly and clear
- Include provider and model info
- Can be changed anytime
API Key Management
Separate keys for development and production. Use different variables for different environments. Monitor usage and costs. Set up billing alerts with your provider. Rotate keys periodically. Update the encrypted variables in the system.Code Organization
One agent per file. Makes it easier to maintain and test. Group related agents. For example, all Anthropic models in one folder. Document your agents. Add comments explaining the use case and configuration.Testing
Test locally first. Verify the agent works in development before deploying. Use test API keys. Many providers offer test keys with limited quotas. Check capabilities. Ensure file type restrictions match the modelâs actual capabilities.Summary
Youâve learned how to create custom agent backends in code by defining ExuluAgent classes. You now understand:- The difference between backends and agent instances
- How to structure your agent code
- All ExuluAgent configuration options
- How to use the AI SDK with multiple providers
- The three layers of custom instructions
- How to register agents with ExuluApp
- How to create agent instances in the UI
- Best practices for agent development