Skip to main content

Python SDK

The official Python client for the Netomi API.

Installation

pip install netomi-python

Requires Python 3.9+.

Initialize the client

import os
from netomi import NetomiClient

client = NetomiClient(
api_key=os.environ["NETOMI_API_KEY"],
environment="production", # or "sandbox"
)

Common operations

Start a conversation:

conversation = client.conversations.create(
agent_id="agent_abc123",
message="Hello",
user_id="user_001",
)

Send a follow-up:

reply = client.conversations.send_message(
conversation.id,
message="My order number is 445566",
)

List agents:

for agent in client.agents.list():
print(agent.name)

Async support

from netomi import AsyncNetomiClient

async with AsyncNetomiClient(api_key="...") as client:
conversation = await client.conversations.create(
agent_id="agent_abc123",
message="Hello",
user_id="user_001",
)

Configuration options

OptionTypeDefaultDescription
api_keystrRequired
environmentstr"production"production or sandbox
timeoutfloat30.0Request timeout in seconds
max_retriesint3Auto-retry on 5xx and 429

Error handling

from netomi import NetomiAPIError

try:
client.conversations.create(...)
except NetomiAPIError as err:
print(err.code, err.message)

Was this page helpful?