Use Cases + Implementation

How do you build workflow automation with an OpenAI-compatible API?

Add an OpenAI-compatible chat completions call wherever a workflow needs judgement. The model receives the case context, returns a JSON-mode decision such as a category, priority or next action, and your orchestrator validates it, executes the matching step through function tools, and logs the run. Existing SDK code moves over with a base URL and model-name change.

Key facts

EndpointPOST https://api.plugsky.com/v1/chat/completions — same shape as OpenAI (live)
JSON modeLive for deterministic decision objects per workflow step
Function callingLive for executing workflow actions with strict schemas
CompatibilityKeep your SDK; change base_url and model names
Models30+ models; cheap tiers for classification, stronger for exceptions
PricingFlat monthly self-serve plans with no per-token charges on self-serve
Free tierplugsky-micro and plugsky-lite on the free plan, no card required
RoadmapThe batch endpoint is coming soon for offline workflow steps

TL;DR

  • Insert one chat completions call where the workflow needs judgement.
  • Demand JSON decisions and validate them before executing steps.
  • Expose actions as function tools with least-privilege credentials.
  • Make steps idempotent and log every decision for replay.
  • Keep the model out of deterministic steps entirely.

How it works, step by step

  1. Choose the workflow step that actually needs judgement, usually classification or exception routing.
  2. Define a JSON schema for the decision: action, category, confidence and required fields.
  3. Call chat completions with JSON mode and the case context, then validate the response in code.
  4. Map validated decisions to workflow branches and execute the matching step.
  5. Expose side-effecting actions as function tools with permission checks and idempotency keys.
  6. Add retries with backoff for transient errors and a dead-letter queue for repeated failures.
  7. Log prompt version, model, decision, tool calls and outcome, and replay historical cases after changes.
1Choose the workflowstep that actuallyneeds judgement,2Define a JSONschema for thedecision: action,3Call chatcompletions withJSON mode and the4Map validateddecisions toworkflow branches5Exposeside-effectingactions as function6Add retries withbackoff fortransient errors

Try it yourself

Open the JSON mode tester →

A webhook-to-decision step

Most workflows already have an orchestrator: a queue, a rules engine, a scheduler. The LLM step slots in where branching is fuzzy. A webhook arrives, your orchestrator assembles the case context, calls chat completions with JSON mode, validates the returned decision and continues down the matching branch. Nothing else about the workflow changes, which is why OpenAI compatibility matters — the call is the same shape your team already writes.

Keep the context tight: only the fields the decision needs. Sending the whole record wastes tokens, dilutes accuracy and widens the blast radius of any prompt-injection content inside the payload. Treat inbound text as untrusted and strip anything that looks like instructions.

Schemas, validation and retries

Never execute a model decision that has not passed a schema check. Validate types, enums and required fields; reject unknown actions; and treat missing required data as a clarification step rather than a guess. When validation fails, retry once with the validation error appended, then route to a human queue.

  • Pin the schema version so workflow code and prompts cannot drift apart.
  • Cap max_tokens to the size of the decision object.
  • Give every action an idempotency key derived from the case id and step.
  • Record the raw response for failed validations; they are your best prompt-improvement signal.

Reliability and observability

Automation earns trust through boring reliability. Retry transient failures with jitter, queue work instead of dropping it, and give each run a state machine so a crash leaves recoverable state rather than a half-finished process. Track decision accuracy, validation failure rate, retry rate and human override rate per step, because aggregate metrics hide which branch is weak.

Roll out by shadowing: run the LLM step in parallel with the existing rule, compare decisions, and only then let it drive execution. Because the endpoint is OpenAI-compatible, you can compare providers on the same prompts before committing. Start on the free plan with plugsky-micro and plugsky-lite, then move to paid tiers or the 14-day full-access trial as volume grows; current plans are on the live pricing page.

Honest comparison

ConcernPlugsky API stepVendor automation builderCustom ML model
IntegrationOpenAI SDK call in existing orchestratorPlatform-hosted flowsTrain and deploy a model
Decision formatJSON mode validated in codePlatform node typesWhatever you build
Model choice30+ models behind one endpointVendor modelsOne bespoke model
Action safetyFunction tools with your permission checksPlatform connectorsCustom
Change costPrompt and schema updatesRebuild flows in a consoleRetrain and redeploy

Frequently asked questions

Where does the LLM fit in an existing workflow?

At the step that needs judgement, typically classification, prioritisation or exception routing. The model returns a decision, your orchestrator validates it and executes the rest, so deterministic steps stay in code.

Why use JSON mode?

It makes the decision machine-checkable: types, enums and required fields can be validated before any action runs, which prevents prose parsing from breaking the workflow.

How do I handle invalid model output?

Validate against the schema, retry once with the validation error appended, then route to a human queue. Log every invalid response; they point to prompt or schema problems.

Are function tools required?

Only if the model should trigger actions directly. Many teams prefer the model to return a decision and let the orchestrator execute, which keeps permissions and side effects in one place.

How do I make retries safe?

Use idempotency keys derived from the case id and step, and make each action's server-side handler idempotent. Retries then cannot duplicate payments, emails or records.

Which model should handle which step?

Route routine classification to plugsky-micro or plugsky-lite and escalate complex or high-value cases to stronger tiers. All 30+ models sit behind one OpenAI-compatible endpoint.

Can I migrate existing OpenAI code?

Yes. Change the base URL and model names and keep your prompts, validation, retries and tests. The compatibility also makes reverting a one-line change.

Can I start for free?

Yes. The free plan includes plugsky-micro and plugsky-lite with no card, and a 14-day full-access trial is available for stronger models.