***

title: AIAction
slug: /reference/typescript/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/typescript/relay/call/ai

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

[stop]: /docs/server-sdks/reference/typescript/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] (`controlId`,
`isDone`, `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/typescript/relay/actions/ai-action/stop">
    Stop the AI agent session.
  </Card>
</CardGroup>

## **Example**

```typescript {11}
import { RelayClient } from '@signalwire/sdk';

const client = new RelayClient({
  project: process.env.SIGNALWIRE_PROJECT_ID!,
  token: process.env.SIGNALWIRE_TOKEN!,
  contexts: ['default']
});

client.onCall(async (call) => {
  await call.answer();
  const action = await call.ai({
    prompt: { text: 'You are a helpful assistant.' },
    aiParams: { temperature: 0.7 },
  });

  // Wait for it to complete naturally
  const event = await action.wait();
});

await client.run();
```