Recipe

AWS Step Functions primer

AWS Step Functions orchestrate distributed services as visual state machines. This primer walks through the moving parts so you can wire Meridian model calls into a production-grade workflow with retries, parallel branches, and observable history.

1.State machine anatomy

A Step Functions state machine is an Amazon States Language (ASL) document. It declares states — Task, Choice, Parallel, Map, Wait, Pass, Succeed, Fail — and transitions. Standard workflows persist execution history for up to one year and bill per state transition; Express workflows bill per duration and are sub-second ideal for high-volume Meridian fanouts.

  • Task states invoke Lambda, ECS, or any AWS SDK action directly.
  • Choice states branch on JSONPath expressions against the running payload.
  • Map states iterate a list with bounded concurrency — perfect for batch inference.

2.Calling Meridian from a Task state

Wrap the Meridian gateway in a thin Lambda or use the HTTPS Task integration. The snippet below defines a single Task state that posts a chat completion request tollm.getnimbus.netand routes the response into the next state.

{
  "Comment": "Meridian completion via Step Functions",
  "StartAt": "CallMeridian",
  "States": {
    "CallMeridian": {
      "Type": "Task",
      "Resource": "arn:aws:states:::http:invoke",
      "Parameters": {
        "ApiEndpoint": "https://llm.getnimbus.net/v1/chat/completions",
        "Method": "POST",
        "Authentication": {
          "ConnectionArn": "arn:aws:events:us-east-1:000:connection/meridian"
        },
        "RequestBody": {
          "model": "azure/model-router",
          "messages.$": "$.messages"
        }
      },
      "Retry": [{
        "ErrorEquals": ["States.ALL"],
        "IntervalSeconds": 2,
        "MaxAttempts": 3,
        "BackoffRate": 2.0
      }],
      "End": true
    }
  }
}

3.Observability and cost guardrails

Enable CloudWatch Logs at the ALL level during development and switch to ERROR-only in production. Use X-Ray tracing on the state machine to see span-level latency for every Meridian call. Set a Map stateMaxConcurrencyto cap concurrent gateway hits, and front the workflow with an SQS queue so bursts shed gracefully instead of failing executions.