***

title: AIAction
slug: /reference/python/relay/actions/ai-action
description: Action handle for an active AI agent session.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[call-ai]: /docs/server-sdks/reference/python/relay/call/ai

[base-action-interface]: /docs/server-sdks/reference/python/relay/actions

[stop]: /docs/server-sdks/reference/python/relay/actions/ai-action/stop

Returned from [`call.ai()`][call-ai]. Tracks
an active AI agent session on the call. Terminal states: `finished`, `error`.

<Note>
  AI sessions typically end when the call ends or when explicitly stopped. The
  terminal event may not carry a standard `state` field like other actions.
</Note>

Inherits all properties and methods from the
[base Action interface][base-action-interface] (`control_id`,
`is_done`, `completed`, `result`, `wait()`).

## **Properties**

No additional properties beyond the [base Action interface][base-action-interface].

## **Methods**

<CardGroup cols={2}>
  <Card title="stop" href="/docs/server-sdks/reference/python/relay/actions/ai-action/stop">
    Stop the AI agent session.
  </Card>
</CardGroup>

## **Example**

```python
from signalwire.relay import RelayClient

client = RelayClient(
    project="your-project-id",
    token="your-api-token",
    host="your-space.signalwire.com",
    contexts=["default"],
)

@client.on_call
async def handle_call(call):
    await call.answer()
    action = await call.ai(
        prompt={"text": "You are a helpful assistant."},
        ai_params={"temperature": 0.7},
    )

    # Wait for it to complete naturally
    event = await action.wait()

client.run()
```