Installation
Install the Nomos Python SDK using pip:Quick Start
Here’s a simple example to get you started:Authentication
The SDK supports multiple authentication methods:No Authentication
JWT Authentication
API Key Authentication
Usage Patterns
Stateless Chat
Stateless chat allows you to maintain conversation state on the client side:Session Management
Session management allows the server to handle conversation state:API Reference
NomosClient
Main async client class for interacting with Nomos agents.Constructor
base_url
: URL of the Nomos API serverauth
: Authentication configurationtimeout
: Request timeout in secondsheaders
: Additional headers for requests
Methods
health_check()
Check the health status of the API server.
chat.next(query, session_data=None)
Send a chat message with optional session data for stateless chat.
session.init(initiate=False)
Create a new session.
session.next(session_id, query)
Send a message to an existing session.
session.get_history(session_id)
Get conversation history for a session.
session.end(session_id)
End a session.
NomosClientSync
Synchronous version of the client for non-async contexts:AuthConfig
Authentication configuration model.Response Models
ChatResponse
SessionResponse
Error Handling
The SDK provides specific exception types for different error scenarios:Advanced Usage
Custom Headers
Timeout Configuration
Context Manager Usage
Always use the client as a context manager to ensure proper cleanup:Examples
Interactive Chat Bot
Session-Based Customer Service Bot
Best Practices
- Always use context managers to ensure proper resource cleanup
- Handle exceptions appropriately for production applications
- Use stateless chat for simple interactions, sessions for complex conversations
- Set appropriate timeouts based on your use case
- Use environment variables for sensitive tokens and configurations
- Implement retry logic for production applications
- Monitor your API usage and implement rate limiting if needed