import asyncio
from unpod import AsyncClient, AgentRunner, CallContext
from unpod.adapters.langchain import LangChainAdapter
async def setup():
client = AsyncClient()
# 1. Pick a voice profile
profiles = await client.voice_profiles.list()
profile = profiles[0]
# 2. Create the Speech Pipe
pipe = await client.pipes.create(
name="My Agent",
voice_profile=profile.profile_id,
agent_id="my-agent",
)
# 3. Attach the first free number
free = [n for n in await client.numbers.list() if n.pipe_id is None]
if free:
await client.numbers.attach(number_id=free[0].number_id, pipe_id=pipe.pipe_id)
print(f"Speech Pipe created: {pipe.pipe_id}")
print(f"Number: {free[0].number if free else 'none assigned'}")
asyncio.run(setup())