Skip to main content
An agent can fill a template’s data fields while LithoBlocks supplies the layout. Templates reduce the block JSON the model needs to generate, but token savings and total cost depend on your model, prompt, and message volume; measure them in your own workflow.

Choose a connection

Use MCP when your client supports remote MCP and you want template discovery, authoring, sending, and history tools. Use a custom HTTP tool when you need a small, application-specific contract.

Establish the contract before sending

  1. Choose an approved template and test destination outside the model.
  2. Read GET /v1/templates/{id}/input-schema and validate the data your application will supply.
  3. Give the model only the content fields it should fill. Keep credentials, destination, template ID, and operation ID in application configuration.
  4. Require approval in your application before exposing or executing a send tool.
  5. Return a small structured result containing the outcome and request ID. Do not send raw receiver errors or credentials back to the model.

Reusable Python client

Download lithoblocks_client.py beside your adapter. It uses Python’s standard library, sets a 30-second request timeout, sends one configured destination, preserves a stable operation ID, and does not automatically retry writes or follow redirects. Set these server-side variables:
The example client expects a template with a Section containing {{message}}. Its only model-supplied input is message; use messages:create on the key. Read/discovery calls additionally need templates:read. The operation ID belongs to one intended send. Persist it in the job/workflow record and reuse it with the same message on retries. For concurrent jobs, create a configured client per job instead of sharing process environment. A new, approved message gets a new operation ID.

Framework adapters

LangChain, LlamaIndex, and CrewAI wrap this client as a tool. These examples focus on the adapter; configure your model provider and approval step using the framework’s own documentation and pin the dependency versions in your application’s lockfile. Use n8n AI for a workflow that validates structured model output before the HTTP step. Never assume an LLM knows your real template or channel IDs.