Two OpenAI steps read text without writing any. Create embeddings — Turns text into vectors, for search and matching. Moderate text — Checks text against OpenAI's content categories, such as harassment, hate and violence, so a workflow can hold back a comment or a reply before it goes out.

Who can do this

Workspace Admins and Editors, on every plan.

Before you start

An OpenAI connection in Connections — see Connect OpenAI.

Steps

Create embeddings:

  1. Select + where the vectors should be made. In the step picker, open AI, then OpenAI, and select Create embeddings.
  2. In Connection, choose the connection with your key.
  3. Optional: in Model, choose one from the list read from OpenAI. Left empty, the step uses OpenAI's current small embedding model.
  4. In Text, a text with values in {{ }} — {{ $json.description }} — or a list of texts from an earlier step, up to 512. Each text gets its own vector, in order.
  5. Select Run this step.

Moderate text:

  1. In the step picker, under OpenAI, select Moderate text, and choose the Connection.
  2. Optional: in Model, choose one from the list. Left empty, the step uses OpenAI's current moderation model.
  3. In Text, the text to check — {{ $json.comment }}.
  4. Select Run this step.

To act on the answer, add IF after it with {{ $json.flagged }} is true — see Choose a path with IF.

Output

Create embeddings gives one item, whatever the number of texts: count, dimensions (the length of each vector), embeddings (one list of numbers per text, in order), first (the first vector) and usage — model, tokensIn and seconds.

Moderate text gives flagged (true or false), categories (the flagged categories by name, such as harassment or violenceGraphic), scores (every category with its score from 0 to 1 — {{ $json.scores.hate }}) and usage. OpenAI's category names are written as one word each, so they work in {{ }}: self-harm/intent is selfHarmIntent.

Output shows usage as the usage strip.

Good to know

  • Moderation is free on OpenAI; embeddings cost a little per text.
  • Keep one model for one set of vectors. Vectors from different models cannot be compared.
  • Each item is a separate call. Pin the output while you build — see Pin a step's output.

If something goes wrong

What the run says Why What to do
OpenAI refused: … Check the connection's details on Connections. The key is wrong or revoked. Replace the key on Connections.
OpenAI refused: … OpenAI refused the request — a text too long for the model, a rate limit, or no credit left. It is not tried again. Read OpenAI's reason.
Text is empty when the step ran — an earlier step may not have given the value it names. Text came out empty. Check the value in Data from earlier steps.
Text holds … texts; one step takes up to 512. Split the list first. The list is too long. Split it, or send fewer — see Repeat steps for each item with Loop Over Items.
Could not reach OpenAI: … / OpenAI did not answer within 5 minutes. OpenAI did not answer. Try again; set If this step fails to try again.