# Chalk CLI Reference: Functions
source: https://docs.chalk.ai/cli#functions

Manage functions registered in the Chalk function catalog, including immutable versions, traffic, invocation, source, and the async call queue.

## `chalk function get`
source: https://docs.chalk.ai/cli?command=function_get

```bash
chalk function get
```

Use the 'chalk function get' command to retrieve an external function and its currently selected version by stable function ID or name. Use 'chalk function versions get' to retrieve a specific immutable version.

**Flags**

- `-i, --id <id>` (string)
  Stable ID of the function (mutually exclusive with --name).
- `-n, --name <name>` (string)
  Name of the function (mutually exclusive with --id).

**Example**

```
$ chalk function get --id=550e8400-e29b-41d4-a716-446655440000
$ chalk function get --name=my-function
```

## `chalk function list`
source: https://docs.chalk.ai/cli?command=function_list

```bash
chalk function list
```

Use the 'chalk function list' command to list stable external functions and their currently selected versions. Use 'chalk function versions list' to inspect version history.

**Flags**

- `-n, --name <name>` (string)
  Filter by function name.
- `--limit <limit>` (int, default `0`)
  Maximum number of results to return.

**Example**

```
$ chalk function list
$ chalk function list --name=my-function
$ chalk function list --limit=10
```

## `chalk function delete`
source: https://docs.chalk.ai/cli?command=function_delete

```bash
chalk function delete
```

Use the 'chalk function delete' command to delete an external function and all of its immutable versions by stable function ID or name.

**Flags**

- `-i, --id <id>` (string)
  Stable ID of the function (mutually exclusive with --name).
- `-n, --name <name>` (string)
  Name of the function (mutually exclusive with --id).

**Example**

```
$ chalk function delete --id=550e8400-e29b-41d4-a716-446655440000
$ chalk function delete --name=my-function
```

## `chalk function update_traffic`
source: https://docs.chalk.ai/cli?command=function_update_traffic

```bash
chalk function update-traffic
```

Use the 'chalk function update-traffic' command to route 100% of traffic for a stable external function to an immutable version. This changes selection without creating a version. The API currently supports one version target at 100% traffic.

**Flags**

- `-i, --id <id>` (string)
  Stable function ID (mutually exclusive with --name).
- `-n, --name <name>` (string)
  Function name (mutually exclusive with --id).
- `--version-id <version-id>` (string)
  Immutable function version ID to select.

**Example**

```
$ chalk function update-traffic --id=fn_123 --version-id=fnv_456
$ chalk function update-traffic --name=my-function --version-id=fnv_456
```

## `chalk function versions get`
source: https://docs.chalk.ai/cli?command=function_versions_get

```bash
chalk function versions get
```

Use the 'chalk function versions get' command to retrieve an immutable function version by version ID, or by stable function ID/name and version number.

**Flags**

- `-i, --id <id>` (string)
  Immutable function version ID.
- `--function-id <function-id>` (string)
  Stable function ID (use with --version).
- `-n, --name <name>` (string)
  Function name (use with --version).
- `--version <version>` (int, default `0`)
  Immutable version number.

**Example**

```
$ chalk function versions get --id=550e8400-e29b-41d4-a716-446655440000
$ chalk function versions get --function-id=fn_123 --version=3
$ chalk function versions get --name=my-function --version=3
```

## `chalk function versions list`
source: https://docs.chalk.ai/cli?command=function_versions_list

```bash
chalk function versions list
```

Use the 'chalk function versions list' command to inspect the immutable version history for one stable external function.

**Flags**

- `--function-id <function-id>` (string)
  Stable function ID whose versions to list (mutually exclusive with --name).
- `-n, --name <name>` (string)
  Function name whose versions to list (mutually exclusive with --function-id).
- `--limit <limit>` (int, default `0`)
  Maximum number of versions to return.

**Example**

```
$ chalk function versions list --function-id=fn_123
$ chalk function versions list --name=my-function --limit=10
```

## `chalk function call`
source: https://docs.chalk.ai/cli?command=function_call

```bash
chalk function call
```

Use the 'chalk function call' command to invoke an external function synchronously. Regular functions run through the ExternalFunctionCatalogService. Generator functions stream through the dataplane API server's function queue service.

Provide arguments with --in (repeated once per argument), or supply a pre-built Arrow IPC stream via --input-file. The response feather stream is written to --output-file, or rendered as a text table when --output-file is omitted.

**Flags**

- `-n, --name <name>` (string)
  Name of the function to invoke.
- `--version <version>` (int, default `0`)
  Function version to invoke (omit for the currently selected version).
- `--in <[arg]=[value]>` (string[], default `[]`)
  Function argument as key=value. Repeat for each argument: --in a=1 --in b=2. Use @file(path) to read the value from a file.

  ```bash
  --in a=1 --in b=2
  ```

  ```bash
  --in texts='["hi","there"]'
  ```

  ```bash
  --in data=@file(payload.json)
  ```
- `-i, --input-file <input-file>` (string)
  Path to a file containing the Arrow IPC (feather) stream that encodes the call arguments. Use `-` to read from stdin.
- `-o, --output-file <output-file>` (string)
  Path to write the response Arrow IPC (feather) stream to. Use `-` (or omit) to write to stdout.

**Example**

```
$ chalk function call --name=add --in a=1 --in b=2
$ chalk function call --name=my-function --input-file=args.feather --output-file=result.feather
$ chalk function call -n my-function --version=3 -i args.feather -o -
$ cat args.feather | chalk function call -n my-function -i - -o result.feather
```

## `chalk function calls recent`
source: https://docs.chalk.ai/cli?command=function_calls_recent

```bash
chalk function calls recent
```

Use the 'chalk function calls recent' command to fetch the most recent async calls submitted to a function via the function queue, ordered newest-first.

The function queue stores per-call metadata (status, enqueue time, trace id) so that you can inspect what has been dispatched without re-running the function.

**Flags**

- `-n, --name <name>` (string)
  Name of the function whose calls to inspect.
- `--limit <limit>` (int, default `0`)
  Maximum number of recent calls to return (clamped server-side to [1, 1000], default 10).

**Example**

```
$ chalk function calls recent --name=my-function
$ chalk function calls recent -n my-function --limit=50
```

## `chalk function calls count`
source: https://docs.chalk.ai/cli?command=function_calls_count

```bash
chalk function calls count
```

Use the 'chalk function calls count' command to fetch the number of async calls submitted to a function in the past hour.

**Flags**

- `-n, --name <name>` (string)
  Name of the function whose call count to fetch.

**Example**

```
$ chalk function calls count --name=my-function
$ chalk function calls count -n my-function
```

## `chalk function download`
source: https://docs.chalk.ai/cli?command=function_download

```bash
chalk function download
```

Use the 'chalk function download' command to download the source volume for a function registered in the Chalk function catalog to a local directory.

The command resolves the immutable source volume version captured by the selected function version, then downloads exactly that snapshot.

**Flags**

- `-i, --id <id>` (string)
  ID of the function version (mutually exclusive with --name).
- `-n, --name <name>` (string)
  Name of the function (mutually exclusive with --id).
- `--version <version>` (int, default `0`)
  Version number (used with --name; omit for the currently selected version).
- `-o, --output <output>` (string)
  Directory to download the source volume into. Defaults to a directory named after the function.

**Example**

```
$ chalk function download --name=my-function
$ chalk function download --name=my-function --version=3 --output=./my-function-src
$ chalk function download --id=550e8400-e29b-41d4-a716-446655440000
```
