DEV Community

shashank ms
shashank ms

Posted on

Integrating LLMs with Existing ERP Systems

Enterprise Resource Planning systems remain the backbone of business operations, but their rigid schemas and proprietary interfaces create friction for modern AI workflows. Large Language Models can bridge this gap by translating natural language into structured ERP queries, extracting insights from lengthy financial reports, and orchestrating multi-step business processes through agentic tool use. The challenge is not whether to integrate, but how to do so without ballooning inference costs or rewriting your entire stack.

Integration Patterns for LLMs and ERP

Most ERP integrations follow one of three patterns. The first is structured translation, where an LLM converts natural language into SQL, OData, or ERP-specific API calls. The second is document intelligence, where models extract entities from scanned invoices, purchase orders, or compliance PDFs. The third is agentic orchestration, where the model plans and executes multi-step workflows across modules such as inventory, HR, and finance.

All three patterns benefit from function calling. Instead of fine-tuning a model on your ERP schema, you describe available tools in the system prompt and let the model decide which endpoint to invoke. This keeps the integration layer thin and your ERP credentials isolated behind your own API gateway.

Code Example: ERP Assistant with Function Calling

The following Python example uses the OpenAI SDK pointed at Oxlo.ai. It defines a mock inventory tool and lets the model decide when to call it.

import openai
import json

client = openai.OpenAI(
    base_url="https://api.oxlo.ai/v1",
    api_key="YOUR_OXLO_API_KEY"
)

tools = [
    {
        "type": "function",
        "function": {
            "name": "query_inventory",
            "description": "Query current inventory levels by SKU",
            "parameters": {
                "type": "object",
                "properties": {
                    "sku": {"type": "string"},
                    "warehouse_id": {"type": "string"}
                },
                "required": ["sku"]
            }
        }
    }
]

def run_erp_assistant(user_query: str):
    response = client.chat.completions.create(
        model="llama-3.3-70b",  # use the exact model ID from the Oxlo.ai catalog
        messages=[
            {"role": "system", "content": "You are an ERP assistant. Use the available tools to answer inventory questions."},
            {"role": "user", "content": user_query}
        ],
        tools=tools,
        tool_choice="auto"
    )
    return response.choices[0].message

msg = run_erp_assistant("How many units of SKU-4492 are in warehouse WH-East?")
print(msg.tool_calls if msg.tool_calls else msg.content)

Because Oxlo.ai is fully OpenAI SDK compatible, this is a drop-in replacement. You can switch the base_url and api_key without changing your request construction logic.

Long Context Costs and ERP Payloads

ERP payloads are inherently verbose. A single JSON schema for a complex module can span thousands of tokens, and batching ten invoices into one prompt for entity extraction can quickly inflate costs on token-based platforms.

Oxlo.ai uses request-based pricing: one flat cost per API call regardless of prompt length. For long-context ERP workloads, this can be 10 to 100 times cheaper than token-based billing because cost does not scale with input length. This matters when you need to pass full database schemas, multi-turn conversation histories, or lengthy document contexts in a single request. See the Oxlo.ai pricing page for current plan details.</p

Top comments (0)