Using Hermes as a Python Library
Using Hermes as a Python Library
Start with meaning, then move to detail.
This lesson explains Using Hermes as a Python Library as part of Hermes internals and extension points. You will learn what it does, when it matters, and the smallest safe test that proves it works.
If you are new, do not memorize names. Focus on three questions: what problem does this solve, what access does it need, and how can you verify the result?
For practice, inspect the first example, identify its effects, run it on test data, and compare the result with the source claim.
For advanced readers, inspect Installation, Basic Usage, Full Conversation Control, then verify failure modes and version compatibility.
Know Python, Git, and basic project structure before changing code.
A clear outcome before you read.
- Understand Using Hermes as a Python Library without assumed prior knowledge.
- Separate the source description from what still needs testing in your environment.
- Read the first command and identify its inputs and outputs before copying it.
Short definitions before the details.
- Tool
- A structured action the agent can call to read or change something.
Embed AIAgent in your own Python scripts, web apps, or automation pipelines — no CLI required
What does the source say, and in what order?
- 01Installation
Start here to understand the core idea or structure.
- 02Basic Usage
Read this after the foundation, then connect it to the previous step.
- 03Full Conversation Control
Read this after the foundation, then connect it to the previous step.
- 04Configuring Tools
Read this after the foundation, then connect it to the previous step.
- 05Multi-turn Conversations
Read this after the foundation, then connect it to the previous step.
- 06Saving Trajectories
Read this after the foundation, then connect it to the previous step.
- 07Custom System Prompts
Read this after the foundation, then connect it to the previous step.
- 08Batch Processing
Read this after the foundation, then connect it to the previous step.
- 09Integration Examples
Read this after the foundation, then connect it to the previous step.
- 10FastAPI Endpoint
Finish here to verify the result and special cases.
Copy only after you understand the effect.
git clone https://github.com/NousResearch/hermes-agent.git
cd hermes-agent
uv sync`chat()` handles the full conversation loop internally — tool calls, retries, everything — and returns just the final text response.
:::warning
Always set `quiet_mode=True` when embedding Hermes in your own code. Without it, the agent prints CLI spinners, progress indicators, and other terminal output that will clutter your application's output.
:::
---
## Full Conversation Control
For more control over the conversation, use `run_conversation()` directly. It returns a dictionary with the full response, message history, and metadata:The returned dictionary contains:
- **`final_response`** — The agent's final text reply
- **`messages`** — The complete message history (system, user, assistant, tool calls)
(The `task_id` you pass in is stored on the agent instance for VM isolation but isn't echoed back in the return dict.)
You can also pass a custom system message that overrides the ephemeral system prompt for that call:Read the first command and identify its inputs and outputs before copying it.
Match every command to your installed Hermes version, review the files and accounts it can reach, and use non-sensitive data for the first test. If this explanation differs from the source, the official source wins.