OpenAI · Arazzo Workflow

OpenAI Moderate then Chat

Version 1.0.0

Screen user input with the moderation endpoint, then chat only if it is safe.

1 workflow 2 source APIs 1 provider
View Spec View on GitHub Artificial IntelligenceLarge Language ModelsT1ArazzoWorkflows

Provider

openai

Workflows

moderate-then-chat
Moderate input text and create a chat completion only when it is allowed.
Classifies the user input for policy violations, and only when the content is not flagged does it forward the message to the chat completions endpoint.
2 steps inputs: apiKey, chatModel, userMessage outputs: flagged, reply
1
moderate
Classify the user input for policy violations.
2
createChat
Create a chat completion for the moderated, allowed user message.

Source API Descriptions

Arazzo Workflow Specification

Raw ↑
arazzo: 1.0.1
info:
  title: OpenAI Moderate then Chat
  summary: Screen user input with the moderation endpoint, then chat only if it is safe.
  description: >-
    Runs the supplied user text through the moderation classifier and branches:
    when the content is flagged the flow ends without calling the model, and
    when it is not flagged it creates a chat completion. Every step spells out
    its request inline so the flow can be read and executed without opening the
    underlying OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: chatApi
  url: ../openapi/openai-chat-api-openapi.yml
  type: openapi
- name: moderationsApi
  url: ../openapi/openai-moderations-api-openapi.yml
  type: openapi
workflows:
- workflowId: moderate-then-chat
  summary: Moderate input text and create a chat completion only when it is allowed.
  description: >-
    Classifies the user input for policy violations, and only when the content
    is not flagged does it forward the message to the chat completions endpoint.
  inputs:
    type: object
    required:
    - apiKey
    - chatModel
    - userMessage
    properties:
      apiKey:
        type: string
        description: OpenAI API key used as a Bearer token.
      chatModel:
        type: string
        description: The model id for the chat completion (e.g. gpt-4o-mini).
      userMessage:
        type: string
        description: The user message to moderate and then send to the model.
  steps:
  - stepId: moderate
    description: Classify the user input for policy violations.
    operationId: createModeration
    parameters:
    - name: Authorization
      in: header
      value: "Bearer $inputs.apiKey"
    requestBody:
      contentType: application/json
      payload:
        input: $inputs.userMessage
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      flagged: $response.body#/results/0/flagged
    onSuccess:
    - name: contentAllowed
      type: goto
      stepId: createChat
      criteria:
      - context: $response.body
        condition: $.results[0].flagged == false
        type: jsonpath
    - name: contentFlagged
      type: end
      criteria:
      - context: $response.body
        condition: $.results[0].flagged == true
        type: jsonpath
  - stepId: createChat
    description: Create a chat completion for the moderated, allowed user message.
    operationId: createChatCompletion
    parameters:
    - name: Authorization
      in: header
      value: "Bearer $inputs.apiKey"
    requestBody:
      contentType: application/json
      payload:
        model: $inputs.chatModel
        messages:
        - role: user
          content: $inputs.userMessage
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      completionId: $response.body#/id
      reply: $response.body#/choices/0/message/content
  outputs:
    flagged: $steps.moderate.outputs.flagged
    reply: $steps.createChat.outputs.reply

Work with this as data

Every workflow here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for arazzo workflows

4 MCP tools reach this
  • find_arazzoBrowse and filter every workflow in the catalog.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This workflow
curl "https://apis.io/api/v1/arazzo/openai-moderate-then-chat-workflow"
All arazzo workflows
curl "https://apis.io/api/v1/arazzo?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.