Read one message, draft a reply with a local model, review it, then create the exact draft in Gmail. You send it yourself.
The complete Python example lives in the docs. It uses the general Soterias SDK; Gmail and LangChain are optional application dependencies.
from soterias import ModelUsage, Soterias
sdk = Soterias.local(workflow="personal-assistant")
try:
def usage(answer):
reported = answer.usage_metadata or {}
return ModelUsage("ollama", input_tokens=reported.get("input_tokens"),
output_tokens=reported.get("output_tokens"))
answer = sdk.invoke_model(chain.invoke, usage, inputs)
print(answer.content)
print(sdk.metrics.snapshot().data())
finally:
sdk.close()Run with sample text
Install the matching updated Soterias SDK, Ollama and the optional example dependencies. Run the example from a new private working directory.
python -m pip install -r gmail-requirements.txt
ollama pull qwen3.5:4b
python gmail_assistant.py --sampleDownload requirements.txt beside the Python file. --sample runs a real local model on public sample text and reports native call duration and the provider's token counts. It makes no Gmail call and creates no draft. Set OLLAMA_MODEL or OLLAMA_BASE_URL to use your own local setup. No model is required by Soterias itself.
Use your mailbox
Enable the Gmail API in your own Google Cloud project, create a desktop OAuth client, and save its downloaded configuration as credentials.json in your private working directory. Use a test mailbox first. The example requests gmail.readonly and gmail.compose, then saves the OAuth session as gmail-token.json. Keep both files out of source control and the model context.
python gmail_assistant.py --list
python gmail_assistant.py --message-id YOUR_SELECTED_MESSAGE_IDThe example reads only the selected message during reply generation. It accepts a bounded plain-text body, gives the model no Gmail tools or credentials, and displays the recipient, subject and proposed content. Type the displayed DRAFT command with its content digest to create that draft. It does not send mail or retry draft creation automatically. If a request times out, check Gmail before retrying.
This recipe uses ordinary observation. The confirmation is an application prompt, not a Soterias signed approval. Direct Gmail callbacks are not restricted by Soterias warrants and produce no broker-signed Gmail receipt. Use the protected Rust execution APIs for supported resources that require enforced policy, exact signed approval and independently verified receipts. See application integration.
Temperature0 and a fixed seed are configuration choices, not a guarantee of identical model output. Draft quality remains unverified; review its facts and commitments yourself. Live Gmail acceptance requires an explicitly authorised test mailbox; it has not been run for this recipe.