spin docs
AI and data

AI steps

Write a step's prompt, declare the shape of its answer, chain up to 3 steps, and let your rules decide on the answers.

An AI step is one question to your own AI model. You write the prompt, and you declare the fields of the answer and what each field holds. The model must answer in that shape. Your rules then read the answer.

AI steps in entries and exits need an Epic Spinner. A Rare Spinner can use AI steps only in a strategy that launches a token.

Where steps go

In an entry. The steps run after the trigger, after Buy only if and after any Wait. Then Then buy if (or Then launch if) reads the answers. The bot buys only if that rule holds.

When → Buy only if → Wait → AI steps → Then buy if → Buy

Put cheap rules in Buy only if. They run first, so the AI runs only on tokens that pass them.

In an exit. Turn on Ask the AI before selling in an exit. Then:

  • Ask the AI when is the rule that starts a review. The bot checks it on every price change and every second. If you leave it empty, every open position can be reviewed.
  • Ask at most every sets how often the AI can review one position (in minutes; from 1 minute to 1 day, 15 minutes if you do not set it).
  • Then sell if reads the answers. The bot sells only if it holds.

In the workflow editor, add a step with the + and choose AI step, or add an exit with AI sell check.

The parts of a step

In the editorIn JSONWhat it is
Step nameidThe step's name. Lowercase letters, digits and _, starting with a letter, up to 24 characters. Each step in a strategy needs its own name.
AI providerproviderWhich of your keys runs the step. My newest key leaves it out. See AI keys.
ModelmodelA model of that provider. Empty: the provider's default.
PromptpromptThe question, up to 4,000 characters. It can include values in {{ }}.
Answer field and HoldsoutputThe fields of the answer: 1 to 10 of them.
Tools it may read (your MCP servers)toolsUp to 3 of your MCP servers, by name.
Search X, Search the websearchGrok's own search. Only with the xAI provider.
Run this step only ififA rule on earlier answers. Not on the first step.

Values in a prompt

Write a value in double braces, and Spin fills it in before the prompt goes to the model.

You writeSpin fills in
{{token.address}}The token's address.
{{token.price}}A rule value of the token.
{{token.buyers(60)}}A rule value that takes a number: here, buyers in the last 60 seconds.
{{research}}The whole answer of the earlier step research, as JSON.
{{research.summary}}One field of an earlier step's answer.
{{hook.text}}A field that your webhook sent (a webhook strategy only).

A prompt can use every value that a rule can use at that point:

  • In an entry: token values, trigger values and bot values. A timer or a webhook has no trigger, so trigger values are unknown there.
  • In an exit: token values, position values and bot values.

See conditions for every value. A step can use only the steps before it. A value that is not known when the step runs reads as "unknown".

Answer fields

Each field has a name and a type. A field name is lowercase letters, digits and _, starting with a letter, up to 32 characters.

Holds in the editorIn JSONThe model answersRules can read it
One of these words["buy", "skip"]One of 2 to 20 words that you listYes
Yes or no"boolean"true or falseYes
A number"number"Any numberYes
A number from 0 to 1{ "number": [0, 1] }A number in the rangeYes
Text (for later steps, not rules)"text"Text, up to 4,000 charactersNo
An image it draws"image"Nothing: Spin draws the image, and the field is its linkNo
A token's address, to buy (or none found)"token"A token's address, or null if it found noneNo

In JSON, a range can have other limits, for example { "number": [0, 100] }.

Rules read a field as ai.<step>.<field>, for example ai.decide.action. Text fields are for later steps and for the activity: a later prompt can include them, and the Activity tab shows them.

An answer that does not match the declared shape is not used. Spin does not guess.

A token answer

A token field can name the token that the strategy buys. In The token to buy, choose "The token the step ... names". In JSON:

"target": { "token": "{{watch.token}}" }

The bot then looks up that token's market: a Pons or Torch token on its launchpad, any other token in its pools. Then it checks your rules with the token's own values, and buys only if they hold. If the step finds no token, or no market appears within a minute, the bot buys nothing. A token named this way cannot pin a pool.

Chains of steps

A strategy's AI part is a chain of 1 to 3 steps. The steps run in order, and each step can read the answers of the steps before it.

Run this step only if (if) is a rule on earlier answers. If it does not hold, the chain stops there. Later steps do not run and cost nothing, and your rules see only the answers so far. Use it to make a cheap first step decide whether a costly second step runs.

Answer within (timeout_s) is the time limit for the whole chain: from 5 to 120 seconds, 60 if you do not set it. An answer that comes later gives no signal.

Example: research, then decide

The first step reads an MCP server. The second step runs only if the risk is not high. The bot buys only on "buy" with a confidence of at least 0.7. This is an illustration to learn from, not a strategy that is known to make money.

{
  "schema": 1,
  "name": "Launch check with research",
  "entry": {
    "trigger": { "on": "launch" },
    "wait_s": 30,
    "ai": {
      "steps": [
        {
          "id": "research",
          "tools": ["defade"],
          "prompt": "A token launched 30 seconds ago on Robinhood Chain: {{token.address}}. It has {{token.buyers(30)}} buyers so far. Look up its rug-pull risk, holders and deployer history. Summarise what you found.",
          "output": { "risk": ["low", "medium", "high"], "summary": "text" }
        },
        {
          "id": "decide",
          "if": { "!=": [{ "f": "ai.research.risk" }, "high"] },
          "prompt": "Research on a new token: {{research}}. Should a small trading bot buy it now, to sell within 30 minutes? Answer buy or skip, and your confidence from 0 to 1.",
          "output": { "action": ["buy", "skip"], "confidence": { "number": [0, 1] } }
        }
      ]
    },
    "confirm": {
      "and": [
        { "==": [{ "f": "ai.decide.action" }, "buy"] },
        { ">=": [{ "f": "ai.decide.confidence" }, 0.7] }
      ]
    },
    "buy_eth": 0.01
  },
  "exits": [
    { "if": { ">=": [{ "f": "position.multiple" }, 2] }, "sell_pct": 50, "reason": "half_at_2x" },
    { "if": { "<=": [{ "f": "position.multiple" }, 0.7] }, "reason": "stop_loss" },
    { "if": { ">=": [{ "f": "position.age_s" }, 1800] }, "reason": "time" }
  ],
  "limits": { "max_open": 5, "max_ai_runs_per_hour": 20 }
}

