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

# Command-line tool

> oneapi generates images and videos from a terminal and saves the file in one command.

`oneapi` is a single binary written in Rust. It submits the task, waits for it and saves the output.

## Install

Build it from the repository's `cli` directory with a [Rust toolchain](https://rustup.rs):

```bash theme={null}
cd cli
cargo build --release
cp target/release/oneapi ~/.local/bin/
```

## Sign in

```bash theme={null}
oneapi login
```

Paste your API key at the prompt. It is saved to `~/.config/one-api/token`, readable only by you. To use an environment variable instead, set `ONE_API_TOKEN`; it takes priority over the saved key. `oneapi logout` removes the saved key.

## Generate an image

```bash theme={null}
oneapi image "a lighthouse on a cliff at dusk, oil painting" --size 16:9 -o lighthouse.jpg
```

| Option | Meaning |
| - | - |
| `-m, --model` | Model, default `z-image-turbo` |
| `--size` | Aspect ratio, such as `16:9` |
| `--resolution` | `1k` or `2k` |
| `--seed` | Seed for a reproducible result |
| `--format` | `jpg`, `png` or `webp` |

## Generate a video

```bash theme={null}
oneapi video "a kitten walking across a rooftop at night" --duration 5 --draft -o kitten.mp4
```

| Option | Meaning |
| - | - |
| `-m, --model` | Model, default `p-video` |
| `-d, --duration` | Length in seconds, 1 to 20 |
| `--resolution` | `720p` or `1080p` |
| `--aspect-ratio` | Such as `9:16` |
| `--draft` | Cheaper, lower-quality preview |
| `--seed` | Seed for a reproducible result |

## Options for both

| Option | Meaning |
| - | - |
| `-o, --output` | Where to save the file. Default is `<task id>.<ext>` in the current directory |
| `--no-wait` | Print the task id and return without waiting |
| `--timeout` | Stop waiting after this many seconds, default 900 |
| `--json` | Print the task as JSON |

## Check on tasks

```bash theme={null}
oneapi tasks                         # your 20 most recent tasks
oneapi task task_30f8… --wait -o out.mp4   # wait for one and save its output
```

## Use it in scripts

The saved file path, or the JSON with `--json`, is the only thing written to standard output. Progress and errors go to standard error. That makes the result easy to capture:

```bash theme={null}
file=$(oneapi image "a product photo of a ceramic mug" --format png)
echo "saved $file"

oneapi video "ocean waves at sunset" --no-wait   # prints the task id
```

### Exit codes

| Code | Meaning |
| - | - |
| 0 | Done |
| 1 | Other error, including a rejected request |
| 2 | Wrong command-line usage |
| 3 | No API key, or the key was refused |
| 4 | Not enough credits |
| 5 | The task failed. Nothing was charged |
| 6 | Still running when `--timeout` passed. Resume with `oneapi task <id> --wait` |

## Other settings

| Variable | Meaning |
| - | - |
| `ONE_API_TOKEN` | API key |
| `ONE_API_BASE_URL` | API address, default `https://one-api.ai`. Plain `http` is accepted for `localhost` only |

The API key is sent only to the API address. It is never sent to the host that serves the output file.


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