inis.run
Integrations

Pydantic AI

Pydantic AI toolset for Python agents.

Pydantic AI is the recommended Python agent framework for new projects. The inis integration wraps the Python SDK as a ready-made toolset — persistent session, shell, files, and code execution.

Beta. Supported Pydantic AI range: >=1.71,<3 (1.71 is the first release with the capabilities API). CI tests against the newest match, currently 2.x; earlier 1.x is supported but not exercised in CI.

Install

pip install inis-pydantic-ai

Usage

import asyncio

from inis import AsyncClient
from inis_pydantic_ai import inis_toolset
from pydantic_ai import Agent

async def main() -> None:
    # Create a persistent session first — the toolset never creates one
    client = AsyncClient()
    session = await client.sessions.create(egress_default="deny")
    toolset = inis_toolset(session_id=session.session_id)

    agent = Agent(
        "openai:gpt-4o",
        toolsets=[toolset],
        system_prompt="Run Python in the sandbox instead of guessing.",
    )

    try:
        result = await agent.run("Plot a histogram of [1, 2, 2, 3, 3, 3, 4] with matplotlib")
        print(result.output)
    finally:
        await toolset.aclose()
        await session.destroy()  # this app owns the session

asyncio.run(main())

What inis_toolset() provides

ToolDescription
execute_pythonRun Python in the sandbox. Raises on non-zero exit.
execute_shellRun a shell command in the persistent session. Raises on non-zero exit.
read_file / write_fileFile I/O under /workspace
list_filesList a directory (defaults to /workspace)

The toolset holds a persistent session for the whole conversation — multiple tool calls, and multiple agent.run() calls, share state. session_id is required; the toolset only ever attaches, never creates or destroys a session.

This is deliberately the smallest execution/file surface. Session administration (pause, resume, checkpoint, restore, expose_port, capture_artifacts) and unbounded stateless-execution sandbox creation (execute_once) are opt-in from inis_pydantic_ai.lifecycle — add them to toolsets=[...] only if your app wants the model to have that control.

For a capability-based alternative that follows the current pydantic-ai-harness sandbox contract (run_command, read_file, write_file, list_directory), see InisSandbox in inis_pydantic_ai.sandbox — same attach-only session rule, registered via Agent(capabilities=[...]) instead of toolsets=[...].

Configuration

inis_toolset(
    session_id="9hmquuxiz7qyqdqiwfvep",  # required
    api_key="inis_...",           # or $INIS_API_KEY
    base_url="https://api.inis.run",
)

vs LangChain

Pydantic AILangChain
Typed tools, minimal boilerplateLarger ecosystem, LangGraph for graphs
Best for new Python agent appsBest if you are already on LangChain

Both wrap the same Python SDK. Pick one — or use remote MCP and skip framework glue entirely.

On this page