Skip to content

E2bExecutionEnvironmentConfig

Base classes

Name Children Inherits
BaseExecutionEnvironmentConfig
exxec_config.configs
Base execution environment configuration.

⋔ Inheritance diagram

graph TD
  966624327["configs.E2bExecutionEnvironmentConfig"]
  2844377061["configs.BaseExecutionEnvironmentConfig"]
  330168112["schema.Schema"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  2844377061 --> 966624327
  330168112 --> 2844377061
  3879467795 --> 330168112
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseExecutionEnvironmentConfig

E2B execution environment configuration.

Executes code in E2B sandboxes for secure, ephemeral execution environments.

Source code in src/exxec_config/configs.py
class E2bExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """E2B execution environment configuration.

    Executes code in E2B sandboxes for secure, ephemeral execution environments.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "E2B Execution Environment"})
    type: Literal["e2b"] = Field("e2b", init=False)
    template: str | None = Field(
        default=None,
        title="E2B Template",
        examples=["python", "nodejs", "custom-template-id"],
    )
    """E2B template to use."""

    sandbox_timeout: float = Field(
        default=300.0,
        gt=0.0,
        title="Sandbox Lifetime",
        examples=[300.0, 600.0, 3600.0],
    )
    """How long the sandbox stays alive in seconds."""

    keep_alive: bool = Field(default=False, title="Keep Alive")
    """Keep sandbox running after execution."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> E2bExecutionEnvironment:
        """Create E2B execution environment instance."""
        from exxec.e2b_provider import E2bExecutionEnvironment

        return E2bExecutionEnvironment(
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            template=self.template,
            timeout=self.sandbox_timeout,
            default_command_timeout=self.default_command_timeout,
            keep_alive=self.keep_alive,
            language=self.language,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

keep_alive class-attribute instance-attribute

keep_alive: bool = Field(default=False, title='Keep Alive')

Keep sandbox running after execution.

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

sandbox_timeout class-attribute instance-attribute

sandbox_timeout: float = Field(
    default=300.0, gt=0.0, title="Sandbox Lifetime", examples=[300.0, 600.0, 3600.0]
)

How long the sandbox stays alive in seconds.

template class-attribute instance-attribute

template: str | None = Field(
    default=None, title="E2B Template", examples=["python", "nodejs", "custom-template-id"]
)

E2B template to use.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> E2bExecutionEnvironment

Create E2B execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> E2bExecutionEnvironment:
    """Create E2B execution environment instance."""
    from exxec.e2b_provider import E2bExecutionEnvironment

    return E2bExecutionEnvironment(
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        template=self.template,
        timeout=self.sandbox_timeout,
        default_command_timeout=self.default_command_timeout,
        keep_alive=self.keep_alive,
        language=self.language,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

:fa-brands-github: Show source on GitHub