> For the complete documentation index, see [llms.txt](https://docs.zerve.ai/zerve-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zerve.ai/zerve-docs/data-and-assets/functions.md).

# Functions

Share reusable code across notebooks, with versions.

A **function** asset is reusable code, such as a function or class, that you write once and use across notebooks. Use functions for code your team shares, such as a standard way to load positions data or calculate risk metrics, so everyone uses the same version.

Find them under **Assets → Functions**.

## What a function contains

Each version of a function holds:

| Part             | Details                                                                  |
| ---------------- | ------------------------------------------------------------------------ |
| **Code**         | The function or class itself                                             |
| **Requirements** | The packages it needs, each with a version rule, such as `pandas >= 2.0` |
| **Imports**      | The imports the code needs                                               |
| **Language**     | The language and language version it's written in                        |

## Versions

Functions are **versioned**, like constants. Each change creates a new version, and a notebook uses the **specific version** attached to it. Updating a function doesn't change notebooks using an older version until you switch them.

This lets you improve shared code without breaking work that depends on the old behavior.

## Using a function in a notebook

Attach the function to a notebook, optionally with an **alias**. A notebook can't have the same function attached twice, or two functions with the same name.

## Functions, DAGs and skills

A function shares **code**. A [DAG](/zerve-docs/data-and-assets/dags.md) shares a whole pipeline of connected blocks. A [skill](/zerve-docs/agents-in-the-workspace/skills.md) shares **instructions** for the agent, such as how your team backtests a strategy. They work well together: a skill can tell the agent to use your team's functions.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zerve.ai/zerve-docs/data-and-assets/functions.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
