Profile

Retrieve chunk results

Retrieve the top-k most relevant user snippets for grounding conversations, reasoning, or retrieval-augmented generation (RAG).

POST /chunks

This endpoint searches across all data ingested for a user — including events, documents, and summaries — and returns excerpts ranked by semantic relevance.

Purpose

Use this endpoint when your agent or model needs contextual grounding based on a user’s history or profile.
The results can be embedded directly into LLM prompts to personalize reasoning and improve factual recall.

Typical use cases include:

  • Chat memory retrieval for ongoing conversations.

  • Personalized RAG pipelines in assistants or copilots.

  • Cross-tool reasoning and summarization tasks.

Endpoint

Headers

Authorization: x-api-key: <token>

Request Body

Field

Type

Required

Description

user_id

string

Yes

Unique ID of the user whose memory to retrieve.

conversation

array

Yes

Conversation history to anchor the retrieval query.

top_k

integer

Optional

Number of relevant snippets to return. Default: 5.

Conversation Object

Each element of conversation represents one message in the context window.

Field

Type

Required

Description

role

string

Yes

One of system, user, or assistant.

content

string

Yes

Message text content.

Example Request

{
  "user_id": "usr_42af7c",
  "conversation": [
    { "role": "system", "content": "You are an assistant that schedules meetings." },
    { "role": "user", "content": "Can you schedule next week's team sync?" }
  ],
  "top_k": 5
}

Example cURL

curl -X POST "https://api.fastino.ai/chunks" \
  -H "Authorization: x-api-key: sk_test_123" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "usr_42af7c",
    "conversation": [
      {"role": "system", "content": "You are an assistant that schedules meetings."},
      {"role": "user", "content": "Can you schedule next week’s team sync?"}
    ],
    "top_k": 5
  }'

Example Response

{
  "results": [
    {
      "chunk_id": "doc_7#p1",
      "excerpt": "Typical focus blocks 9–12 PT; meetings after 1 PM preferred.",
      "score": 0.84
    },
    {
      "chunk_id": "evt_1#s1",
      "excerpt": "Let's move stand-up to 2 PM starting next week.",
      "score": 0.81
    }
  ]
}

Response Fields

Field

Type

Description

results

array

List of retrieved memory snippets ranked by relevance.

results[].chunk_id

string

Unique ID linking to the source record (document or event).

results[].excerpt

string

Extracted text segment relevant to the query.

results[].score

number

Similarity score between 0–1 (higher = more relevant).

Behavior

  • Retrieval results are ranked using Fastino’s adaptive user-specific embeddings.

  • Results include both event and document excerpts where relevant.

  • top_k controls the number of snippets returned (defaults to 5, max 20).

  • Retrieved context can be used for:

    • Model grounding in RAG pipelines.

    • User-aware reasoning and prompt initialization.

    • Personalized summarization or decision support.

Error Responses

HTTP Code

Error Code

Description

400

INVALID_REQUEST

Missing user_id or conversation data.

401

UNAUTHORIZED

Invalid or missing API key.

404

USER_NOT_FOUND

The user doesn’t exist in your workspace.

500

SERVER_ERROR

Internal processing failure — retry later.

Example:

{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "Missing field: conversation"
  }
}

Example Implementation (Python)

import requests

BASE_URL = "https://api.fastino.ai"
HEADERS = {"Authorization": "x-api-key: sk_live_456", "Content-Type": "application/json"}

payload = {
    "user_id": "usr_42af7c",
    "conversation": [
        {"role": "system", "content": "You are an assistant that schedules meetings."},
        {"role": "user", "content": "Can you schedule next week’s team sync?"}
    ],
    "top_k": 5
}

r = requests.post(f"{BASE_URL}/chunks", json=payload, headers=HEADERS)
for item in r.json()["results"]:
    print(f"{item['excerpt']} (score={item['score']})")

Best Practices

  • Keep top_k between 3–8 for optimal LLM prompt context.

  • Combine retrieved snippets with /summary results for hybrid reasoning.

  • Filter or rerank retrieved chunks in your app for domain-specific weighting.

  • Log retrieved chunk_ids if you need traceability between user data and responses.

  • Avoid sending empty or truncated conversation arrays — include sufficient context.

Related Endpoints

Endpoint

Description

POST /query

Ask a natural-language question about the user.

GET /summary

Retrieve a deterministic summary for user context.

POST /ingest

Add new data for retrieval.

Summary:
Use POST /chunks to retrieve the most relevant user memory snippets for RAG workflows.
This endpoint powers Fastino’s context-grounded reasoning — allowing agents to access personalized, user-specific information instantly and deterministically.

On this page