Headless automation in your ERP with a scheduled model call

AnthropicKeyFreeAPI · Updated 2026-11-22 · 8 min read

Office at night with one glowing computer and shelves of folders
Scheduled scripts work while nobody is at the desk.

Business platforms increasingly ship chat-style AI connectors, and they are pleasant for asking questions about your data. But people who want real automation, such as classifying incoming records overnight or drafting descriptions for new items without anyone clicking a button, soon find a connector is not enough. The natural question is whether a server-side script inside the platform, for example a NetSuite SuiteScript, can call a model API directly and do the work in the background.

It can, and the pattern is the same for most ERP and CRM scripting environments: an HTTPS POST with a JSON body, a parsed response and careful handling of limits and errors. This guide walks through a scheduled SuiteScript that calls an OpenAI-compatible endpoint, explains how to adapt it to a paid provider such as Anthropic, and spends real time on the part that matters most in business systems: what data you are allowed to send. This site is not affiliated with Anthropic or Oracle NetSuite.

Frequently asked questions

What is SuiteScript?

It is NetSuite's JavaScript-based scripting platform for customising and automating the ERP. Scripts of different types run on schedules, on record events or as web services, and can make outbound HTTPS requests through a built-in module.

How does a connector differ from a script calling an API?

A connector lets a person chat with an assistant that can look at platform data. A script runs unattended on a schedule or trigger and can process many records automatically. Scripts are what you need for true automation.

Can a SuiteScript call the Anthropic API directly?

Yes, through an outbound HTTPS request with Anthropic's own headers and Messages format and a key stored securely. Anthropic's official API documentation describes the exact request shape.

Which is better for business data, a paid API or a free endpoint?

For real customer, financial or employee data, a paid provider with a data processing agreement is the right choice. A free endpoint without contractual terms suits test data, public product text or prototypes.

What are governance limits?

Platform-imposed caps on how much work a script may do, such as usage units per execution and time limits. Outbound HTTP calls consume units, so long batches must be split or rescheduled.

What does the free endpoint here require?

No key and no account. Send a POST to https://api.anthropickeyfreeapi.com/v1/chat/completions with model free-ai. Limits are per IP, which matters because your scripts share the platform's outbound address.

What is free-ai?

An independent open-weight model of about 35B parameters, fine-tuned to refuse less than commercial assistants. It is not Claude and not an Anthropic product.

Step by step

  1. Choose a low-risk task — Pick a classification or drafting task where a wrong answer is visible and harmless, and decide where the AI output will be stored for review.
  2. Create a scheduled script — Write a SuiteScript 2.1 scheduled script that loads a small batch of records with a saved search.
  3. Add the HTTPS call — Use the N/https module to POST a chat request with model free-ai, a strict system prompt and only the fields the task needs.
  4. Validate and write back — Check the reply against your allowed values and write it to a draft field or custom record, logging failures with their status code.
  5. Schedule and monitor — Deploy the script on a schedule, cap records per run to respect governance and rate limits, and review the suggestions regularly.

Why scripts, not chat connectors

Chat connectors shine when a human is in the loop: someone asks a question, the assistant fetches data and answers. Automation is the opposite. Nobody is watching; records arrive, something must happen to each, and the result must land back in a field. That requires code that runs on a schedule or a trigger, calls a model with a precise prompt and writes a structured answer.

Back-office tasks that fit this pattern are common and unglamorous. Tag support cases by topic. Draft a first version of an item description from its attributes. Summarise a long vendor note into one line. Flag sales orders whose memo field mentions a cancellation.

Begin with one task and one record type. A narrow first integration is easy to evaluate, and its success makes a stronger case for expanding than a broad pilot that is hard to judge.

Pick tasks with cheap mistakes

Start where an occasional wrong answer is harmless and visible, such as a suggested category a person confirms. Avoid automating anything that moves money or sends messages to customers until you have confidence in the results.

Keep a human review queue

Write AI output to a draft field or a custom record, not directly into the final one. A saved search of pending suggestions becomes your review queue.

The request in plain terms

An OpenAI-compatible chat call is a JSON object with a model name and a list of messages. The system message sets the rules; the user message holds the record data. The response returns the model's reply under choices[0].message.content. That is all a script needs to know.

Anthropic's native API uses a different shape, with its own endpoint, headers including an API key and version, and a Messages format where the system prompt is a separate field. The script structure is the same; only the request builder and response parser change. We compare the formats in Messages API vs chat completions.

Ask for structured output

Tell the model to reply with a single JSON object or a single word from a fixed list. Parsing free text inside an ERP script is fragile; parsing one token from a known set is easy.

Set a low temperature

For classification and extraction, a temperature of zero makes answers more consistent from run to run, which simplifies validation and review.

Capsule entering a pneumatic tube
One HTTPS request carries the record to the model and back.

A scheduled SuiteScript example

The script below is a SuiteScript 2.1 scheduled script. It sends one prompt to the free endpoint and logs the reply. In a real deployment you would load a batch of records with a search, loop over them and write results back, but the HTTP part is exactly this.

Validate the answer

Check the reply against your allowed list before writing it anywhere. Anything unexpected becomes other, or is left for review.

Store prompts as script parameters

Putting the system prompt in a script parameter lets an administrator refine it without redeploying code.

/**
 * @NApiVersion 2.1
 * @NScriptType ScheduledScript
 */
define(['N/https', 'N/log'], (https, log) => {
  const ENDPOINT = 'https://api.anthropickeyfreeapi.com/v1/chat/completions';

  const classify = (text) => {
    const res = https.post({
      url: ENDPOINT,
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        model: 'free-ai',
        temperature: 0,
        max_tokens: 10,
        messages: [
          { role: 'system', content: 'Classify the support case. Reply with one word: billing, shipping, product or other.' },
          { role: 'user', content: text }
        ]
      })
    });
    if (res.code !== 200) {
      log.error({ title: 'AI call failed', details: res.code + ' ' + res.body });
      return null;
    }
    const data = JSON.parse(res.body);
    return data.choices[0].message.content.trim().toLowerCase();
  };

  const execute = () => {
    const label = classify('My invoice shows the wrong tax amount for last month.');
    log.audit({ title: 'AI label', details: label });
  };

  return { execute };
});

Respecting governance and rate limits

ERP platforms meter scripts. Each outbound request consumes governance units, and scheduled scripts have a ceiling per execution. A batch that tries to classify thousands of records in one run will hit that ceiling. Process a bounded number per run, record progress and let the next scheduled run continue, or use the platform's map/reduce script type for large volumes.

The model API has limits too. On this site's endpoint each IP address may send one request per second with bursts of three, keep two in flight and make up to 10,000 requests per day, resetting at 00:00 UTC. Because a hosted ERP sends traffic from shared outbound addresses, other tenants on the same address could, in principle, share that budget, so do not count on the full allowance.

Back off on 429 and 503

A 429 includes a Retry-After header. A 503 means the server is busy and a retry after a few seconds usually succeeds. In a scheduled script, the simplest strategy is to stop the run and let the next one resume.

People passing through a turnstile one by one
Governance units and rate limits pace every batch.

Data you may and may not send

This is the most important section. ERP records contain customer names, addresses, payment details, salaries and contract terms. Sending them to any external model is a data transfer that your privacy obligations, contracts and internal policies govern. A free endpoint offers no data processing agreement and keeps a technical log per request, including IP, time, sizes and tokens.

For anything personal or confidential, use a paid provider whose terms you have reviewed and who will sign the agreements your organisation requires. Free endpoints are appropriate for public data, such as marketing copy for products already on your website, or for synthetic test records while you build the integration.

  • Never send payment card numbers, bank details or government IDs
  • Strip names and contact details when the task does not need them
  • Send only the fields the prompt actually uses
  • Document which scripts call which providers and why
  • Review the provider's terms before any production data flows

Switching to a paid provider later

Because the script isolates the HTTP call in one function, switching providers is a contained change. For an OpenAI-compatible provider, replace the URL and model and add an authorisation header. For Anthropic's native API, rewrite the request body to its Messages format and read the reply from its response structure.

Store keys using the platform's secure credential mechanism rather than in script source or plain parameters. Restrict who can view or edit the script deployment, and rotate keys when people with access leave.

Keep one function per provider

A small adapter per provider, each returning the same simple result, lets you switch with a parameter and compare outputs on the same records.

Budget before you scale

Estimate tokens per record and records per day, then multiply by the provider's current rates. Log usage from the response so you can check the estimate against reality.

Shredder beside a locked filing cabinet
Send only the fields the task needs, and never sensitive data to a free service.

Where a free model is good enough

Classification into a handful of labels, short summaries and first-draft product text are tasks where a 35B open model performs well. Writing nuanced customer correspondence, interpreting complex contracts or reasoning about accounting rules are where a stronger commercial model clearly earns its cost.

free-ai refuses far less than commercial assistants, which rarely matters for back-office text but means your prompts, not the model, must enforce business rules. It also has two hard limits it will never cross: no sexual content involving minors and no operational guidance for mass-casualty weapons.

Test on a sample first

Run fifty real but anonymised records through the prompt and compare with what a person would have chosen. That tells you quickly whether the model is ready for the task.

Monitoring the integration

Log every failed call with its status code and a short excerpt of the error body. Count successful classifications per run. A saved search over the review queue shows how often people correct the model, which is your best quality signal over time.

Watch for drift. If corrections increase, the data may have changed, or the provider may have changed the model. Keep a small fixed set of test records and run them weekly to tell the two apart. The same ideas apply to any back-office platform; for a wider view of costs see tracking API spend.

Alert on silence

A scheduled job that quietly stops producing results is worse than one that fails loudly. Alert when a run processes zero records on a day when there should have been work.

Control room dials with one needle drifting
Watch correction rates to catch drift early.
Try the free API

Send a prompt to the keyless free-ai endpoint from the home page and see how it handles your own task, no signup needed.

Read also