Skip to main content
The Agnost AI Python SDK can be configured during initialization to enable debug logging and customize behavior.

Basic Configuration

Initialize the SDK with your organization ID (passed positionally as write_key):

Configuration Options

SDK Initialization (agnost.init)

ParameterTypeRequiredDefaultDescription
org_idstrRequired-Your organization ID from the Agnost AI dashboard
debugboolNoFalseEnable debug logging for troubleshooting

Begin/End Tracking (agnost.begin)

Start interaction with agnost.begin():
ParameterTypeRequiredDefaultDescription
user_idstrNo""Identifier for the user
agent_namestrNo"default"Name of the AI agent or model
inputstrNoNoneInput text or prompt (can also set later with set_input())
conversation_idstrNoNoneID to group related messages in a conversation
propertiesdictNoNoneAdditional metadata as key-value pairs
Complete interaction with interaction.end():
ParameterTypeRequiredDefaultDescription
outputstrNoNoneOutput or response from the AI agent
successboolNoTrueWhether the interaction was successful
latencyintNoAuto-calculatedExecution time in milliseconds (auto-calculated from begin time if not provided)

User Identification (agnost.identify)

ParameterTypeRequiredDefaultDescription
user_idstrRequired:Identifier for the user
traitsdictRequired:User characteristics. Prefer non-sensitive traits such as plan, role, or account_segment; avoid raw names, emails, phone numbers, or other personal data unless explicitly approved.

Interaction methods

agnost.begin() returns an Interaction object with these methods:
MethodSignatureDescription
set_input(text: str)Set the input text after the interaction has begun.
set_property(key: str, value: Any)Set a single property. Returns the interaction for chaining.
set_properties(properties: dict)Merge multiple properties at once. Returns the interaction for chaining.
end(output=None, success=True, latency=None, **extra)Complete the interaction and send the event. Latency auto-calculated if not supplied.

Lifecycle

FunctionDescription
agnost.flush()Manually flush all queued events (non-blocking).
agnost.shutdown()Flush remaining events and release resources. Called automatically on process exit.
agnost.set_debug_logs(enabled)Toggle debug logs after initialization.

Debug Mode

Enable debug mode to see detailed logging of SDK operations:
Debug mode is useful for troubleshooting integration issues and verifying events are being sent correctly.

Sensitive data

Agnost receives the input, output, user traits, and metadata you send. For production traffic, use pseudonymous user IDs, allowlist metadata keys, and redact sensitive data before calling the SDK. See Data Governance for recommended patterns.

Next Steps