Sec-Gemini Python SDK
Python SDK, terminal client, MCP server, and BYOT tunnel for the Sec-Gemini security AI agent.
Install
pip install sec-gemini
Set your API key
Get an API key from secgemini.google/keys, then:
sec-gemini set-key
What's included
- Terminal UI (
sec-gemini) -- interactive chat with the agent - Python SDK -- async client for programmatic access
- MCP server (
sec-gemini-mcp) -- expose the SDK to AI assistants - BYOT client (
sec-gemini-byot) -- connect local tools to the cloud agent - Security policies & BYOK (
sec-gemini policy,sec-gemini config) -- declarative CEL scope guardrails and Bring-Your-Own Gemini/VirusTotal API keys - 21 baseline tools in 4 categories: file operations (including sandbox transfer), shell & task management, Python execution, and network analysis
Quick start
Terminal UI -- interactive chat with the agent:
# Standard launch
sec-gemini
# Launch with local MCP scripts (BYOT "magic" mode)
sec-gemini --mcp ./my_tools.py
Tip: Local scripts passed via
--mcpappear in the "Bring Your Own MCP" section and are automatically functional in new sessions. Requiresfastmcpinstalled.
Python SDK -- programmatic access:
import asyncio
from sec_gemini.services.backend import Backend
async def main():
backend = Backend(api_key="YOUR_KEY")
await backend.connect()
session = await backend.create_session()
await backend.send_prompt(session.session_id, "Analyze example.com")
async for msg in backend.stream_messages(session.session_id):
print(f"[{msg.message_type}] {msg.content[:200]}")
await backend.close()
asyncio.run(main())
Model selection -- opt in to a different Gemini model per session. One
knob sets every agent role; config.fast_model / config.planner_model /
config.reviewer_model / config.self_reflection_model /
config.escalation_model / config.refusal_retry_model tune them
independently. Model availability
depends on the deployment you talk to (the cyber model is internal-only and
automatically enforces the default-deny-internet-access security policy):
sec-gemini --model gemini-4-argon-cyber-permissive -p "Triage this sample"
await backend.send_prompt(
session.session_id,
"Triage this sample",
meta={"config.model": "gemini-4-argon-cyber-permissive"},
)
MCP server -- expose the SDK to AI assistants (Claude Code, Gemini CLI):
sec-gemini-mcp # stdio (default)
sec-gemini-mcp --transport streamable-http --port 8000 # HTTP on 127.0.0.1
- Results include
session_idandsession_url(web UI link). Turn results addoutcome(completed,failed,needs_input,running, ...) andfinal_response. Errors havestatus: "error"pluserror_code,retryableandhint. - Deep analyses can take tens of minutes.
prompt_and_collectandcollect_messageswait up totimeoutseconds (default 600, set withSEC_GEMINI_MCP_TIMEOUT). Ifoutcomeisrunning, callcollect_messageswith the samesession_idto keep waiting. Keeptimeoutbelow your MCP client's own request timeout. - Health: the
health_checktool verifies API connectivity. HTTP transports also serveGET /healthz, a liveness check that doesn't need auth. - HTTP transports always bind 127.0.0.1 and reject requests whose
HostorOriginis not loopback, which protects against DNS rebinding.
BYOT -- connect local tools to the cloud agent:
# Minimal: connect with base local tools (enabled by default)
uvx --from sec-gemini sec-gemini-byot
# Connect additional MCPs and local skills (a SKILL.md file or a directory of skills)
uvx --from sec-gemini sec-gemini-byot --mcp ./my_tools.py --skills ./my_skill/SKILL.md
uvx --from sec-gemini sec-gemini-byot --skills ~/my-skills
Security notice: BYOT base tools (shell, file, Python, JavaScript) run directly on your machine with no sandboxing. Run inside a container or VM. See the BYOT Guide for details.
Documentation
Full documentation, guides, and API reference: secgemini.google
Requirements
- Python 3.12+
- uv (recommended for development)
License
Internal -- see repository root for license details.
Metadata
Release files for sec-gemini 3.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sec_gemini-3.5.0.tar.gz | 374.7 kB | Without provenance | Details for sec_gemini-3.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sec_gemini-3.5.0-py3-none-any.whl | Python 3 | none | any | Details for sec_gemini-3.5.0-py3-none-any.whl |
Total release size: 831.3 kB
Release files / sec_gemini-3.5.0.tar.gz
| Download URL | sec_gemini-3.5.0.tar.gz |
|---|---|
| Size | 374.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e1fceb7c938b0903302dc94c4d60401ecf147ed7eb0799e68a227cd8767916db
|
|
BLAKE2b-256 checksum How to use checksums |
b3f35bdca5f1363cce73b36e96168652630cede0c0e2599e38781a0503959d22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / sec_gemini-3.5.0-py3-none-any.whl
| Download URL | sec_gemini-3.5.0-py3-none-any.whl |
|---|---|
| Size | 456.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a611a4a4d20035bae95e31b26ce0ab17ad6db023dcebf216b53c78fe0e3b738
|
|
BLAKE2b-256 checksum How to use checksums |
c3978e6799d09db5c32c1b480c12b7c1d6c251c887bd9308df613eff53a44df6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for sec-gemini 3.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.