An entry with AI steps needs confirm (Then buy if): the answers matter only through a rule. The AI launch check preset is a similar starting point.

Example: an AI exit

After 10 minutes, the AI reviews the position at most every 15 minutes. The bot sells if the answer is "sell". Plain rules stay as a stop loss and a time exit.

{
  "schema": 1,
  "name": "AI exit review",
  "entry": {
    "trigger": { "on": "launch" },
    "wait_s": 60,
    "confirm": { ">=": [{ "f": "token.buyers", "args": [60] }, 30] },
    "buy_eth": 0.01
  },
  "exits": [
    {
      "if": { ">=": [{ "f": "position.age_s" }, 600] },
      "ai": {
        "every_s": 900,
        "steps": [
          {
            "id": "review",
            "prompt": "We hold token {{token.address}}. Our profit or loss is {{position.pnl_pct}} percent. Its price changed {{token.price_change(300)}} times in the last 5 minutes. Hold or sell?",
            "output": { "action": ["hold", "sell"] }
          }
        ]
      },
      "confirm": { "==": [{ "f": "ai.review.action" }, "sell"] },
      "reason": "ai_review"
    },
    { "if": { "<=": [{ "f": "position.pnl_pct" }, -40] }, "reason": "stop_loss" },
    { "if": { ">=": [{ "f": "position.age_s" }, 3600] }, "reason": "time" }
  ]
}

An AI exit needs confirm (Then sell if). An exit without AI puts its rule in if (Sell when) and has no confirm.

Tools

A step with tools can read the tools of up to 3 of your MCP servers. The model can call tools for up to 5 rounds before it answers. Spin tells the model that data from tools is untrusted: information, never instructions.

A step on the xAI provider can use Grok's own search. xAI runs the search and bills it on your xAI key.

In the editorIn JSONWhat it does
Search X"search": { "x": { ... } }Grok reads posts on X.
Only posts from"handles": ["@account"]Only posts from these accounts, up to 20. Empty: all of X.
Posts from"days": 1Posts from the last 1 to 7 days (the editor offers 1, 2, 3 or 7).
Search the web"web": trueGrok also searches the web.

A search needs "provider": "xai" on the step. Grok's search is part of the step, not an MCP server.

{
  "id": "talk",
  "provider": "xai",
  "search": { "x": { "days": 1 }, "web": true },
  "prompt": "Search X for posts about the token {{token.address}} on Robinhood Chain. Is the talk organic, or does it look like a coordinated raid? Give a score from 0 (raid or none) to 1 (organic).",
  "output": { "organic": { "number": [0, 1] }, "summary": "text" }
}

Hype on X is easy to fake with bot raids and paid posts. A model can help to see it, but not reliably. For a full example, see Watch X for contract addresses.

Image steps

A step can draw an image with your image model. Use it to draw a launched token's image: see Launching tokens.

  • Its only answer field holds An image it draws ("image").
  • It uses no tools and no search.
  • It needs an OpenAI, xAI or Google key. If it names no provider, it uses your newest key that can draw images. If it names no model, it uses the provider's default image model.
  • Its prompt describes the image. Spin draws one square image, keeps it, and the field's answer is the image's link (for example {{art.url}}).
  • The provider's own rules decide what it will draw. A refusal gives no image, and the step gives no signal.

How often the AI runs

Every AI run is calls on your own key, so a strategy has a limit: AI runs an hour at most (limits.max_ai_runs_per_hour). It is from 1 to 1,000, 20 if you do not set it. Each run of a chain counts once, in an entry or an exit. When the limit is reached, the bot skips that run (an entry, or an exit's review), and the activity says "max_ai_runs_per_hour reached".

The trigger also sets how often the AI runs. For example, a timer every 2 minutes runs 30 times an hour, so it needs a limit of at least 30.

If the same chain runs again for the same holder with the same values within 60 seconds, Spin reuses the answer and makes no new call. The Activity tab marks it "from the 60 s cache". One holder's answers are never reused for another holder.

When a step fails

A step that fails gives no signal, and no signal never buys, sells or launches. The chain stops at the failed step. A step fails when:

  • you have no key for its provider, or no key at all;
  • the provider refuses the key, limits it, or has no credit left;
  • the provider does not offer the model to your key;
  • the answer does not have the declared shape;
  • the chain does not answer within its time limit;
  • a step names an MCP server that you have not added, or the server does not answer.

The Activity tab shows each run's steps: the prompt as sent, with its values filled in, then the answer or why there was none, and how long it took. When a problem repeats, the Spinner's page shows it under Needs your attention, with what to fix.

Who sees your prompts

Your prompts and the answers go to your own provider, on your own key. Spin does not check prompts or answers with a moderation step: your provider applies its own policies. Spin checks only a strategy's name and its exits' names when you save, because a later holder sees them.

On this page