from seltz import (
AgentRunStatus,
Seltz,
SeltzAPIError,
SeltzAuthenticationError,
SeltzConnectionError,
SeltzRateLimitError,
SeltzTimeoutError,
)
client = Seltz()
try:
run = client.agent.create_and_wait(
"What are the three most notable AI-company acquisitions announced in 2026?",
timeout=120,
)
except SeltzAuthenticationError:
print("Error: Invalid API key")
except SeltzConnectionError:
print("Error: Could not connect to Seltz API")
except SeltzTimeoutError:
print("Still running -- poll get() again later, or cancel() it")
except SeltzRateLimitError:
print("Error: Rate limit exceeded, try again later")
except SeltzAPIError as e:
print(f"Request rejected: {e.grpc_code} - {e.grpc_details}")
else:
if run.status == AgentRunStatus.AGENT_RUN_STATUS_COMPLETED:
print(run.output.text)
else:
print("Run did not complete:", run.stop_reason)