> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-devupd-1765394015-eccef47.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Riza Code Interpreter

> The Riza Code Interpreter is a WASM-based isolated environment for running Python or JavaScript generated by AI agents.

In this notebook we'll create an example of an agent that uses Python to solve a problem that an LLM can't solve on its own:
counting the number of 'r's in the word "strawberry."

Before you get started grab an API key from the [Riza dashboard](https://dashboard.riza.io). For more guides and a full API reference
head over to the [Riza Code Interpreter API documentation](https://docs.riza.io).

Make sure you have the necessary dependencies installed.

```python theme={null}
pip install -qU langchain-community rizaio
```

Set up your API keys as an environment variable.

```python theme={null}
%env ANTHROPIC_API_KEY=<your_anthropic_api_key_here>
%env RIZA_API_KEY=<your_riza_api_key_here>
```

```python theme={null}
from langchain_community.tools.riza.command import ExecPython
```

```python theme={null}
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import ChatPromptTemplate
```

Initialize the `ExecPython` tool.

```python theme={null}
tools = [ExecPython()]
```

Initialize an agent using Anthropic's Claude Haiku model.

```python theme={null}
llm = ChatAnthropic(model="claude-haiku-4-5-20251001", temperature=0)

prompt_template = ChatPromptTemplate.from_messages(
    [
        (
            "system",
            "You are a helpful assistant. Make sure to use a tool if you need to solve a problem.",
        ),
        ("human", "{input}"),
        ("placeholder", "{agent_scratchpad}"),
    ]
)

agent = create_tool_calling_agent(llm, tools, prompt_template)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
```

```python theme={null}
# Ask a tough question
result = agent_executor.invoke({"input": "how many rs are in strawberry?"})
print(result["output"][0]["text"])
```

```output theme={null}
> Entering new AgentExecutor chain...

Invoking: `riza_exec_python` with `{'code': 'word = "strawberry"\nprint(word.count("r"))'}`
responded: [{'id': 'toolu_01JwPLAAqqCNCjVuEnK8Fgut', 'input': {}, 'name': 'riza_exec_python', 'type': 'tool_use', 'index': 0, 'partial_json': '{"code": "word = \\"strawberry\\"\\nprint(word.count(\\"r\\"))"}'}]

3
[{'text': '\n\nThe word "strawberry" contains 3 "r" characters.', 'type': 'text', 'index': 0}]

> Finished chain.


The word "strawberry" contains 3 "r" characters.
```

***

<Callout icon="pen-to-square" iconType="regular">
  [Edit the source of this page on GitHub.](https://github.com/langchain-ai/docs/edit/main/src/oss/python/integrations/tools/riza.mdx)
</Callout>

<Tip icon="terminal" iconType="regular">
  [Connect these docs programmatically](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
</Tip>
