---
title: "Connect Lirium to AI Agents: Orchestrate Fiat and Trading Workflows"
slug: connect-lirium-to-ai-agents-orchestrate-fiat-and-trading-workflows
date: 2026-06-19
author: Uday Gajavalli
categories: ["AI & Agents"]
excerpt: "Learn how to connect Lirium to AI Agents using Truto's /tools endpoint. Build autonomous fiat, crypto trading, and compliance workflows without custom API code."
tldr: "A technical guide to connecting Lirium to AI Agents. Discover how to bypass complex Lirium API auth, handle two-step trading workflows, and bind Truto's Lirium tools directly to frameworks like LangChain and Vercel AI SDK."
canonical: https://truto.one/blog/connect-lirium-to-ai-agents-orchestrate-fiat-and-trading-workflows/
---

# Connect Lirium to AI Agents: Orchestrate Fiat and Trading Workflows


You want to connect Lirium to your AI agents so your system can autonomously handle customer onboarding, route fiat transactions, execute crypto orders, and manage compliance documents. Here is exactly how to do it using Truto's `/tools` endpoint and SDK, bypassing the need to build and maintain a custom REST API integration layer.

Giving a Large Language Model (LLM) read and write access to a specialized cryptocurrency and fiat infrastructure platform is an engineering headache. You either spend months building, testing, and securing a custom API connector, or you use a [managed infrastructure layer](https://truto.one/zero-data-retention-for-ai-agents-why-pass-through-architecture-wins/) that automatically translates complex vendor APIs into LLM-ready functions. If your team uses ChatGPT, check out our guide on [connecting Lirium to ChatGPT](https://truto.one/connect-lirium-to-chatgpt-manage-crypto-customer-kyc-and-orders/), or if you prefer Anthropic's ecosystem, read about [connecting Lirium to Claude](https://truto.one/connect-lirium-to-claude-monitor-rates-investments-and-balances/). For developers building custom autonomous workflows across any LLM framework, you need a programmatic way to fetch these tools and bind them directly to your agent.

This guide breaks down exactly how to fetch AI-ready tools for Lirium, bind them natively to an LLM using your preferred framework (LangChain, LangGraph, CrewAI, Vercel AI SDK), and execute complex trading operations. For a deeper look at the architectural approach behind this methodology, refer to our research on [architecting AI agents and the SaaS integration bottleneck](https://truto.one/architecting-ai-agents-langgraph-langchain-and-the-saas-integration-bottleneck/).

## The Engineering Reality of Custom Lirium Connectors

Building an AI agent is relatively straightforward today. Connecting that agent to external FinTech APIs is hard. Giving an LLM access to external trading data sounds simple in a Jupyter Notebook prototype - you write a fetch request, wrap it in a tool decorator, and move on. In production, this approach collapses entirely under the weight of vendor-specific API constraints.

If you decide to build a custom Lirium AI Agents integration, you are responsible for the entire API lifecycle. Lirium's API is built for high-stakes financial transactions, introducing several very specific integration challenges that break standard LLM assumptions.

### Two-Step Order Execution and Partner Authorizations
Most modern LLMs assume a standard CRUD architecture where a `POST` request to create an entity is the end of the transaction. In Lirium, order creation is frequently a two-step - or even three-step - process. An agent cannot simply "buy Bitcoin". It must first call `create_a_lirium_customer_order`. Depending on the account structure, this order goes into a pending state and requires an explicit call to `create_a_lirium_order_confirm`. 

Furthermore, if your platform operates with partner-level guardrails, the order might trigger an authorization flow requiring an administrator to call `update_a_lirium_order_authorization_by_id`. Hand-coding these sequence dependencies into agent prompts requires massive context windows and brittle retry logic. Truto standardizes these endpoints into discrete, highly descriptive tools that explicitly guide the LLM through the correct sequence of operations.

### Regional Fiat Routing Complexities
When dealing with fiat deposits and withdrawals, the Lirium API does not accept a generic "bank account" string. The API strictly enforces regional routing formats. If an agent is attempting to create a partner withdrawal order via `create_a_lirium_partner_order`, it must supply a specific transfer destination sub-object matching the currency and region - such as `ar_cvu` for Argentina, `ar_cbu`, `ar_alias`, or an `address_book_item` reference. 

If the LLM hallucinates the schema and tries to pass an IBAN into an `ar_cvu` object, the API will fail. Maintaining massive JSON schemas to catch these edge cases takes weeks of engineering. Truto's proxy layer normalizes the upstream schema and provides the LLM with exact parameter requirements, ensuring the payload is correctly formatted before the network request is ever dispatched.

### Multipart KYC Document Uploads
Financial integrations require Know Your Customer (KYC) documentation. Lirium's `create_a_lirium_customer_document` endpoint requires the developer to handle `multipart/form-data` uploads while matching the exact `document_type` to the customer's pending `data_requirements`. Most LLM frameworks struggle natively with multipart binary data orchestration. An agent needs a tool that abstracts the file handling complexity away, allowing it to simply reference a file path or URL and specify the required document type string.

## Essential Lirium Tools for AI Agents

Instead of writing custom API wrappers, you can generate AI-ready tools dynamically via Truto's `/tools` endpoint. Here are six high-leverage hero tools you can use to orchestrate complex Lirium workflows immediately.

### 1. Create a Lirium Customer (`create_a_lirium_customer`)
This tool handles the genesis of the user lifecycle. It creates a new individual or business account in Lirium. Crucially, it returns the newly created customer's `data_requirements`, which the AI agent can read to determine exactly which KYC documents need to be requested from the user next.

> "A new user, Alice Smith (reference ID: AS-9942), wants to sign up for a trading account. Create an individual Lirium customer profile with her email alice@example.com, then tell me exactly which KYC documents Lirium says we need to collect from her."

### 2. Generate Incoming Fiat Instructions (`create_a_lirium_customer_incoming_fiat_instruction`)
Before a user can trade, they need to fund their account. This tool generates the deposit instructions (like an AR CVU or MX CLABE) specific to the customer and currency. The agent can use this tool to autonomously provision funding routes and surface the deposit details back to the user interface.

> "Customer ID 883-XYZ wants to deposit Mexican Pesos. Generate a new incoming fiat instruction for MXN and return the CLABE number they need to send funds to."

### 3. Create a Customer Order (`create_a_lirium_customer_order`)
This is the core trading tool. It allows the agent to initiate a buy, sell, send, or swap operation. The tool requires the LLM to specify the asset, the amount, and the operation type. Because this is often step one of a two-step process, the agent uses the returned order ID to proceed to confirmation.

> "Execute a market buy order for $500 USD worth of BTC for customer ID 883-XYZ. Return the pending order ID so I can log it before we confirm."

### 4. Confirm a Lirium Order (`create_a_lirium_order_confirm`)
Once an order is created and the user (or internal logic) agrees to the execution price and fees returned by the API, this tool commits the transaction. It changes the order state from pending to confirmed.

> "The user approved the fee structure for order ID ORD-7762. Confirm the pending Lirium order for customer ID 883-XYZ and report back the final execution state."

### 5. List Customer Investments (`list_all_lirium_customer_investments`)
Lirium supports yield-generating investment products. This tool allows the agent to audit a specific customer's investment portfolio, retrieving their invested amount, quote asset, Profit and Loss (PnL), PnL percentage, and net fee details.

> "Pull the current investment portfolio for customer ID 883-XYZ. Calculate their total PnL across all active investments and summarize their highest-performing asset."

### 6. Manage Partner Authorizations (`list_all_lirium_partner_authorizations`)
For internal treasury agents, this tool is critical. It lists all orders that require partner-level authorization. An internal compliance bot can run on a cron job, use this tool to fetch pending authorizations, cross-reference the transaction with an internal risk database, and alert the treasury team.

> "Fetch all Lirium orders currently sitting in a 'pending' authorization state. Format the list in a table showing the customer ID, operation type, currency, and amount."

View the complete tool inventory and schema details on the [Lirium integration page](https://truto.one/integrations/detail/lirium).

## Building Multi-Step Workflows

To connect Lirium to AI Agents in a production environment, you need an orchestration layer that handles tool retrieval, schema binding, and error management. This is the foundation of [LLM function calling for integrations](https://truto.one/what-is-llm-function-calling-for-integrations-2026-guide/). Frameworks like LangGraph or the Vercel AI SDK are excellent at managing the agent's memory and reasoning loop, but they rely on you to provide the tools.

Using the Truto SDK, you can dynamically fetch the Lirium tools defined on your integrated account and bind them to your model. 

### Framework-Agnostic Tool Binding
Here is an example of how you fetch Lirium tools and bind them to an LLM using the `TrutoToolManager` from the `truto-langchainjs-toolset`. This exact pattern applies whether you are using LangChain, CrewAI, or direct function calling via OpenAI's SDK.

```typescript
import { ChatOpenAI } from "@langchain/openai";
import { TrutoToolManager } from "truto-langchainjs-toolset";
import { AgentExecutor, createOpenAIToolsAgent } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";

// 1. Initialize the LLM
const llm = new ChatOpenAI({
  modelName: "gpt-4o",
  temperature: 0,
});

// 2. Initialize the Truto Tool Manager for the Lirium integration
const toolManager = new TrutoToolManager({
  trutoApiKey: process.env.TRUTO_API_KEY,
  integratedAccountId: process.env.LIRIUM_ACCOUNT_ID,
});

async function runTradingAgent() {
  // 3. Fetch Lirium tools directly from Truto
  const liriumTools = await toolManager.getTools();

  // 4. Bind the tools to the LLM
  const llmWithTools = llm.bindTools(liriumTools);

  // 5. Define the Agent Prompt
  const prompt = ChatPromptTemplate.fromMessages([
    ["system", "You are a financial operations agent. You manage Lirium customer accounts, fiat routing, and order execution. Always double-check IDs before executing confirmations."],
    ["human", "{input}"],
    ["placeholder", "{agent_scratchpad}"],
  ]);

  // 6. Create and execute the agent loop
  const agent = await createOpenAIToolsAgent({
    llm: llmWithTools,
    tools: liriumTools,
    prompt,
  });

  const executor = new AgentExecutor({
    agent,
    tools: liriumTools,
  });

  const result = await executor.invoke({
    input: "Customer ID CUST-992 wants to execute a market buy for 0.05 BTC using USD. Create the order and then immediately confirm it."
  });

  console.log(result.output);
}

runTradingAgent();
```

### Handling API Rate Limits
When building autonomous agents, rate limits are the silent killer of workflows. An agent acting in a loop can fire dozens of requests per second, quickly exhausting upstream quotas.

It is vital to understand that **Truto does not automatically retry, throttle, or apply backoff on rate limit errors.** When the upstream Lirium API returns an HTTP 429 Too Many Requests error, Truto proxies that exact error back to the caller. However, Truto does normalize the upstream rate limit information into standard IETF headers (`ratelimit-limit`, `ratelimit-remaining`, `ratelimit-reset`). 

Your agent framework is responsible for handling the retry and backoff logic. When your code receives a 429, it must parse the `ratelimit-reset` header, pause the agent's execution thread, and retry the tool call once the window resets. Failing to implement this at the caller level will cause the LLM to hallucinate successful transactions or crash the execution loop entirely.

```mermaid
flowchart TD
    A["Agent Core<br>(LLM Framework)"]
    B["Truto Tool Manager<br>(Lirium Schema)"]
    A -->|"Select Tool & Args"| B
    B -->|"Dispatch HTTP Request"| C["Lirium API<br>(via Truto Proxy)"]
    C -->|"Return 200 OK"| A
    C -->|"HTTP 429 Error"| D["Read Headers<br>(ratelimit-reset)"]
    D -->|"Wait & Retry Loop"| B
```

## Workflows in Action

Connecting a Lirium API AI agent unlocks massive operational leverage. Let's look at two concrete examples of how specific personas use these multi-step workflows in production.

### Scenario 1: The Autonomous Onboarding & Funding Bot
**Persona:** Product Manager / Onboarding Operations

A FinTech platform wants an autonomous bot to handle users who have passed basic identity checks but haven't funded their accounts. The bot monitors the database and reaches out to users via an in-app chat interface to orchestrate the funding process.

> **Prompt:** "User 551-ABC just requested to deposit funds in Argentine Pesos (ARS). Generate their incoming fiat instructions, extract the CVU, and format a message to send to the user explaining how to transfer their funds."

**Agent Execution Steps:**
1. The agent calls `create_a_lirium_customer_incoming_fiat_instruction`, passing the `customer_id` and specifying `currency: ARS`.
2. The Truto proxy standardizes the payload and executes the request against Lirium.
3. The agent receives the response containing the `ar_cvu` sub-object.
4. The agent parses the CVU string and generates natural language output for the front-end chat interface.

**Outcome:** The user receives a completely automated, perfectly formatted set of bank instructions specific to their Lirium sub-account, without a human support rep ever touching the ticket.

### Scenario 2: Treasury Operations and Partner Withdrawals
**Persona:** Treasury Manager / Finance Ops

A treasury team needs to extract fiat revenue from their Lirium settlement account to their corporate outside bank. Instead of logging into a dashboard, they command their internal Slack bot.

> **Prompt:** "Check our current partner balances. If our available EUR balance is above €50,000, create a partner withdrawal order to move €10,000 to our whitelisted corporate bank account. Use reference ID TX-WEEKLY-09."

**Agent Execution Steps:**
1. The agent calls `list_all_lirium_partner_balances` to check liquidity.
2. The agent interprets the JSON response, specifically looking at the `available_amount` for EUR.
3. Recognizing the balance exceeds the threshold, the agent calls `list_all_lirium_partner_withdrawal_destinations` to find the correct whitelisted bank ID.
4. The agent formulates a payload and calls `create_a_lirium_partner_order`, specifying the operation as `withdrawal` and embedding the correct transfer-destination sub-object.

**Outcome:** The agent executes complex financial logic based on live API state, initiating a high-value treasury movement with strict adherence to the company's reference ID naming conventions.

## Strategic Wrap-Up

If you want to connect Lirium to AI Agents, writing custom integration code is a losing battle against API maintenance, auth lifecycles, and schema drift. Truto's `/tools` endpoint transforms the Lirium API into a standardized, AI-native surface area. By binding these dynamically generated tools directly to LangChain, CrewAI, or your custom agent router, you can ship complex trading and compliance workflows in hours instead of quarters.

> Stop wasting engineering cycles on custom API wrappers. Get instant, AI-ready Lirium tools with Truto and focus on building your core agent logic.
>
> [Talk to us](https://cal.com/truto/partner-with-truto)
