> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tensorpro.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# The SIP

> The context package EDN builds for your model before each call.

The **SIP (Session Initialisation Package)** is a short, labelled block of the
memory most relevant to the user's current message. Before each model call,
your app asks EDN for a SIP and places it in the model's prompt. Your model
gets only the memory it needs, not your whole history.

## Build a SIP

Call `POST /api/v1/sip/build` with the user's message:

```bash theme={"theme":"github-light"}
curl https://api.tensorpro.ai/api/v1/sip/build \
  -H "Authorization: Bearer $EDN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "Who manages the website project?", "session_id": "YOUR_SESSION_ID"}'
```

| Field | Required | What it does |
| - | - | - |
| `query` | Yes | The text to find memory for, normally the user's latest message |
| `session_id` | Yes | The conversation this request belongs to |
| `project_id` | No | Build from one project's memory and documents only. Omit it to use general memory |
| `include_global` | No | With `project_id`, also include general memory. Default `false` |

## What you get back

The response contains the SIP itself, plus details about how it was built.

### The SIP text

`sip` is a plain text string. This is exactly what your model sees when you
place it in the prompt: one line per memory, each labelled with its source.

```text theme={"theme":"github-light"}
[MEMORY CONTEXT]
- Sara manages the website project. (USER_STATED)
[END MEMORY CONTEXT]
```

### The full response

```json theme={"theme":"github-light"}
{
  "sip": "[MEMORY CONTEXT]\n- Sara manages the website project. (USER_STATED)\n[END MEMORY CONTEXT]",
  "records_used": 1,
  "grounded": false,
  "abstain": false,
  "citations": []
}
```

| Field | Type | What it means |
| - | - | - |
| `sip` | string | The text to place in your model's prompt |
| `records_used` | number | How many memory records are in the SIP |
| `grounded` | boolean | `true` when the build was scoped to a project |
| `abstain` | boolean | `true` when a project build found nothing relevant |
| `citations` | array | The numbered sources, in project builds only. See [Citations](#citations) |

## How memory is chosen

* **Only relevant memory.** EDN compares the query with your stored records and
  keeps only those that are relevant enough.
* **Only trusted sources.** Records that are AI-written and unconfirmed are
  never included. See [Provenance](https://docs.tensorpro.ai/concepts/provenance.md).
* **Only current versions.** Replaced and deleted records are left out.
* **No model involved.** No language model chooses the records, so the same
  question over the same memory always gives the same SIP.
* **Follow-up questions.** If you save messages to the session, short follow-ups
  like "and who approves it?" can still find the right memory.

## Citations

In a project build, each citable source is numbered in the SIP:

```text theme={"theme":"github-light"}
[MEMORY CONTEXT]
[1] Sara leads design and delivery. (DOCUMENT_VERIFIED)
- Who manages the website project? (ROUND)
[END MEMORY CONTEXT]
```

Ask your model to cite these numbers in its answer, for example "Sara leads the
project \[1]." Then use `citations` to show where each number came from:

| Citation field | What it means |
| - | - |
| `index` | The number, matching `[n]` in the SIP |
| `source_title` | The document's title, for example `Project plan.pdf`, or `null` if not from a document |
| `summary` | What the cited memory says |
| `provenance` | Where it came from |

Each document gets one number, even if several of its sections are used. Saved
conversations (`ROUND`) can appear in the SIP as background, but are never
numbered or cited.

## When nothing matches

* **General build:** `sip` is an empty string. Call your model without memory
  context.
* **Project build:** `abstain` is `true`, and `sip` contains an instruction
  telling your model to answer only from the project's sources and to say
  plainly that they don't cover the question. Your model declines instead of
  guessing.

## Next steps

> [card] [Quickstart](https://docs.tensorpro.ai/quickstart.md)
>
> Use a SIP with your model, step by step.

> [card] [Provenance](https://docs.tensorpro.ai/concepts/provenance.md)
>
> What each source label means.

> [card] [Grounding answers in documents](https://docs.tensorpro.ai/concepts/projects-and-sessions.md)
>
> Projects, documents and citations end to end.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.