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

# Push and poll using the Openlayer CLI

> Learn how to push and poll your artifacts using the Openlayer CLI

As discussed in the [development mode overview](https://docs.openlayer.com/development/overview.md),
to make Openlayer part of your pipeline, you must set up a way to push your artifacts
to the Openlayer platform after each development cycle.

This guide shows how to use the **Openlayer CLI** to **push artifacts**
and **retrieve test results**.

> [!TIP]
>
> To follow this guide, feel free to use one of the template projects from the [Template gallery](https://github.com/openlayer-ai/templates).
> We use the [OpenAI in Python](https://github.com/openlayer-ai/templates/tree/main/python/llms/openai-chatbot) as an example.

## Directory structure

Before you start, make sure that the directory you want to push to Openlayer adheres to one of the
options below.

![Directory structure](https://mintcdn.com/openlayer-44/jN8MTVdaEnRVD4sY/images/guides/options.png?fit=max\&auto=format\&n=jN8MTVdaEnRVD4sY\&q=85\&s=b02793a99196068fa7a0e01a4698eaf3)

In the first option, besides the `openlayer.json`, there is a run script (`openlayer_run.py`).
This option represents the scenario where Openlayer will use your script to get your model
outputs for your datasets.

On the other hand, option 2 illustrates the situation when
you already provide your model's outputs for your datasets. Refer to the [Configuring
output generation](https://docs.openlayer.com/development/configuring-output-generation.md) page for details.

> [!NOTE]
>
> Option 1 is more common. However, option 2 is suitable for users who don't
> want to give Openlayer access to their source code and for users whose
> execution runtime is not supported by Openlayer.

## Pushing to Openlayer

The quickest path is [`openlayer init`](https://docs.openlayer.com/api-reference/cli/commands/init). It signs you in,
creates or links the Openlayer project, and offers to run your first push — so `login` and
`link` are no longer separate steps:

**1. Install the Openlayer CLI**

Run the [install command](https://docs.openlayer.com/api-reference/cli/overview.md#installing-the-openlayer-cli) for your
operating system.

**2. Run openlayer init**

Inside your directory, run:

```bash theme={null}
openlayer init
```

Sign in when prompted, create or link an Openlayer project, then choose **Development
mode**. `init` writes an `openlayer.json` seeded for your project type and offers to push
your first commit for you. Refer to the
[init command reference](https://docs.openlayer.com/api-reference/cli/commands/init.md) for the full walkthrough.

**3. Push after each change**

Once the project is set up, every later development cycle is just:

```bash theme={null}
openlayer push
```

### Setting up step by step

If you would rather run each step yourself — or you are connecting a directory to a project
that already exists — use the individual commands instead:

**1. Login to Openlayer using the CLI**

Inside your directory, run the command:

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

This asks for a profile name, then whether to sign in through your **browser** or with an
**API key**. The API key path also asks for the Openlayer API URL (which should be kept as
`https://api.openlayer.com` if you are using app.openlayer.com) and for your API key (which
you can [find here](https://docs.openlayer.com/workspace-and-projects/find-your-api-key.md)).

```bash theme={null}
> Enter a name for this profile: default
> Log in to Openlayer: API Key
> Enter the Openlayer API URL: https://api.openlayer.com
> Enter your API key: ********************************
> Done! The Openlayer CLI is configured for <Your username> under the workspace <Your workspace name> (profile: default)
```

In CI, pass `--api-key` or set `OPENLAYER_API_KEY` and `openlayer login` skips the prompts
entirely. Refer to the [login command reference](https://docs.openlayer.com/api-reference/cli/commands/login.md) for more
information.

**2. Link to an Openlayer project**

Then, run the command:

```bash theme={null}
openlayer link
```

You must answer a few questions, such as whether to create a new project on Openlayer,
the project directory, and others.

```bash theme={null}
? Set up “~/Desktop/openai-chatbot”? Yes
? Link to existing project? No
? What's your project's name? openai-chatbot
? What's the directory of your project? ./
✅ Linked to openlayer/openai-chatbot (created .openlayer)
```

Refer to the [link command reference](https://docs.openlayer.com/api-reference/cli/commands/link.md) for more information.

**3. Push to the Openlayer project**

Finally, run:

```bash theme={null}
openlayer push
```

This command creates and pushes a new commit to your Openlayer project and prints a
link to it. It then waits for the evaluation of your tests, printing each processing
step as it runs:

```bash theme={null}
Running "openlayer validate"
Config is valid
Running "openlayer bundle"
Bundle completed [9ms]
Running "openlayer upload"
Uploading bundle [0.29 MB]...
Upload completed [5.904s]
Push completed [7.423s]
View the commit in Openlayer: https://app.openlayer.com/openlayer/7dd13019-5bba-4138-aeb0-6a60226c31d1?mode=development&projectVersionId=5979c341-fa08-4a72-9bc9-c7e6296ee9dc
⋯ Queued [0s]
⟳ Running setup [4s]
⟳ Computing model outputs (6.9%) [12s]
⠇ Computing model outputs (48.2%) [31s]
```

When processing finishes, `push` prints the final status, such as
`✓ Processed commit [1m40s]`, followed by the test results.

Refer to the [push command reference](https://docs.openlayer.com/api-reference/cli/commands/push.md) for more information.

## Poll the results

After following the steps above, you should see a new commit in your Openlayer project.
You can view the test results using the `openlayer inspect` CLI command:

```bash theme={null}
Version Information:
-------------------
Version ID: 5979c341-fa08-4a72-9bc9-c7e6296ee9dc
More Details: https://app.openlayer.com/openlayer/7dd13019-5bba-4138-aeb0-6a60226c31d1?mode=development&projectVersionId=5979c341-fa08-4a72-9bc9-c7e6296ee9dc
Date Created: April 29, 2024 at 3:54 PM
Commit Message: Pushed from Openlayer CLI
Source of Commit: cli
Status: completed
Status Message: Generated insights

Test Result Summary:
-------------------
|     TYPE      | COUNT |
|---------------|-------|
| Passing Tests | 4     |
| Failing Tests | 1     |
| Total Tests   | 7     |
|---------------|-------|

Failing / Errored Tests:
-------------
| #  |           TEST NAME            | DETAILS |
+----+--------------------------------+---------+
| 01 | Validation answer relevancy >= | failing |
|    | 0.8                            |         |
+----+--------------------------------+---------+
```

If the push fails (status `failed`), you can check the logs on the Openlayer platform to debug the issue.
Refer to the [inspect command reference](https://docs.openlayer.com/api-reference/cli/commands/inspect.md) for more information.


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