Skip to content

SDK API Reference

Full reference for the sec_gemini Python package. All methods are async unless noted.

from sec_gemini import SecGemini
MethodDescription
SecGemini(api_key, host=...)Create a client. host defaults to the production API Hub.
await client.start()Connect to the server and authenticate.
await client.close()Close the connection.
async with SecGemini(...) as client:Context manager — calls start() / close() automatically.
MethodReturnsDescription
await client.sessions.create()SessionCreate a new session
await client.sessions.list()list[Session]List all sessions
await client.sessions.get(session_id)SessionGet session by ID (cached)
await client.sessions.delete(session_id)boolDelete a session
MethodReturnsDescription
await client.mcps.list()list[McpServer]List account-level MCP servers
await client.mcps.add(name, uri)McpServer | NoneRegister a new MCP server
await client.mcps.remove(id)boolRemove an MCP server by ID
MethodReturnsDescription
await client.skills.list()list[Mcp]List all available skills (runtime)
await client.skills.list_uploaded()list[str]List names of user-uploaded skills
await client.skills.upload(name, content)NoneUpload a skill
await client.skills.get(name)strGet skill content by name
await client.skills.delete(name)boolDelete an uploaded skill

Returned by client.sessions.create() or client.sessions.list().

PropertyTypeDescription
session.idstrSession ID
session.namestrDisplay name (auto-generated from first prompt)
session.statusstrStatus string (e.g. "RUNNING", "COMPLETED")
session.status_intintStatus as protobuf enum integer
session.created_atfloatCreation timestamp
session.is_emptyboolTrue if no name has been set
MethodReturnsDescription
await session.prompt(text, meta=None)NoneSend a prompt to start the agent
await session.cancel()NoneCancel the running session
await session.pause()NonePause the session
await session.resume()NoneResume a paused session
await session.delete()boolDelete the session
session.add_status_callback(fn)NoneRegister fn(session_id, status) callback
MethodReturnsDescription
async for msg in session.messages.stream()AsyncIterator[dict]Stream messages from the server

Each yielded dict contains:

KeyTypeDescription
message_typestre.g. "MESSAGE_TYPE_RESPONSE"
contentstrMessage text content
titlestrShort label
source_typestr"SOURCE_TYPE_USER", "SOURCE_TYPE_AGENT", "SOURCE_TYPE_SYSTEM"
render_typestr"RENDER_TYPE_MARKDOWN", "RENDER_TYPE_JSON", etc.
mime_typestrContent MIME type
idstrUnique message ID
timestampstrISO timestamp
snapshot_idstrMessage snapshot ID
MethodReturnsDescription
await session.files.upload(file_path, content_type="application/octet-stream")NoneUpload a local file
await session.files.list()list[FileInfo]List uploaded files
await session.files.delete(filename)boolDelete a file by name

FileInfo fields: filename, url.

MethodReturnsDescription
await session.mcps.list()list[Mcp]List MCPs active in this session
await session.mcps.set(mcps)boolSet active MCPs (list of server URLs)

Mcp fields: name, uri, status, tools (list), skills (list), id.

MethodReturnsDescription
await session.confirmations.set_config(always_ask)boolSet confirmation behavior
await session.confirmations.get_info()ConfirmationInfo | NoneGet pending confirmation details
await session.confirmations.send_tool_confirmation(action_id, confirmed)NoneApprove or deny a tool call
ConstantDescription
MESSAGE_TYPE_PROMPTUser’s input
MESSAGE_TYPE_RESPONSEAgent’s final answer
MESSAGE_TYPE_THOUGHTAgent’s internal reasoning
MESSAGE_TYPE_PROGRESSTransient status update
MESSAGE_TYPE_TOOL_CALLAgent executing a tool
MESSAGE_TYPE_TOOL_RESULTTool execution output
MESSAGE_TYPE_TOOL_CONFIRMATION_REQUESTWaiting for user approval
MESSAGE_TYPE_TOOL_CONFIRMATION_RESPONSEUser’s confirmation decision
MESSAGE_TYPE_CLARIFICATION_REQUESTAgent needs more info
MESSAGE_TYPE_CLARIFICATION_RESPONSEUser’s clarification
MESSAGE_TYPE_TASK_LISTInternal task hierarchy dump
MESSAGE_TYPE_MEMORY_STATEShared context dump
MESSAGE_TYPE_SESSION_NAMEAuto-generated session name
MESSAGE_TYPE_SKILL_LOADEDSkill loaded notification
MESSAGE_TYPE_AGENT_IS_DONESynthetic: session completed
MESSAGE_TYPE_FAILUREAgent job failed
MESSAGE_TYPE_LOGDiagnostic log
MESSAGE_TYPE_DEBUGDebug info
MESSAGE_TYPE_WARNINGWarning
MESSAGE_TYPE_ERRORError
MESSAGE_TYPE_AGENT_RESPONSEAgent response (rendered same as RESPONSE)
MESSAGE_TYPE_NOTIFICATIONSystem notification
StatusDescription
NOT_INITIALIZEDSession created but not yet started
PENDINGWaiting to be scheduled
RUNNINGAgent is actively working
PAUSEDSession paused by user
COMPLETEDAgent finished successfully
FAILEDAgent encountered a fatal error
CANCELEDSession canceled by user
WAITING_FOR_TOOL_CONFIRMATIONAgent paused, waiting for tool approval
WAITING_FOR_CLARIFICATIONAgent paused, waiting for user input
MAX_ATTEMPTS_EXCEEDEDAgent exceeded maximum retry attempts

Active statuses: RUNNING, PENDING, WAITING_FOR_TOOL_CONFIRMATION, WAITING_FOR_CLARIFICATION

Terminal statuses: COMPLETED, FAILED, CANCELED, MAX_ATTEMPTS_EXCEEDED

from sec_gemini import (
SdkError, # Base exception
AuthenticationError, # Invalid or expired API key
ConnectionLostError, # gRPC connection dropped
SessionError, # Session creation/operation failed
FileOperationError, # File upload/delete failed
SkillError, # Skill upload/get failed
ProtocolError, # Unexpected server response
NotBoundError, # Operation on unbound object
ByotError, # BYOT operation failed
ByotAuthError, # BYOT hub authentication failed
ByotNotAvailableError, # BYOT dependencies not installed (requires [tools] extra)
)

All exceptions inherit from SdkError.