Instalação
Requisitos
Python 3.8+
Suporta operações síncronas e assíncronas
Obter Sua Chave API
Para usar o SDK, você precisará de uma chave API do seu painel de controle itellicoAI :
Navegue até Desenvolvedores na barra lateral
Clique em Chaves API
Clique em Criar Chave API
Copie a chave gerada para usar com o SDK
Armazene sua chave API com segurança usando variáveis de ambiente. Nunca a envie para o controle de versão.
Início Rápido
from itellicoai import Itellicoai
# Initialize client
client = Itellicoai(
api_key = "your-api-key"
)
# Create an agent
agent = client.agents.create(
account_id = "your-account-id" ,
name = "Customer Support Agent" ,
model = {
"provider" : "openai" ,
"model" : "gpt-4o-mini"
},
voice = {
"provider" : "elevenlabs" ,
"voice_id" : "EXAVITQu4vr4xnSDxMaL"
},
transcriber = {
"provider" : "deepgram" ,
"model" : "nova-2:general" ,
"language" : "en-US"
},
initial_message = {
"mode" : "fixed_message" ,
"message" : "Hello! How can I assist you today?" ,
"delay_ms" : 1000
},
max_duration_seconds = 1800 ,
tags = [ "support" , "customer-service" ]
)
print ( f "Created agent: { agent.id } " )
Suporte Async
import asyncio
from itellicoai import AsyncItellicoAI
async def main ():
client = AsyncItellicoAI( api_key = "your-api-key" )
# List agents asynchronously
agents = await client.agents.list()
for agent in agents:
print ( f "Agent: { agent.name } " )
asyncio.run(main())
Operações do SDK
Listar Agentes from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
agents = client.agents.list(
account_id = "account_id" ,
)
print (agents.count)
Recuperar Agente from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
agent_response = client.agents.retrieve(
agent_id = "agent_id" ,
account_id = "account_id" ,
)
print (agent_response.id)
Atualizar Agente from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
agent_response = client.agents.update(
agent_id = "agent_id" ,
account_id = "account_id" ,
)
print (agent_response.id)
Arquivar Agente from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
client.agents.archive(
agent_id = "agent_id" ,
account_id = "account_id" ,
)
Listar Conversas from itellicoai import Itellicoai
client = Itellicoai( api_key = "My API Key" )
conversations = client.accounts.list_conversations(
account_id = "account_id"
)
for conv in conversations.items:
print ( f "Conversation ID: { conv.conversation_id } " )
print ( f "Contact: { conv.contact_number } " )
print ( f "Duration: { conv.duration_seconds } s" )
print ( f "Status: { conv.status } " )
Listar Números de Telefone from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
phone_numbers = client.accounts.phone_numbers.list(
account_id = "account_id" ,
)
print (phone_numbers.count)
Criar Número de Telefone from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
phone_number = client.accounts.phone_numbers.create(
account_id = "account_id" ,
sip_trunk_id = "sip_trunk_id" ,
)
print (phone_number.id)
Obter Número de Telefone from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
phone_number = client.accounts.phone_numbers.retrieve(
phone_number_id = "phone_number_id" ,
account_id = "account_id" ,
)
print (phone_number.id)
Atualizar Número de Telefone from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
phone_number = client.accounts.phone_numbers.update(
phone_number_id = "phone_number_id" ,
account_id = "account_id" ,
)
print (phone_number.id)
Excluir Número de Telefone from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
client.accounts.phone_numbers.delete(
phone_number_id = "phone_number_id" ,
account_id = "account_id" ,
)
Listar Modelos from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
response = client.accounts.providers.list_models(
account_id = "account_id" ,
)
print (response)
Listar Transcritores from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
response = client.accounts.providers.list_transcribers(
account_id = "account_id" ,
)
print (response)
Listar Vozes from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
response = client.accounts.providers.list_voices(
account_id = "account_id" ,
provider = "provider" ,
)
print (response)
Listar Trunks SIP from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
sip_trunks = client.accounts.sip_trunks.list(
account_id = "account_id" ,
)
print (sip_trunks.count)
Criar Trunk SIP from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
sip_trunk = client.accounts.sip_trunks.create(
account_id = "account_id" ,
)
print (sip_trunk.id)
Obter Trunk SIP from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
sip_trunk = client.accounts.sip_trunks.retrieve(
sip_trunk_id = "sip_trunk_id" ,
account_id = "account_id" ,
)
print (sip_trunk.id)
Atualizar Trunk SIP from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
sip_trunk = client.accounts.sip_trunks.update(
sip_trunk_id = "sip_trunk_id" ,
account_id = "account_id" ,
)
print (sip_trunk.id)
Excluir Trunk SIP from itellicoai import Itellicoai
client = Itellicoai(
api_key = "My API Key" ,
)
client.accounts.sip_trunks.delete(
sip_trunk_id = "sip_trunk_id" ,
account_id = "account_id" ,
)
Obter Análises de Uso response = client.accounts.analytics.get_usage(
account_id = "account_id" ,
)
print (response.meta)
Listar Subcontas subaccounts = client.accounts.subaccounts.list(
account_id = "account_id" ,
)
print (subaccounts.count)
Criar Subconta account = client.accounts.subaccounts.create(
account_id = "account_id" ,
name = "name" ,
)
print (account.id)
Obter Subconta account = client.accounts.subaccounts.retrieve(
subaccount_id = "subaccount_id" ,
account_id = "account_id" ,
)
print (account.id)
Atualizar Subconta account = client.accounts.subaccounts.update(
subaccount_id = "subaccount_id" ,
account_id = "account_id" ,
)
print (account.id)
Tratamento de Erros
from itellicoai import ItellicoAI
from itellicoai.exceptions import (
AuthenticationError,
NotFoundError,
RateLimitError,
APIError
)
client = ItellicoAI( api_key = "your-api-key" )
try :
agent = client.agents.retrieve( "agent_123abc" )
except AuthenticationError:
print ( "Invalid API key" )
except NotFoundError:
print ( "Agent not found" )
except RateLimitError:
print ( "Rate limit exceeded" )
except APIError as e:
print ( f "API error: { e.message } " )
Variáveis de Ambiente
import os
from itellicoai import ItellicoAI
# API key automatically loaded from ITELLICO_API_KEY env var
client = ItellicoAI()
# Or set explicitly
client = ItellicoAI( api_key = os.getenv( "ITELLICO_API_KEY" ))
Recursos