# 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 in Studio provides a pre-configured API call with your agent's identifiers already populated.

## Prerequisites [#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 [#get-the-embed-code]

To get the API call for your agent:

1. In Agent Studio, select **Agents** from the sidebar.
2. From the agent list, open the **Actions** menu for your 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).

<CalloutContainer type="info">
  <CalloutTitle>
    Authentication
  </CalloutTitle>

  <CalloutDescription>
    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.
  </CalloutDescription>
</CalloutContainer>

## Sample code [#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.

<Tabs defaultValue="rest-api" groupId="ai-rest-sample-language">
  <TabsList>
    <TabsTrigger value="rest-api">
      REST API
    </TabsTrigger>

    <TabsTrigger value="python">
      Python
    </TabsTrigger>

    <TabsTrigger value="nodejs">
      Node.js
    </TabsTrigger>
  </TabsList>

  <TabsContent value="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>"
        }
      }'
    ```
  </TabsContent>

  <TabsContent value="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)
    ```
  </TabsContent>

  <TabsContent value="nodejs">
    ```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));
    ```
  </TabsContent>
</Tabs>

<CalloutContainer type="info">
  <CalloutTitle>
    About pipeline_id
  </CalloutTitle>

  <CalloutDescription>
    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 in Studio.
  </CalloutDescription>
</CalloutContainer>

## See also [#see-also]

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