← All procedures

llm.complete

Send a prompt to a language model and give the text and the usage. The model can use tools and procedures

CLI
Package
@procedures/llm · README
Path
["llm","complete"]
CLI
mark llm complete --prompt <string>
As data
{"$proc":["llm","complete"],"input":{}}
Tags
llm, anthropic, tools

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/llm/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["llm","complete"], { prompt: "<prompt>" });
console.log(JSON.stringify(result));

From the command line

$ mark llm complete --prompt <string>

As data, in a program

{ "$proc": ["llm", "complete"], "input": { "prompt": "<prompt>" } }

Input

FieldTypeRequiredDefaultDescription
promptstringyesThe text of the user
systemstringnoThe system text: the instructions to the model
modelstringnoThe model (default: the model of the module, claude-sonnet-5-5)
maxTokensintegernoThe most tokens of the output, with the thinking (default 16000)
temperaturenumbernoThe temperature, 0 to 1. Some models accept only the default
effort"low" | "medium" | "high" | "xhigh" | "max"noThe effort of the model (default: the default of the model)
timeoutMsintegernoThe time limit of each request, in milliseconds (default 600000)
fallbackbooleannoTrue: the API runs a declined request again on its fallback model (default: the option of the module, true)
toolsobject[]noThe tools that the model can use. The output gives each tool_use block
toolChoiceanynoHow the model uses the tools: auto (default), any, tool or none. Some models refuse any and tool
retriesintegernoThe new tries after a retryable error (429, 529, 5xx, a connection error), 0 to 10 (default: the option of the module, 2)
proceduresstring[]noThe procedures that the model can use as tools: the procedure calls them and sends the results back
maxRoundsintegernoThe most requests to the model in one call, 1 to 64 (default 8)

Output

