# Connect your agent (/en/ai/studio/deploy/connect-agent)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

After publishing your agent, you can integrate it into your applications using the Conversational AI Engine API. The **Embed** option provides a pre-configured API call with your agent's identifiers already populated.

## Prerequisites

- A published agent.
- Agora [Customer ID and Customer Secret](/en/api-reference/api-ref/conversational-ai/authentication#generate-customer-id-and-customer-secret) for API authentication.

## Get the embed code

To get the API call for your agent:

1. In the navigation sidebar, select **Agents**.
2. From the agent list, open the **Action** menu for your published agent and select **Embed Agent**.
3. Copy the generated code snippet. It includes your agent's `name`, `pipeline_id`, channel settings, and a valid RTC `token`.

Use this as the starting point for integrating the agent into your backend service. For full API reference, see [Start a conversational AI agent](/en/api-reference/api-ref/conversational-ai/join).

> **Info: Authentication**
>
> This endpoint requires [Basic Auth](/en/api-reference/api-ref/conversational-ai/authentication). Generate a Base64-encoded credential with your Customer ID and Customer Secret. The generated code snippet includes an RTC token under `properties` which is valid for 24 hours.

## Sample code

The following examples show how to start an agent call using your embed credentials. Replace `<base64Credentials>` with your Base64-encoded Agora Customer ID and Customer Secret.

**REST API**

```bash
curl --request POST \
  --url https://api.agora.io/api/conversational-ai-agent/v2/projects/<appid>/join \
  --header 'Authorization: Basic <base64Credentials>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "<agent_name>",
    "pipeline_id": "<pipeline_id>",
    "properties": {
      "channel": "<channel_name>",
      "agent_rtc_uid": "<agent_rtc_uid>",
      "remote_rtc_uids": ["*"],
      "token": "<token>"
    }
  }'
```

**Python**

```python
import requests

url = "https://api.agora.io/api/conversational-ai-agent/v2/projects/<appid>/join"

payload = {
    "name": "<agent_name>",
    "pipeline_id": "<pipeline_id>",
    "properties": {
        "channel": "<channel_name>",
        "agent_rtc_uid": "<agent_rtc_uid>",
        "remote_rtc_uids": ["*"],
        "token": "<token>"
    }
}

headers = {
    "Content-Type": "application/json",
    "Authorization": "Basic <base64Credentials>"
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)
```

**Node.js**

```js
const options = {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Basic <base64Credentials>'
    },
    body: JSON.stringify({
        name: '<agent_name>',
        pipeline_id: '<pipeline_id>',
        properties: {
            channel: '<channel_name>',
            agent_rtc_uid: '<agent_rtc_uid>',
            remote_rtc_uids: ['*'],
            token: '<token>'
        }
    })
};

fetch('https://api.agora.io/api/conversational-ai-agent/v2/projects/<appid>/join', options)
    .then(res => res.json())
    .then(res => console.log(res))
    .catch(err => console.error(err));
```

> **Info: About pipeline\_id**
>
> The `pipeline_id` in the embed code is the internal identifier for your published agent configuration. It is automatically populated when you copy the embed code from the **Embed Agent** option.

## See also

- [Webhooks](../../build/handle-runtime-events/webhooks)
