Skip to Content
Guides/Messages

Messages

Send a conversation and get the next turn: system prompts, images, limits, stop reasons.

Every request to Strokes Writing Intelligence is a conversation: a list of messages, and the model writes the next one.

One question

{
  "model": "swim-1.0",
  "messages": [
    { "role": "user", "content": "Write a subject line for our spring sale." }
  ]
}

A conversation

The API keeps no state between requests. To continue a conversation, send all of it each time, with the model's earlier replies as assistant messages:

{
  "model": "swim-1.0",
  "messages": [
    { "role": "user", "content": "Write a subject line for our spring sale." },
    { "role": "assistant", "content": "Spring into savings: 30% off everything" },
    { "role": "user", "content": "Shorter, and without a pun." }
  ]
}

System prompt

system sets the context for the whole conversation — who the model writes as, for whom, in what voice. It goes beside messages, not inside them:

{
  "model": "swim-1.0",
  "system": "You write for a calm, plain-spoken outdoor brand. No exclamation marks.",
  "messages": [
    {
      "role": "user",
      "content": "Write a subject line for our spring sale."
    }
  ]
}

Content blocks

content is a string, or a list of blocks. A user message can mix text and images:

{
  "role": "user",
  "content": [
    {
      "type": "text",
      "text": "Write alt text for this product photo:"
    },
    {
      "type": "image",
      "source": {
        "type": "url",
        "url": "https://example.com/trail-shoe.jpg"
      }
    }
  ]
}

An image is a URL or inline base64: { "type": "base64", "media_type": "image/jpeg", "data": "…" }. Documents such as PDFs aren't supported — send their text. Tools add tool_use and tool_result blocks: see Tool use.

The model searches the web on its own when a question needs it. Send "web_search": false to answer without it — for edits and rewrites of text you already sent, say. See Web search.

Mode

swim-1.0 supports business, academic and creative writing modes. Pass "mode": "business", "academic" or "creative" to set one, or leave it out and the API picks one for the request. See Modes.

Reasoning level

The model can reason before it answers. output_config.effort sets how much:

{
  "model": "swim-1.0",
  "output_config": { "effort": "high" },
  "messages": [
    {
      "role": "user",
      "content": "Restructure this essay so the argument builds: …"
    }
  ]
}
effort
lowThe default. Little or no reasoning: the fastest and cheapest answers
mediumRuns as high
highSome reasoning, at about the same speed. Better on long, many-step tasks
maxReasons in full — often thousands of tokens — before it writes. For the hardest tasks

thinking of type disabled runs at low too.

Reasoning is written in output tokens: it counts toward max_tokens and usage.output_tokens, and it's billed. At max, leave max_tokens out or give it plenty of room. If the model spends all of it reasoning and writes nothing, the API asks it again one level lower (max, then high, then low) so you still get an answer; every attempt is billed, so usage.output_tokens can then be higher than max_tokens.

See the reasoning

The reasoning isn't returned unless you ask for it. Send thinking of type adaptive (or enabled) and the reply starts with a thinking block:

{
  "model": "swim-1.0",
  "thinking": { "type": "adaptive" },
  "output_config": { "effort": "max" },
  "messages": [
    {
      "role": "user",
      "content": "Find the weakest step in this argument: …"
    }
  ]
}
"content": [
  {
    "type": "thinking",
    "thinking": "The argument moves from …",
    "signature": ""
  },
  {
    "type": "text",
    "text": "The weakest step is the third …"
  }
]

thinking only decides whether the reasoning is shown; how much the model reasons is still output_config.effort, and budget_tokens is ignored. "display": "omitted" hides it again. Streamed, it arrives as thinking_deltas before the text — see Streaming events. signature is always empty, and thinking blocks sent back in the conversation are dropped: the model never sees its earlier reasoning.

Length and stop reasons

max_tokens is optional: left out, the reply may be as long as the model allows, 32,000 tokens. Set it only to cut replies off at a hard limit — it stops the reply where it is rather than making it shorter; to get a shorter text, ask for it in the prompt. The Anthropic SDKs require the field, so the examples send 32000. Read stop_reason to know why the reply ended:

stop_reasonMeaning
end_turnThe model finished, or wrote one of your stop_sequences
max_tokensThe reply hit max_tokens and was cut off
tool_useThe model called one of your tools
pause_turnThe model was still searching the web after 12 rounds
refusalThe model declined to answer

stop_sequences takes up to four strings; the reply stops where the model would write one. It ends with end_turn, and stop_sequence is null.

A token is about four characters of English text.

Usage

Every reply carries usage:

"usage": {
  "input_tokens": 27,
  "cache_creation_input_tokens": 0,
  "cache_read_input_tokens": 0,
  "output_tokens": 39
}

input_tokens counts the system prompt, the messages and the tools you sent, less what was read from the prompt cache (cache_read_input_tokens); output_tokens counts the reply and its reasoning. With web search they add up every round of the request, and usage.server_tool_use counts the searches and page reads.

Tokens are billed at the model's price — $0.50 per million input tokens and $2.50 per million output tokens — from your organization's credits. The console's Usage and Activity pages add them up.

Prompt caching

When a request starts the same way as a recent one — the same tools, the same system prompt and the same earlier messages — the API reads that start from a cache instead of processing it again, and the reply comes sooner. It's automatic: there's nothing to turn on, and cache_control is accepted and ignored. What came from the cache is counted in usage.cache_read_input_tokens; input_tokens is the rest.

To get the most out of it, keep the start of your requests stable — tools and the system prompt first, in the same order, with anything that changes per request (a timestamp, a user's name) later in the conversation — and add new turns at the end. A cache entry lasts a few minutes after its last use. Cached tokens are billed like other input tokens.

Reference

Every field of the request and the response: POST /v1/messages.

On this page