FieldTypeRequiredDefaultDescription
textstringyesThe text of the last answer
modelstringyesThe model that answered
stopReasonstringyesWhy the model stopped: end_turn, max_tokens, stop_sequence, tool_use or another reason
usageobjectyesThe tokens of the call
toolUsesobject[]yesThe tool_use blocks of the last answer that no procedure ran
toolCallsobject[]yesThe calls of the procedure tools, in their sequence
roundsintegeryesThe number of requests to the model
roundLimitbooleanyesTrue when maxRounds stopped the loop before the model stopped
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "prompt": {
        "type": "string",
        "minLength": 1,
        "maxLength": 4000000,
        "description": "The text of the user"
      },
      "system": {
        "description": "The system text: the instructions to the model",
        "type": "string",
        "maxLength": 4000000
      },
      "model": {
        "description": "The model (default: the model of the module, claude-sonnet-5-5)",
        "type": "string",
        "minLength": 1,
        "maxLength": 200,
        "pattern": "^[A-Za-z0-9][A-Za-z0-9._:@/-]*$"
      },
      "maxTokens": {
        "description": "The most tokens of the output, with the thinking (default 16000)",
        "type": "integer",
        "minimum": 1,
        "maximum": 64000
      },
      "temperature": {
        "description": "The temperature, 0 to 1. Some models accept only the default",
        "type": "number",
        "minimum": 0,
        "maximum": 1
      },
      "effort": {
        "description": "The effort of the model (default: the default of the model)",
        "type": "string",
        "enum": [
          "low",
          "medium",
          "high",
          "xhigh",
          "max"
        ]
      },
      "timeoutMs": {
        "description": "The time limit of each request, in milliseconds (default 600000)",
        "type": "integer",
        "exclusiveMinimum": 0,
        "maximum": 3600000
      },
      "fallback": {
        "description": "True: the API runs a declined request again on its fallback model (default: the option of the module, true)",
        "type": "boolean"
      },
      "tools": {
        "description": "The tools that the model can use. The output gives each tool_use block",
        "maxItems": 128,
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_-]{1,128}$",
              "description": "The name of the tool"
            },
            "description": {
              "description": "What the tool does and when the model uses it",
              "type": "string",
              "maxLength": 100000
            },
            "inputSchema": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {},
              "description": "The JSON Schema of the input of the tool, with type object"
            },
            "strict": {
              "description": "True: the API makes each input agree with the schema (strict tool use)",
              "type": "boolean"
            }
          },
          "required": [
            "name",
            "inputSchema"
          ]
        }
      },
      "toolChoice": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "auto"
              },
              "disableParallelToolUse": {
                "description": "True: the model uses at most one tool in an answer",
                "type": "boolean"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "any"
              },
              "disableParallelToolUse": {
                "description": "True: the model uses at most one tool in an answer",
                "type": "boolean"
              }
            },
            "required": [
              "type"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "tool"
              },
              "name": {
                "type": "string",
                "pattern": "^[a-zA-Z0-9_-]{1,128}$",
                "description": "The tool that the model uses"
              },
              "disableParallelToolUse": {
                "description": "True: the model uses at most one tool in an answer",
                "type": "boolean"
              }
            },
            "required": [
              "type",
              "name"
            ]
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "none"
              }
            },
            "required": [
              "type"
            ]
          }
        ],
        "description": "How the model uses the tools: auto (default), any, tool or none. Some models refuse any and tool"
      },
      "retries": {
        "description": "The new tries after a retryable error (429, 529, 5xx, a connection error), 0 to 10 (default: the option of the module, 2)",
        "type": "integer",
        "minimum": 0,
        "maximum": 10
      },
      "procedures": {
        "description": "The procedures that the model can use as tools: the procedure calls them and sends the results back",
        "maxItems": 64,
        "type": "array",
        "items": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]+(\\.[A-Za-z0-9_-]+)*$"
        }
      },
      "maxRounds": {
        "description": "The most requests to the model in one call, 1 to 64 (default 8)",
        "type": "integer",
        "minimum": 1,
        "maximum": 64
      }
    },
    "required": [
      "prompt"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "text": {
        "type": "string",
        "description": "The text of the last answer"
      },
      "model": {
        "type": "string",
        "description": "The model that answered"
      },
      "stopReason": {
        "type": "string",
        "description": "Why the model stopped: end_turn, max_tokens, stop_sequence, tool_use or another reason"
      },
      "usage": {
        "type": "object",
        "properties": {
          "inputTokens": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "The tokens of the input that the cache did not have"
          },
          "outputTokens": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "The tokens of the output, with the thinking"
          },
          "cacheReadInputTokens": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "The tokens of the input from the cache"
          },
          "cacheCreationInputTokens": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "The tokens of the input that went into the cache"
          }
        },
        "required": [
          "inputTokens",
          "outputTokens",
          "cacheReadInputTokens",
          "cacheCreationInputTokens"
        ],
        "additionalProperties": false,
        "description": "The tokens of the call"
      },
      "toolUses": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "The ID of the tool_use block"
            },
            "name": {
              "type": "string",
              "description": "The name of the tool"
            },
            "input": {
              "description": "The input of the call"
            }
          },
          "required": [
            "id",
            "name",
            "input"
          ],
          "additionalProperties": false
        },
        "description": "The tool_use blocks of the last answer that no procedure ran"
      },
      "toolCalls": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "description": "The ID of the tool_use block"
            },
            "name": {
              "type": "string",
              "description": "The name of the tool"
            },
            "procedure": {
              "type": "string",
              "description": "The key of the procedure"
            },
            "input": {
              "description": "The input that the model gave"
            },
            "isError": {
              "type": "boolean",
              "description": "True when the procedure failed: the model got the error"
            },
            "output": {
              "description": "The output of the procedure"
            },
            "error": {
              "description": "The error of the procedure",
              "type": "string"
            }
          },
          "required": [
            "id",
            "name",
            "procedure",
            "input",
            "isError"
          ],
          "additionalProperties": false
        },
        "description": "The calls of the procedure tools, in their sequence"
      },
      "rounds": {
        "type": "integer",
        "minimum": -9007199254740991,
        "maximum": 9007199254740991,
        "description": "The number of requests to the model"
      },
      "roundLimit": {
        "type": "boolean",
        "description": "True when maxRounds stopped the loop before the model stopped"
      }
    },
    "required": [
      "text",
      "model",
      "stopReason",
      "usage",
      "toolUses",
      "toolCalls",
      "rounds",
      "roundLimit"
    ],
    "additionalProperties": false
  }
}