Installation
Quick Start
Async Support
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | string | required | Your AmbientMeta API key |
base_url | string | https://api.ambientmeta.com | API base URL |
timeout | float | 30.0 | Request timeout in seconds |
Methods
client.sanitize(text, entities=None, mode=“sanitize”)
Sanitize text by replacing PII with placeholders. ReturnsSanitizeResponse with .sanitized, .session_id, .entities_found, .entities, .processing_ms, .redacted.
Set mode="redact" to permanently remove PII. Redacted responses have session_id=None and cannot be rehydrated.
client.rehydrate(text, session_id)
Restore original PII to sanitized text. ReturnsRehydrateResponse with .text, .entities_restored, .processing_ms.
client.create_pattern(name, pattern, description="", examples=None)
Create a custom entity pattern. ReturnsPatternResponse with .pattern_id, .name, .status.
client.send_feedback(session_id, feedback_type, text_snippet, expected_type="")
Submit a single correction. ReturnsFeedbackResponse with .status.
client.get_insights()
Get pending insights and knowledge depth metrics. ReturnsInsightsResponse with .pending_conflicts, .proposed_improvements, .discovered_patterns, .knowledge_depth.
client.resolve_insight(insight_id, resolution, modifications=None, reason=None)
Resolve an insight.resolution is "approve", "refine", or "reject".
Batch Corrections
Chain corrections on aSanitizeResponse and submit them all at once:
Correction Methods on SanitizeResponse
| Method | Description |
|---|---|
result.correct(placeholder, correct_type) | Mark a detected entity as misclassified |
result.report_missed(span_text, correct_type) | Report an entity the system missed |
result.report_false_positive(placeholder) | Report a false positive detection |
result.submit_corrections() | Submit all accumulated corrections (sync) |
await result.asubmit_corrections() | Submit all accumulated corrections (async) |
Error Handling
Error Classes
| Exception | Description |
|---|---|
AmbientMetaError | Base exception for all SDK errors |
AuthenticationError | API key is invalid or missing (401) |
RateLimitError | Rate limit exceeded (429) |
NotFoundError | Resource not found — session, pattern, or insight (404) |
ValidationError | Request failed validation (422) |

