To give a Cerebras agent an email address, define Gork Mail tools in Cerebras function-calling format and run an agent loop: the model reasons over gpt-oss-120b, your code executes gork_create_inbox, gork_send_email, and gork_read_emails against the Gork REST API. Ten minutes of wiring buys a personal email agent with a real inbox.
Why Cerebras for an Email Agent
Email agents live in loops: check the inbox, read anything new, decide, reply, repeat. Every cycle is inference tokens, so the economics of the loop matter as much as the smarts. Cerebras inference is built for exactly this shape — fast answers on an OpenAI-compatible API, which means the standard tools array and tool_calls loop work unchanged. No custom glue, no new SDK to learn.
One honest note first: chat.cerebras.ai is a model playground. It has no tool integrations, so you cannot plug email in there directly. The integration path is code, against the Cerebras inference API. That is what this post builds.
Step 1: Define the Gork Tools
Cerebras function calling takes the familiar OpenAI shape — a tools array of {type: "function", function: {...}} objects. Three tools cover the whole email life of an agent:
EMAIL_TOOLS = [
{
"type": "function",
"function": {
"name": "gork_create_inbox",
"description": "Provision a dedicated email inbox for the agent. Returns its address and inbox id.",
"parameters": {
"type": "object",
"properties": {
"username": {"type": "string", "description": "Lowercase username, e.g. support-bot"}
},
"required": ["username"],
},
},
},
{
"type": "function",
"function": {
"name": "gork_send_email",
"description": "Send an email from the agent inbox.",
"parameters": {
"type": "object",
"properties": {
"inbox_id": {"type": "string"},
"to": {"type": "string"},
"subject": {"type": "string"},
"text": {"type": "string"},
},
"required": ["inbox_id", "to", "subject", "text"],
},
},
},
{
"type": "function",
"function": {
"name": "gork_read_emails",
"description": "Search everything the inbox has received.",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string"}
},
"required": ["query"],
},
},
},
]Step 2: Run the Agent Loop
The loop is the standard one from the Cerebras tool-use docs: send messages plus tools, execute whatever the model requests against Gork's REST API, feed results back as tool messages, repeat until the model answers directly.
import json, os, requests
from cerebras.cloud.sdk import Cerebras
cerebras = Cerebras(api_key=os.environ["CEREBRAS_API_KEY"])
GORK = "https://api.gork.email/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['GORK_API_KEY']}"}
def run_tool(name, args):
if name == "gork_create_inbox":
r = requests.post(f"{GORK}/inboxes", headers=HEADERS,
json={"username": args["username"]})
return r.json()["data"]
if name == "gork_send_email":
r = requests.post(f"{GORK}/messages/send", headers=HEADERS, json={
"inboxId": args["inbox_id"], "to": [args["to"]],
"subject": args["subject"], "text": args["text"]})
return r.json()["data"]
if name == "gork_read_emails":
r = requests.get(f"{GORK}/messages", headers=HEADERS,
params={"q": args["query"]})
return r.json()["data"]
raise ValueError(f"Unknown tool: {name}")
messages = [
{"role": "system", "content": "You are an email agent with Gork Mail tools."},
{"role": "user", "content": "Give the support agent an email address."},
]
while True:
resp = cerebras.chat.completions.create(
model="gpt-oss-120b", messages=messages, tools=EMAIL_TOOLS)
msg = resp.choices[0].message
if not msg.tool_calls:
print("Agent:", msg.content)
break
messages.append(msg.model_dump())
for call in msg.tool_calls:
output = run_tool(call.function.name, json.loads(call.function.arguments))
messages.append({"role": "tool", "tool_call_id": call.id,
"content": json.dumps(output)})Ask for an inbox and the model calls gork_create_inbox, your code hits POST /v1/inboxes, and the address comes back into context — a real address on @try.gork.email, or your own verified domain on paid plans.
Step 3: Keep the Agent From Burning Your Domain
A fast model in a tight loop is exactly the thing that can spiral: same reply sent forty times, a hallucinated recipient list, a prompt-injected instruction to blast. Gork enforces the brakes server-side so your agent code does not have to:
- Daily caps bound any loop to a single day of damage.
- Suppressions are absolute — bounces, complaints, and unsubscribes fail fast with
422 recipient_suppressed. - A bulk tripwire pauses the workspace if it blasts 50+ new recipients in 10 minutes.
- A reputation kill switch pauses sending if complaints or bounces spike.
Add one line to your system prompt as well: never invent message ids, and stop and report on recipient_suppressed instead of retrying.
What You Get
A personal email agent that runs on Cerebras inference and owns a real inbox: it provisions addresses over the API, reads what arrives, searches its own history, and replies in-thread. Start free with 2 inboxes and 1,000 emails a month — grab a Gork API key and give your agent its address today.
Ready to give your AI agent an email address?
Real inboxes, conversation threads, search, and native MCP tools. Deploy your first inbox in seconds.