# Project setup

Source: https://docs.orbytelabs.com/cli/setup

Link your project, create a catalog, and set up an API key.

## Initialize a project [#initialize-a-project]

Run from your application directory.

```npm
npx orbytelabs init
```

The CLI signs in if needed, links your application and environment, installs
`orbytelabs` if needed, and creates `orbyte.config.ts`. The install uses your
project's package manager and the version of the CLI you ran.

Choose a raw catalog, an [AI SDK](/integrations/ai-sdk) catalog, or an
[Eve](/integrations/eve) catalog. The CLI suggests a preset based on
`package.json`. Set `--preset raw`,
`--preset ai-sdk`, or `--preset eve` to choose it directly. The Raw preset uses
the core pricing helpers, and the AI SDK and Eve presets use their respective
integrations.

With a CLI login, you can opt in to creating a standard API key and saving it
as `ORBYTE_API_KEY` in an env file. Use `--save-key .env.local` to opt in directly.
The CLI adds the env file to `.gitignore` and preserves an existing key entry.
If `ORBYTE_API_KEY` is already exported, `init` creates the catalog for that
key's environment.

An existing `orbyte.config.ts` stays in place. Run `orbytelabs dev` to deploy
the catalog and watch for edits.

## Sign in [#sign-in]

```npm
npx orbytelabs login
```

Confirm the device code in your browser. The CLI saves credentials in
`~/.orbyte/auth.json`. For an agent or remote terminal, add `--no-browser` and
keep the command running while you confirm the printed URL and code.

## Link your project [#link-your-project]

Run from your application's directory:

```npm
npx orbytelabs link
```

Select or create an organization, application, and environment. The CLI saves
`.orbyte/project.json` and adds `.orbyte/` to `.gitignore`. Run `link` again to
change the target.

### Set up without selection menus [#set-up-without-selection-menus]

List commands print JSON. Use the returned IDs:

```sh
npx orbytelabs organization list
npx orbytelabs application list --organization org_example
npx orbytelabs environment list --organization org_example --application app_example
npx orbytelabs link --environment env_example
```

Create only the resources you need:

```sh
npx orbytelabs organization create --name "Example company"
npx orbytelabs application create --organization org_example --name "Example app"
```

Application creation waits for its initial Development environment and returns
`environmentId`. To add another development environment to an existing app:

```sh
npx orbytelabs environment create --organization org_example \
  --application app_example --name "Agent development"
```

Add `--production` only to create a production environment. Check `isProduction`
before deploying. `link --environment` verifies access and saves the same project
link as interactive setup. After an uncertain creation response, list resources
before retrying to avoid duplicates.

## Use an API key [#use-an-api-key]

Set `ORBYTE_API_KEY` as a protected environment variable to use a key instead of
the saved user login. Environment-scoped commands, including `deploy`, `check`,
`track`, `balance`, `grant`, `subscribe`, and `topup`, use the key's environment
without a project link or an environment metadata read. Each operation still
requires its corresponding key permissions.

Managing organizations, applications, environments, or API keys requires a user
login. Unset `ORBYTE_API_KEY` for those operations. Explicit `login` and `logout`
commands continue to manage the saved user session.

For the complete agent workflow, [copy the onboarding prompt](/agents).

## Sign out [#sign-out]

```npm
npx orbytelabs logout
```

Logout revokes the OAuth grant and removes local credentials after success.