Skip to Content
Create a message

Create a message

POST /v1/messages — send a conversation and get the model's next message.

POST https://api.strokes.ink/v1/messages

Request

Headers

Header
x-api-keyRequired. Your API key. Authorization: Bearer <key> also works
content-typeRequired. application/json

Body

FieldType
modelstringRequired. swim-1.0. See Models
max_tokensintegerThe most tokens the reply may have, reasoning included. From 1 to the model's maximum, 32,000, which is also the default. The Anthropic SDKs require it: send 32000
messagesarrayRequired. The conversation so far, oldest first. At least one message
messages[].rolestringRequired. user or assistant
messages[].contentstring or arrayRequired. The message's text, or a list of content blocks
systemstring or arrayA system prompt: a string, or a list of text blocks
streambooleantrue to receive the reply as server-sent events. Default false
stop_sequencesarrayUp to 4 non-empty strings. The reply stops where the model writes one
temperaturenumberFrom 0 to 1
top_pnumberFrom 0 to 1
toolsarrayTools the model may call
tool_choiceobjectHow the model uses the tools: tool choice
output_config.effortstringHow much the model reasons: low (the default), medium, high or max. See reasoning level
thinkingobjectWhether the reasoning is returned: { "type": "adaptive" } or { "type": "enabled" } returns it as thinking blocks, "display": "omitted" hides it, { "type": "disabled" } reasons at low. budget_tokens is ignored. See reasoning level
web_searchbooleanWhether the model may search the web and read pages. Default true for swim-1.0. See Web search
stroke_idstringThe stroke the request belongs to: 1 to 200 letters, digits or . _ : -. The stroke-id header works too
modestringThe kind of writing: business, academic or creative. Left out, the API picks one for the request. See Modes

Other fields of Anthropic's Messages API, such as metadata, are accepted and ignored. These answer 400 invalid_request_error: top_k, container and mcp_servers.

Content blocks

In a user message:

Block
{ "type": "text", "text": "…" }Text
{ "type": "image", "source": { "type": "base64", "media_type": "image/png", "data": "…" } }An image, inline
{ "type": "image", "source": { "type": "url", "url": "https://…" } }An image, by URL
{ "type": "tool_result", "tool_use_id": "toolu_…", "content": "…", "is_error": false }Your answer to a tool_use. content is a string or a list of text blocks; is_error is optional

In an assistant message: text, tool_use, and the web search blocks server_tool_use, web_search_tool_result and web_fetch_tool_result — send the model's earlier replies back as they came. thinking and redacted_thinking blocks are accepted and dropped: the model never sees its earlier reasoning.

document blocks (PDFs and other files) aren't supported and answer 400.

Tools

A custom tool, which your code runs:

{
  "name": "get_word_count",
  "description": "Counts the words in a draft.",
  "input_schema": {
    "type": "object",
    "properties": { "draft_id": { "type": "string" } },
    "required": ["draft_id"]
  }
}

type may be left out or set to custom. name and input_schema are required.

Web search needs no tool: the model has it on every request unless you send "web_search": false. You can also declare web_search_20250305 (name: "web_search") or web_fetch_20250910 (name: "web_fetch") to override max_uses (1–10), allowed_domains, blocked_domains or max_content_tokens — see Web search.

Tool choice

tool_choice
{ "type": "auto" }The model decides. The default
{ "type": "any" }The model must call a tool
{ "type": "tool", "name": "…" }The model must call this tool
{ "type": "none" }The model must not call a tool

Add "disable_parallel_tool_use": true to get at most one call per reply. Every type but none needs tools.

Reasoning level

output_config.effort sets how much the model reasons before it answers:

{ "output_config": { "effort": "high" } }
effort
lowThe default, when output_config is left out or thinking is disabled. Little or no reasoning
mediumRuns as high
highSome reasoning
maxReasons in full, often thousands of tokens

Reasoning tokens count toward output_tokens and max_tokens — if you set max_tokens, leave room for them. If the model spends all of max_tokens reasoning and writes nothing, the API asks it again one level lower; every attempt is billed.

The reasoning is returned only with thinking of type adaptive or enabled: a thinking block, { "type": "thinking", "thinking": "…", "signature": "" }, before the text. See Messages.

Example

curl https://api.strokes.ink/v1/messages \
  -H "x-api-key: $STROKES_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "swim-1.0",
    "system": "You are a concise copy editor.",
    "messages": [
      {
        "role": "user",
        "content": "Tighten: We are very excited to be able to announce our new product."
      }
    ]
  }'

Response

A message object:

{
  "id": "msg_4bJ8wqT2nV9sKx1LmP0aR7cZ",
  "type": "message",
  "role": "assistant",
  "model": "swim-1.0",
  "content": [
    {
      "type": "text",
      "text": "We're excited to announce our new product."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 31,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "output_tokens": 112
  }
}
FieldType
idstringThe message's unique ID, msg_…
typestringAlways message
rolestringAlways assistant
modelstringThe model that wrote the reply
contentarrayThe reply's blocks, in order: thinking (when you asked for the reasoning), text, tool_use (a call for your code to run, with an id like toolu_…), and when the model searched the web server_tool_use, web_search_tool_result and web_fetch_tool_result
stop_reasonstringWhy the reply ended — see below
stop_sequencenullAlways null
usage.input_tokensintegerTokens read that weren't in the prompt cache: the system prompt, messages and tools — every round, when the API searched the web in between
usage.cache_read_input_tokensintegerTokens read from the prompt cache. All input is input_tokens plus this
usage.cache_creation_input_tokensintegerAlways 0: writing to the cache costs nothing
usage.output_tokensintegerTokens written, reasoning included
usage.server_tool_useobjectPresent when the model searched the web: web_search_requests and web_fetch_requests, the searches and page reads billed
stop_reason
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. Run it and send a tool_result — see Tool use
pause_turnThe model was still searching the web after 12 rounds. Send the reply back to let it go on — see Web search
refusalThe model declined to answer

Errors

StatusTypeWhen
400invalid_request_errorThe body isn't JSON, a field is missing, of the wrong type or not supported, or max_tokens is above the model's maximum
401authentication_errorThe key is missing, wrong, disabled or deleted
402billing_errorThe organization is out of credits, or the key reached its monthly spend limit
404not_found_errormodel isn't a model the API serves
529overloaded_errorThe model is busy. Retry with backoff
500api_errorSomething went wrong on our side. Retry

See Errors for the body and the messages.

On this page