Add threshold parameter to profile API docs (#659)

Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
This commit is contained in:
Dhravya Shah 2026-01-08 18:36:48 -08:00 committed by GitHub
parent 68d4d95c1d
commit ca8eb295db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 99 additions and 1 deletions

View file

@ -117,4 +117,8 @@ That's it! Supermemory automatically:
- Builds and maintains user profiles (static facts + dynamic context)
- Returns relevant context for personalized LLM responses
<Tip>
**Optional:** Use the `threshold` parameter to filter search results by relevance score. For example: `client.profile(container_tag=USER_ID, threshold=0.7, q=query)` will only include results with a score above 0.7.
</Tip>
Learn more about [User Profiles](/user-profiles) and [Search](/search/overview).

View file

@ -25,6 +25,7 @@ Retrieves a user's profile, optionally combined with search results.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `containerTag` | string | Yes | The container tag (usually user ID) to get profiles for |
| `threshold` | float | No | Threshold for filtering search results. Only results with a score above this threshold will be included. |
| `q` | string | No | Optional search query to include search results with the profile |
## Response
@ -165,11 +166,53 @@ search_results = data.get('searchResults', {}).get('results', [])
</CodeGroup>
## Profile with Threshold
Use the optional `threshold` parameter to filter search results by relevance score:
<CodeGroup>
```typescript TypeScript
const response = await fetch('https://api.supermemory.ai/v4/profile', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
containerTag: 'user_123',
threshold: 0.7, // Only include results with score > 0.7
q: 'deployment errors yesterday'
})
});
const data = await response.json();
```
```python Python
response = requests.post(
'https://api.supermemory.ai/v4/profile',
headers={
'Authorization': f'Bearer {os.getenv("SUPERMEMORY_API_KEY")}',
'Content-Type': 'application/json'
},
json={
'containerTag': 'user_123',
'threshold': 0.7, # Only include results with score > 0.7
'q': 'deployment errors yesterday'
}
)
data = response.json()
```
</CodeGroup>
## Error Responses
| Status | Description |
|--------|-------------|
| `400` | Missing or invalid `containerTag` |
| `400` | Missing or invalid `containerTag` or `threshold` |
| `401` | Invalid or missing API key |
| `404` | Container not found |
| `500` | Internal server error |

View file

@ -180,6 +180,57 @@ Relevant Information:
</CodeGroup>
## Filtering with Threshold
Use the optional `threshold` parameter to filter search results by relevance score:
<CodeGroup>
```typescript TypeScript
async function getHighQualityContext(userId: string, userQuery: string) {
const response = await fetch('https://api.supermemory.ai/v4/profile', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.SUPERMEMORY_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
containerTag: userId,
threshold: 0.7, // Only include high-confidence results
q: userQuery
})
});
const data = await response.json();
// Only highly relevant memories are included
return data;
}
```
```python Python
async def get_high_quality_context(user_id: str, user_query: str):
response = requests.post(
'https://api.supermemory.ai/v4/profile',
headers={
'Authorization': f'Bearer {os.getenv("SUPERMEMORY_API_KEY")}',
'Content-Type': 'application/json'
},
json={
'containerTag': user_id,
'threshold': 0.7, # Only include high-confidence results
'q': user_query
}
)
data = response.json()
# Only highly relevant memories are included
return data
```
</CodeGroup>
## Separate Profile and Search
For more control, you can call profile and search endpoints separately: