Skip to content

Introduction

In the age of AI, enterprise platforms face a critical challenge: integrating intelligence shouldn't be a complex, costly, and fragile project. It should be a fundamental building block of the application itself.

The $ai API is Simple's answer to this challenge. We have transformed artificial intelligence from a complex external service you must integrate into a secure, durable, and hyper-performant platform primitive, as easy to use as a function call.

This is not just another API wrapper. It is a fully managed, end-to-end intelligence engine, deeply integrated into the core of the Simple Platform.

The Problem: The Legacy Approach to AI Integration

On platforms like Salesforce, ServiceNow, or SAP, integrating AI for a task like document processing is a multi-week project fraught with complexity, security risks, and unpredictable results. The developer is responsible for everything:

  1. Vendor Management: Finding, vetting, and managing contracts and API keys for third-party AI services.
  2. Brittle Code: Writing verbose Apex or server-side logic to handle authentication, API requests, and parsing inconsistent JSON responses.
  3. No Guarantees: Building complex retry logic and error handling to deal with unreliable AI model outputs.
  4. Security Holes: Architecting a secure way to transfer sensitive customer documents to an external service, often creating significant compliance risks.
  5. Performance Bottlenecks: Processing files and managing AI jobs in-process, leading to slow response times and an inability to scale.

The result is a slow, expensive, and fragile solution that adds significant maintenance overhead and delivers an unreliable user experience.

The Simple Advantage: A Single, Secure, and Deterministic Function Call

The Simple Platform handles all of that complexity for you. Your entire workflow is reduced to a single, secure function call within a Record Behavior.

javascript
export default async ({ $form, $ai }) => {
  // When a user uploads an invoice...
  if ($form.updated('invoice_pdf')) {
    const invoice = $form('invoice_pdf').value();

    // ...securely extract the data with one line of code.
    const { data } = await $ai.extract(invoice, {
      prompt: "Extract the invoice number, total, and all line items.",
      schema: { /* a JSON schema defining your desired output */ }
    });

    // And populate your form with guaranteed, structured data.
    $form('invoice_number').set(data.invoice_number);
    $form('total_amount').set(data.total_amount);
    // ...
  }
}

This is possible because the $ai API is a fully managed system that leverages our entire platform architecture.

Simple AI Architecture Overview

When you call the $ai API, you are invoking a powerful, durable backend system that handles:

  • Zero-Configuration AI: No API keys to manage. No external accounts to provision. It just works.

  • Guaranteed & Deterministic Responses: By providing a JSON schema, you define a strict contract for the AI's output. Our AI Engine automatically validates, retries, and conforms the provider's response to your schema. You get the exact same structured JSON output every time for the same input, guaranteed.

  • Automated Model Selection: You can specify a model class (lite, medium, large), and the AI Engine intelligently routes your request to the best-performing and most cost-effective model available that meets your needs, abstracting away specific provider model names like 'GPT-4o' or 'Gemini 2.5'.

  • Secure by Design: The entire operation runs on the server. Our Secure Asset Federation streams files directly from Simple's secure storage to the AI provider, ensuring the application server is never a bottleneck or an attack vector. Sensitive data is never exposed to the client.

  • Massive Scalability & Durability: Your request becomes a durable job, published via NATS to a highly concurrent pool of AI workers. The system is designed to handle tens of thousands of parallel jobs, with automatic retries and self-healing capabilities for orphaned tasks.

  • Cost-Efficient by Default: All AI operations are deterministically cached. If the same file is processed with the same instructions, the result is returned instantly from the AI Memcache at zero additional cost and near-zero latency.

  • Seamless Document Handling: The $ai API is natively integrated with our Secure Document Handling lifecycle. Simply pass a document handle from a form field, and the platform orchestrates the rest.

Next Steps