> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# execute • AI Agent SDK

> execute: Execute code in sandboxed environment.

# execute

<div className="flex items-center gap-2">
  <Badge color="purple">Method</Badge>
</div>

> This is a method of the [**CodeAgent**](../classes/CodeAgent) class in the [**code\_agent**](../modules/code_agent) module.

Execute code in sandboxed environment.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def execute(code: str, language: str) -> Dict[str, Any]
```

## Parameters

<ParamField query="code" type="str" required={true}>
  Code to execute
</ParamField>

<ParamField query="language" type="str" required={false} default="'python'">
  Programming language \*\*kwargs: Additional execution options
</ParamField>

### Returns

<ResponseField name="Returns" type="Dict[str, Any]">
  Dictionary with stdout, stderr, return\_code, and execution\_time
</ResponseField>

## Used By

* [`CodeAgent.execute_code`](../functions/CodeAgent-execute_code)
* [`CodeAgent.aexecute`](../functions/CodeAgent-aexecute)
* [`MiddlewareManager.execute_model_call`](../functions/MiddlewareManager-execute_model_call)
* [`MiddlewareManager.execute_tool_call`](../functions/MiddlewareManager-execute_tool_call)
* [`HookRunner.execute_sync`](../functions/HookRunner-execute_sync)

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agent/code_agent.py#L217">
  `praisonaiagents/agent/code_agent.py` at line 217
</Card>
