> ## Documentation Index
> Fetch the complete documentation index at: https://docs.retellai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SDKs

> Official SDKs for Node.js and Python to integrate Retell AI phone agents into your applications

## Overview

Retell provides official SDKs for Node.js and Python to simplify integration with our platform. While you can use our [REST API](/api-references/create-phone-call) directly, our SDKs offer:

* **Type safety**: Full TypeScript support with autocomplete
* **Simplified authentication**: Built-in API key handling
* **Error handling**: Structured error responses with detailed messages
* **Reduced boilerplate**: Cleaner, more maintainable code

## Available SDKs & Requirements

### Node.js TypeScript SDK

* **Package**: [retell-sdk on NPM](https://www.npmjs.com/package/retell-sdk)
* **Requirements**: Node.js version 18.10.0 or higher
* **Features**: Full TypeScript support, async/await, promise-based API

### Python SDK

* **Package**: [retell-sdk on PyPI](https://pypi.org/project/retell-sdk/)
* **Requirements**: Python 3.7 or higher
* **Features**: Type hints, async support, comprehensive error handling

<Steps>
  <Step title="Get Your API Key">
    Navigate to the "API Keys" tab in your dashboard to obtain your API key.

    <Frame>
      <img height="200" src="https://mintcdn.com/retellai/gY538VnArOndFhp0/images/api_key.png?fit=max&auto=format&n=gY538VnArOndFhp0&q=85&s=eafc7807d7c80f3268ed2f2a1b9d2ebf" alt="API Keys tab in Retell dashboard showing where to find and copy your API key" data-path="images/api_key.png" />
    </Frame>
  </Step>

  <Step title="Install the SDK">
    Choose your preferred language and install the SDK:

    <CodeGroup>
      ```bash Node Client theme={null}
      npm i retell-sdk
      ```

      ```bash Python Client theme={null}
      pip install retell-sdk
      ```
    </CodeGroup>
  </Step>

  <Step title="Initialize the Client">
    Create a new client instance using your API key:

    <CodeGroup>
      ```typescript Node Client theme={null}
      import Retell from 'retell-sdk';

      const retellClient = new Retell({
        apiKey: "YOUR_API_KEY",
      });
      ```

      ```python Python Client theme={null}
      from retell import Retell

      retell_client = Retell(
        api_key="YOUR_API_KEY"
      )
      ```
    </CodeGroup>
  </Step>

  <Step title="Make API Calls">
    Here's an example of making a phone call using the SDK:

    <CodeGroup>
      ```typescript Node Client theme={null}
      try {
        const response = await retellClient.call.createPhoneCall({
          from_number: '+14157774444',
          to_number: '+12137774445',
        });
        console.log('Call initiated:', response);
      } catch (error) {
        console.error('Error making call:', error);
      }
      ```

      ```python Python Client theme={null}
      try:
        response = await retell_client.call.create_phone_call(
          from_number="+14157774444",
          to_number="+12137774445"
        )
        print(f"Call initiated: {response}")
      except Exception as e:
        print(f"Error making call: {e}")
      ```
    </CodeGroup>
  </Step>
</Steps>

## SDK vs REST API Comparison

To illustrate the benefits of using our SDK, here's a comparison of creating an agent using both methods:

#### Using REST API (More Verbose)

```javascript theme={null}
const options = {
  method: 'POST',
  headers: {
    Authorization: '<authorization>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    response_engine: {
      type: 'retell-llm',
      llm_id: 'llm_234sdertfsdsfsdf'
    },
    agent_name: 'Jarvis',
    voice_id: '11labs-Adrian',
    // ... many more configuration options
  })
};

fetch('https://api.retellai.com/create-agent', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
```

#### Using SDK (More Concise)

```typescript theme={null}
import Retell from 'retell-sdk';

const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
});

async function main() {
  const params: Retell.AgentCreateParams = {
    response_engine: { 
      llm_id: 'llm_234sdertfsdsfsdf',
      type: 'retell-llm'
    },
    voice_id: '11labs-Adrian',
  };
  const agentResponse = await client.agent.create(params);
}
```

## Best Practices

### 1. Error Handling

Always wrap SDK calls in try-catch blocks to handle potential errors gracefully:

```typescript theme={null}
try {
  const response = await retellClient.call.createPhoneCall(params);
  // Handle success
} catch (error) {
  if (error.code === 'insufficient_funds') {
    // Handle specific error
  }
  // Log error details
}
```

### 2. Environment Variables

Store your API key securely using environment variables:

```typescript theme={null}
const retellClient = new Retell({
  apiKey: process.env.RETELL_API_KEY,
});
```

### 3. Type Safety

Leverage TypeScript types for better developer experience:

```typescript theme={null}
import { Retell, AgentCreateParams } from 'retell-sdk';

const params: AgentCreateParams = {
  // TypeScript will provide autocomplete here
};
```

## Additional Resources

Find more SDK examples in our test suites to learn more about how to use the SDK:

* [Node.js SDK Examples](https://github.com/RetellAI/retell-typescript-sdk/tree/main/tests/api-resources)
* [Python SDK Examples](https://github.com/RetellAI/retell-python-sdk/tree/main/tests/api_resources)
