# Khan API Reference

These are the tasks Khan can be passed and the gifts it can give.

## Tasks <a href="#tasks" id="tasks"></a>

Here are the tasks you can pass Khan. You'd either use [`%fard`](#fard) to run a thread from a file or [`%lard`](#lard) to run an in-line thread.

### `%fard` <a href="#fard" id="fard"></a>

Run a thread from within Arvo.

```hoon
[%fard p=(fyrd cage)]
```

`.p` contains the thread location, name, and start arguments. See the [`+fyrd`](/urbit-os/kernel/khan/types.md#fyrd) data type reference entry for details.

#### Returns

When the thread finishes, either by succeeding or failing, Khan will return an [`%arow`](#arow) gift.

***

### `%fyrd` <a href="#fyrd" id="fyrd"></a>

External thread.

```hoon
[%fyrd p=(fyrd cast)]
```

This is passed to Khan by the runtime when a thread is run externally. You would not use this from userspace.

***

### `%lard` <a href="#lard" id="lard"></a>

In-line thread.

```hoon
[%lard =bear =shed]
```

The [`$bear`](/urbit-os/kernel/khan/types.md#bear) is either a `$desk` or `$beak`. The `$shed` is the thread itself. Since Spider doesn't need to read out the thread from Clay, the `$bear` doesn't do much apart from be included in the thread name that Spider generates. Khan will have Spider run the given thread, and eventually give an [`%arow`](#arow) gift back with the result.

#### Returns

When the thread eventually finishes (or if it fails), Khan with give an [`%arow`](#arow) gift back with the result.

***

## Gifts <a href="#gifts" id="gifts"></a>

These are the two gifts Khan can give. In userspace, you'd only receive an [`%arow`](#arow).

### `%arow` <a href="#arow" id="arow"></a>

In-arvo result.

```hoon
[%arow p=(avow cage)]
```

This gift contains the result of a finished thread if successful, or an error and stack trace if it failed. It's given for threads run from within Arvo. See the [`+avow`](/urbit-os/kernel/khan/types.md#avow) entry in the types reference for more details.

***

### `%avow` <a href="#avow" id="avow"></a>

External result.

```hoon
[%avow p=(avow page)]
```

This gift contains the result of running a thread externally. You would not receive this in userspace.

A `$page` is a pair of `$mark` and `$noun`. See the [`+avow`](/urbit-os/kernel/khan/types.md#avow) entry in the types reference for more details of that mold builder.

***


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.urbit.org/urbit-os/kernel/khan/tasks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
