Package Exports
- retell-sdk
- retell-sdk/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (retell-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
retell-sdk-test
🏗 Welcome to your new SDK! 🏗
It has been generated successfully based on your OpenAPI spec. However, it is not yet ready for production use. Here are some next steps:
- 🛠 Make your SDK feel handcrafted by customizing it
- ♻️ Refine your SDK quickly by iterating locally with the Speakeasy CLI
- 🎁 Publish your SDK to package managers by configuring automatic publishing
- ✨ When ready to productionize, delete this section from the README
SDK Installation
NPM
npm add <UNSET>Yarn
yarn add <UNSET>SDK Example Usage
Create an outbound phone call
Initiate an outbound phone call.
import { RetellClient } from "retell-sdk-test";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const res = await sdk.createPhoneCall({
phoneNumber: {
from: "+14159095857",
to: "+14159095858",
},
agentPromptParams: [
{
name: "username",
value: "Adam",
},
],
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Retrieve a on-going or finished call
Retrieve details of a specific call
import { RetellClient } from "retell-sdk-test";
import { GetCallRequest } from "retell-sdk-test/dist/sdk/models/operations";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const callId: string = "119c3f8e47135a29e65947eeb34cf12d";
const res = await sdk.getCall(callId);
if (res.statusCode == 200) {
// handle response
}
}
run();
List all web or phone calls
Retrieve call details
import { RetellClient } from "retell-sdk-test";
import {
CallType,
FilterCriteria,
ListCallsRequest,
SortOrder,
} from "retell-sdk-test/dist/sdk/models/operations";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const filterCriteria: FilterCriteria = {
agentId: ["oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD"],
callType: [CallType.InboundPhoneCall, CallType.OutboundPhoneCall],
beforeStartTimestamp: 1703302407399,
afterStartTimestamp: 1703302407300,
beforeEndTimestamp: 1703302428899,
afterEndTimestamp: 1703302428800,
};
const sortOrder: SortOrder = SortOrder.Descending;
const limit: number = 850344;
const res = await sdk.listCalls(filterCriteria, sortOrder, limit);
if (res.statusCode == 200) {
// handle response
}
}
run();
Create a new voice AI agent
Create a new agent
import { RetellClient } from "retell-sdk-test";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const res = await sdk.createAgent({
prompt: "You are a marketing assistant. You help come up with creative content ideas and content like marketing emails, blog posts, tweets, ad copy and product descriptions. You respond concisely, with filler words in it.",
voiceId: "elevenlabs-xxcrwXReTKMHWjqi7Q27",
agentName: "Jarvis",
enableBeginMessage: true,
beginMessage: "Hello there, how can I help you?",
enableEndCall: true,
enableEndMessage: false,
endMessage: "Hope you have a good day, goodbye.",
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Retrieve details of an agent
Retrieve details of a specific agent
import { RetellClient } from "retell-sdk-test";
import { GetAgentRequest } from "retell-sdk-test/dist/sdk/models/operations";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const agentId: string = "16b980523634a6dc504898cda492e939";
const res = await sdk.getAgent(agentId);
if (res.statusCode == 200) {
// handle response
}
}
run();
List all agents
List all agents
import { RetellClient } from "retell-sdk-test";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const res = await sdk.listAgents();
if (res.statusCode == 200) {
// handle response
}
}
run();
Update an existing agent
Update an existing agent
import { RetellClient } from "retell-sdk-test";
import { UpdateAgentRequest } from "retell-sdk-test/dist/sdk/models/operations";
import { AgentNoDefaultNoRequired } from "retell-sdk-test/dist/sdk/models/shared";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const agentId: string = "16b980523634a6dc504898cda492e939";
const agentNoDefaultNoRequired: AgentNoDefaultNoRequired = {
prompt: "You are a marketing assistant. You help come up with creative content ideas and content like marketing emails, blog posts, tweets, ad copy and product descriptions. You respond concisely, with filler words in it.",
voiceId: "elevenlabs-xxcrwXReTKMHWjqi7Q27",
agentName: "Jarvis",
enableBeginMessage: true,
beginMessage: "Hello there, how can I help you.",
enableEndCall: true,
enableEndMessage: false,
endMessage: "Hope you have a good day, goodbye.",
};
const res = await sdk.updateAgent(agentId, agentNoDefaultNoRequired);
if (res.statusCode == 200) {
// handle response
}
}
run();
Delete an existing agent
Delete an existing agent
import { RetellClient } from "retell-sdk-test";
import { DeleteAgentRequest } from "retell-sdk-test/dist/sdk/models/operations";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const agentId: string = "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD";
const res = await sdk.deleteAgent(agentId);
if (res.statusCode == 200) {
// handle response
}
}
run();
Create a new phone number
Create a new phone number
import { RetellClient } from "retell-sdk-test";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const res = await sdk.createPhoneNumber({
agentId: "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
areaCode: 415,
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Retrieve info about a specific number
Retrieve info about a specific number
import { RetellClient } from "retell-sdk-test";
import { GetPhoneNumberRequest } from "retell-sdk-test/dist/sdk/models/operations";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const phoneNumber: string = "+14159095857";
const res = await sdk.getPhoneNumber(phoneNumber);
if (res.statusCode == 200) {
// handle response
}
}
run();
List all purchased and active phone numbers
List all purchased and active phone numbers
import { RetellClient } from "retell-sdk-test";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const res = await sdk.listPhoneNumbers();
if (res.statusCode == 200) {
// handle response
}
}
run();
Update an existing phone number
Update an existing phone number
import { RetellClient } from "retell-sdk-test";
import {
UpdatePhoneAgentRequest,
UpdatePhoneAgentRequestBody,
} from "retell-sdk-test/dist/sdk/models/operations";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const phoneNumber: string = "+14159095857";
const requestBody: UpdatePhoneAgentRequestBody = {
agentId: "oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD",
};
const res = await sdk.updatePhoneAgent(phoneNumber, requestBody);
if (res.statusCode == 200) {
// handle response
}
}
run();
Delete a specific phone number
Delete a specific phone number
import { RetellClient } from "retell-sdk-test";
import { DeletePhoneNumberRequest } from "retell-sdk-test/dist/sdk/models/operations";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const phoneNumber: string = "string";
const res = await sdk.deletePhoneNumber(phoneNumber);
if (res.statusCode == 200) {
// handle response
}
}
run();
Available Resources and Operations
RetellClient SDK
- createPhoneCall - Initiate an outbound phone call.
- getCall - Retrieve details of a specific call
- listCalls - Retrieve call details
- createAgent - Create a new agent
- getAgent - Retrieve details of a specific agent
- listAgents - List all agents
- updateAgent - Update an existing agent
- deleteAgent - Delete an existing agent
- createPhoneNumber - Create a new phone number
- getPhoneNumber - Retrieve info about a specific number
- listPhoneNumbers - List all purchased and active phone numbers
- updatePhoneAgent - Update an existing phone number
- deletePhoneNumber - Delete a specific phone number
Error Handling
Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an error. If Error objects are specified in your OpenAPI Spec, the SDK will throw the appropriate Error type.
| Error Object | Status Code | Content Type |
|---|---|---|
| errors.CreatePhoneCallResponseBody | 400 | application/json |
| errors.CreatePhoneCallResponseResponseBody | 401 | application/json |
| errors.CreatePhoneCallResponse402ResponseBody | 402 | application/json |
| errors.CreatePhoneCallResponse422ResponseBody | 422 | application/json |
| errors.CreatePhoneCallResponse429ResponseBody | 429 | application/json |
| errors.CreatePhoneCallResponse500ResponseBody | 500 | application/json |
| errors.SDKError | 4xx-5xx | / |
Example
import { RetellClient } from "retell-sdk-test";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
let res;
try {
res = await sdk.createPhoneCall({
phoneNumber: {
from: "+14159095857",
to: "+14159095858",
},
agentPromptParams: [
{
name: "username",
value: "Adam",
},
],
});
} catch (err) {
if (err instanceof errors.CreatePhoneCallResponseBody) {
console.error(err); // handle exception
throw err;
} else if (err instanceof errors.CreatePhoneCallResponseResponseBody) {
console.error(err); // handle exception
throw err;
} else if (err instanceof errors.CreatePhoneCallResponse402ResponseBody) {
console.error(err); // handle exception
throw err;
} else if (err instanceof errors.CreatePhoneCallResponse422ResponseBody) {
console.error(err); // handle exception
throw err;
} else if (err instanceof errors.CreatePhoneCallResponse429ResponseBody) {
console.error(err); // handle exception
throw err;
} else if (err instanceof errors.CreatePhoneCallResponse500ResponseBody) {
console.error(err); // handle exception
throw err;
} else if (err instanceof errors.SDKError) {
console.error(err); // handle exception
throw err;
}
}
if (res.statusCode == 200) {
// handle response
}
}
run();
Server Selection
Select Server by Index
You can override the default server globally by passing a server index to the serverIdx: number optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
| # | Server | Variables |
|---|---|---|
| 0 | https://api.re-tell.ai |
None |
Example
import { RetellClient } from "retell-sdk-test";
async function run() {
const sdk = new RetellClient({
serverIdx: 0,
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const res = await sdk.createPhoneCall({
phoneNumber: {
from: "+14159095857",
to: "+14159095858",
},
agentPromptParams: [
{
name: "username",
value: "Adam",
},
],
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Override Server URL Per-Client
The default server can also be overridden globally by passing a URL to the serverURL: str optional parameter when initializing the SDK client instance. For example:
import { RetellClient } from "retell-sdk-test";
async function run() {
const sdk = new RetellClient({
serverURL: "https://api.re-tell.ai",
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const res = await sdk.createPhoneCall({
phoneNumber: {
from: "+14159095857",
to: "+14159095858",
},
agentPromptParams: [
{
name: "username",
value: "Adam",
},
],
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Custom HTTP Client
The Typescript SDK makes API calls using the axios HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom AxiosInstance object.
For example, you could specify a header for every request that your sdk makes as follows:
import { retell-sdk-test } from "RetellClient";
import axios from "axios";
const httpClient = axios.create({
headers: {'x-custom-header': 'someValue'}
})
const sdk = new RetellClient({defaultClient: httpClient});Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme |
|---|---|---|
apiKey |
http | HTTP Bearer |
To authenticate with the API the apiKey parameter must be set when initializing the SDK client instance. For example:
import { RetellClient } from "retell-sdk-test";
async function run() {
const sdk = new RetellClient({
apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});
const res = await sdk.createPhoneCall({
phoneNumber: {
from: "+14159095857",
to: "+14159095858",
},
agentPromptParams: [
{
name: "username",
value: "Adam",
},
],
});
if (res.statusCode == 200) {
// handle response
}
}
run();
Development
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!