Use this file to discover all available pages before exploring further.
The Nonhumans Python SDK brings your AI agent a complete digital identity without the infrastructure overhead. In a few lines of Python your agent gains a real email inbox, crypto and fiat wallet, vector memory, credential vault, LLM access, always-on compute, and more — all through a single, consistent API key.
Python 3.9 or later is required. The SDK ships with type hints throughout, so you get autocomplete and static analysis in editors like VS Code and PyCharm.
Your agent has a real email address (e.g. alice@nonhumans.ai). Read, send, and reply to messages programmatically.
# Send an emailagent.email.send( to="hiring@acme.com", subject="Application received", body="Thank you for applying. We will be in touch shortly.",)# List recent unread messagesinbox = agent.email.list(limit=20, unread=True)for message in inbox: print(message.subject, message.from_address)# Fetch a single message by IDmessage = agent.email.get("msg_01hx...")# Reply to a threadagent.email.reply( "msg_01hx...", body="Following up on your earlier question — see details below.",)
Call language models through the same API key — no separate provider accounts required.
# Chat completionresponse = agent.models.chat( model="gpt-4o", messages=[ {"role": "system", "content": "You are a helpful recruiting assistant."}, {"role": "user", "content": "Summarise this resume in three bullet points."}, ], temperature=0.3,)print(response.choices[0].message.content)# Generate embeddingsembedding = agent.models.embed( model="text-embedding-3-small", input="Candidate has 5 years of Python experience.",)print(len(embedding.data[0].embedding)) # e.g. 1536
Securely store and retrieve API keys, tokens, and other secrets your agent needs at runtime.
# Store a secretagent.vault.set("stripe_key", "sk_live_...")# Retrieve a secretstripe_key = agent.vault.get("stripe_key")# List all stored secret names (values are never returned in list)keys = agent.vault.list()# ['stripe_key', 'openai_key', 'twilio_sid']# Delete a secretagent.vault.delete("stripe_key")
Your agent has a real phone number it can use to send texts and make outbound calls.
# Send an SMSagent.phone.sms( to="+14155550199", body="Your verification code is 849201.",)# Initiate an outbound callcall = agent.phone.call( to="+14155550199", script="Hello, this is Alice calling from Acme to confirm your appointment.",)
For async frameworks like FastAPI, asyncio, or LangChain async chains, use AsyncNonhumans. Every method is await-able and the interface mirrors the sync client exactly.
import asynciofrom nonhumans import AsyncNonhumansimport osagent = AsyncNonhumans(api_key=os.environ['NONHUMANS_KEY'])async def process_inbox(): emails = await agent.email.list(unread=True, limit=50) for email in emails: # Score with an LLM score = await agent.models.chat( model="gpt-4o", messages=[ {"role": "system", "content": "Rate this application 1–10."}, {"role": "user", "content": email.body}, ], ) # Store result await agent.memory.store( content=f"Score for {email.from_address}: {score.choices[0].message.content}", metadata={"email_id": email.id}, ) # Reply await agent.email.reply(email.id, body="Thanks for your application!")asyncio.run(process_inbox())
Use AsyncNonhumans inside any async framework — FastAPI route handlers, Celery async tasks, or standalone asyncio scripts — without any extra configuration.
All SDK methods raise NonhumansError on failure. Inspect status, code, and message to handle errors cleanly.
from nonhumans import Nonhumans, NonhumansErrorimport osagent = Nonhumans(api_key=os.environ['NONHUMANS_KEY'])try: agent.email.send( to="not-an-email", subject="Test", body="Hello", )except NonhumansError as e: print(f"[{e.status}] {e.code}: {e.message}") # e.g. [422] validation_error: 'to' must be a valid email address
In async code, use try/except inside your async functions or attach an exception handler to your event loop to avoid silent task failures.
This example shows an agent that monitors its inbox for job applications, scores them, stores the result in memory, and sends a personalised reply.
from nonhumans import Nonhumans, NonhumansErrorimport osagent = Nonhumans(api_key=os.environ['NONHUMANS_KEY'])def process_applications(): # 1. Fetch unread emails emails = agent.email.list(unread=True, limit=50) print(f"Found {len(emails)} new application(s).") for email in emails: try: # 2. Score the application with an LLM score = agent.models.chat( model="gpt-4o", messages=[ { "role": "system", "content": ( "You are a recruiting assistant. " "Rate the candidate 1–10 and give a one-sentence reason." ), }, {"role": "user", "content": email.body}, ], temperature=0, ) score_text = score.choices[0].message.content # 3. Persist to memory agent.memory.store( content=f"Application from {email.from_address}: {score_text}", metadata={"email_id": email.id, "from": email.from_address}, ) # 4. Send a personalised reply agent.email.reply( email.id, body=( "Hi,\n\n" "Thank you for reaching out. We have received your application " "and will review it shortly.\n\n" "Best,\nAlice" ), ) except NonhumansError as e: print(f"Failed to process {email.id}: {e.message}")if __name__ == "__main__": process_applications()