Dev.to AI ๐Ÿค– Ai ๐Ÿ‘ 0 ๐Ÿ“– 5 min read

Integrating LLM with Robotic Process Automation

Robotic Process Automation excels at repeating deterministic workflows, but classic RPA stalls when a workflow encounters unstructured language. Integrating a Large Language Model as a cognitive layer lets bots interpret

Robotic Process Automation excels at repeating deterministic workflows, but classic RPA stalls when a workflow encounters unstructured language. Integrating a Large Language Model as a cognitive layer lets bots interpret emails, classify documents, and decide branching logic. The challenge is not the prompt engineering. It is building a reliable inference backend that does not inflate costs when an invoice or contract fills the context window.

The Cognitive Layer: Moving Beyond Rule-Based Bots

Traditional RPA tools rely on explicit selectors, regular expressions, and rigid if-then trees. When a supplier changes an invoice format or a customer writes a request in idiomatic language, the bot breaks. An LLM can sit between the trigger and the execution layer to parse intent, extract entities, and select the correct downstream action.

For this to work in production, the model must support function calling so the RPA orchestrator receives machine-readable instructions rather than free text. Oxlo.ai offers function calling and tool use across its chat and reasoning models, including Llama 3.3 70B and Qwen 3 32B, and it exposes a fully OpenAI-compatible endpoint. That means you can keep your existing Python or Node.js SDK code and only change the base URL.

Architecture: Event-Driven RPA with LLM Tool Use

A typical integration looks like this. An RPA trigger, such as an email arrival, a file drop, or a scheduled job, collects raw context and posts it to the LLM endpoint. The LLM evaluates the context against a system prompt and a set of registered tools. If the model decides a tool is required, it returns a structured tool call. The RPA executor validates the arguments, performs the action, and optionally loops the result back to the LLM for a final confirmation message.

This pattern keeps the LLM stateless and the RPA platform in control of side effects. Oxlo.ai supports multi-turn conversations, so you can run this loop across several reasoning steps without managing conversation state on the inference provider.

Implementation: Classifying Support Tickets with Tool Calling

Below is a minimal example using the OpenAI Python SDK pointed at Oxlo.ai. The bot receives an unstructured support message and decides whether to create a ticket or escalate to a human.

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.oxlo.ai/v1",
    api_key=os.getenv("OXLO_API_KEY")
)

tools = [
    {
        "type": "function",
        "function": {
            "name": "create_ticket",
            "description": "Create a low-priority support ticket in the CRM",
            "parameters": {
                "type": "object",
                "properties": {
                    "customer": {"type": "string"},
                    "issue": {"type": "string"},
                    "priority": {"type": "string", "enum": ["low", "medium", "high"]}
                },
                "required": ["customer", "issue"]
            }
        }
    },
    {
        "type": "function",
        "function": {
            "name": "escalate_to_human",
            "description": "Hand off to a human agent immediately",
            "parameters": {
                "type": "object",
                "properties": {
                    "reason": {"type": "string"}
                },
                "required": ["reason"]
            }
        }
    }
]

response = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=[
        {"role": "system", "content": "You are an RPA routing agent. Use the available tools to process the request."},
        {"role": "user", "content": "The server in rack 4 keeps throwing 502 errors and the client is Acme Corp."}
    ],
    tools=tools,
    tool_choice="auto"
)

tool_calls = response.choices[0].message.tool_calls
print(tool_calls)

Because Oxlo.ai is a drop-in replacement for the OpenAI SDK, you can adopt the same patterns described in OpenAI function-calling guides without rewriting your orchestration logic. The platform also exposes chat/completions, embeddings, audio/transcriptions, and image/generations endpoints, so an RPA workflow that needs to transcribe a voicemail and then summarize it can stay inside the same API surface.

Cost Predictability for Long-Context Workloads

RPA bots often process lengthy inputs. A single mortgage document, legal contract, or thread of customer emails can consume thousands of tokens. Under token-based pricing, every extra paragraph increases the cost of the run. For high-volume automation, that variance makes budgeting impossible.

Oxlo.ai uses request-based pricing: one flat cost per API request regardless of prompt length. For long-context and agentic workloads, this can be significantly cheaper than token-based alternatives because the price does not scale with input size. You can see the current plans on the Oxlo.ai pricing page.

Selecting Models for RPA Tasks

Not every RPA step needs the same model. Oxlo.ai hosts more than 45 models across seven categories, which lets you match the model to the task instead of over-provisioning a single large endpoint.

  • Reasoning and routing: DeepSeek R1 671B MoE, Kimi K2.6, and GLM 5 handle complex decision trees and multi-step agentic reasoning.
  • Code generation and repair: Qwen 3 Coder 30B, DeepSeek Coder, and Oxlo.ai Coder Fast are useful when the bot must generate SQL, Python, or shell scripts on the fly.
  • Vision and document understanding: Gemma 3 27B and Kimi VL A3B can extract data from scanned PDFs or screenshots when OCR alone is insufficient.
  • Audio processing: Whisper Large v3 and Turbo variants transcribe call-center recordings or voicemails into text for downstream classification.
  • Retrieval and embeddings: BGE-Large and E5-Large power semantic search over internal knowledge bases before the LLM generates an answer.

This breadth lets you build a heterogeneous RPA pipeline where a lightweight model handles filtering and a heavy reasoning model handles exceptions, all behind one API key and one base URL.

Production Readiness: Streaming, JSON Mode, and No Cold Starts

RPA dashboards usually show execution logs in real time. Oxlo.ai supports streaming responses, so your orchestrator can emit partial outputs to a monitoring pane while the model is still generating. If you prefer structured output over tool calling, JSON mode constrains the response to valid JSON that your RPA engine can parse directly.

response = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=[
        {"role": "system", "content": "Extract invoice_date, total, and vendor as JSON."},
        {"role": "user", "content": "..."}
    ],
    response_format={"type": "json_object"}
)

In addition, Oxlo.ai advertises no cold starts on popular models. For RPA, that matters because a scheduled job that fires at midnight should not wait twenty seconds for a GPU to spin up. Consistent latency keeps SLAs predictable.

Conclusion

Integrating an LLM into RPA is not about replacing the robot. It is about giving the robot judgment for the edge cases that rules cannot cover. The integration succeeds when the inference layer is compatible, cost-predictable, and fast enough to fit inside an automated workflow.

Oxlo.ai fits this stack naturally. Its OpenAI-compatible SDK, request-based pricing, and broad model catalog remove the infrastructure friction that usually slows down RPA experiments. If you are already prototyping with the OpenAI SDK, switching the base URL to https://api.oxlo.ai/v1 is the fastest way to test whether flat-rate inference improves your automation economics.

๐Ÿ“ฐ Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.