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

# Gemini CLI

> Trace Gemini CLI sessions, agent steps, model calls, and tool invocations in Arize AX using the Arize Coding Harness Tracing.

> Trace Gemini CLI sessions, agent steps, model calls, and tool invocations in Arize AX for full observability.

[Gemini CLI](https://github.com/google-gemini/gemini-cli) is Google's open-source command-line agent for Gemini. The [Arize Coding Harness Tracing](https://github.com/Arize-ai/coding-harness-tracing) instruments Gemini CLI sessions and exports [OpenInference](https://github.com/Arize-ai/openinference) spans to Arize AX or Phoenix.

## Launch Arize AX

To get started, sign up for a free [Arize AX account](https://app.arize.com/auth/join) and get your Space ID and API Key:

1. Log in at [app.arize.com](https://app.arize.com)
2. Click **Settings** and copy the **Space ID**
3. Open the **API Keys** tab and create or copy an API key

## Install

### Curl installer

**macOS / Linux:**

```bash theme={null}
curl -sSL https://raw.githubusercontent.com/Arize-ai/coding-harness-tracing/main/install.sh | bash -s -- gemini
```

**Windows (PowerShell):**

```powershell theme={null}
iwr -useb https://raw.githubusercontent.com/Arize-ai/coding-harness-tracing/main/install.bat -OutFile $env:TEMP\install.bat
& $env:TEMP\install.bat gemini
```

### Local clone

```bash theme={null}
git clone https://github.com/Arize-ai/coding-harness-tracing.git
cd coding-harness-tracing
./install.sh gemini        # macOS / Linux
install.bat gemini         # Windows
```

The installer prompts for your backend (Phoenix or Arize AX) and project name, writes credentials to `~/.arize/harness/config.yaml`, and registers the hooks in `~/.gemini/settings.json`.

## Configuration

Credentials live in `~/.arize/harness/config.yaml`. Environment variables override values in `config.yaml` and can be set in your shell profile.

### Phoenix (self-hosted)

```bash theme={null}
export PHOENIX_ENDPOINT="http://localhost:6006"
export ARIZE_PROJECT_NAME="gemini"
export ARIZE_TRACE_ENABLED="true"
```

### Arize AX (cloud)

```bash theme={null}
export ARIZE_API_KEY="<your-api-key>"
export ARIZE_SPACE_ID="<your-space-id>"
export ARIZE_PROJECT_NAME="gemini"
export ARIZE_TRACE_ENABLED="true"
```

### Redaction controls

Each `ARIZE_LOG_*` flag accepts `"true"` or `"false"` and defaults to `"true"`. Set to `"false"` to opt out per category:

```bash theme={null}
export ARIZE_LOG_PROMPTS="false"
export ARIZE_LOG_TOOL_DETAILS="false"
export ARIZE_LOG_TOOL_CONTENT="false"
```

| Flag                     | Redacts                                 |
| :----------------------- | :-------------------------------------- |
| `ARIZE_LOG_PROMPTS`      | User prompt and assistant response text |
| `ARIZE_LOG_TOOL_DETAILS` | Tool names and arguments                |
| `ARIZE_LOG_TOOL_CONTENT` | Tool call output content                |

## Observe

Once tracing is enabled, Gemini CLI activity is streamed to Arize AX. You'll see:

* **Session traces** — each session bracketed by `SessionStart` and `SessionEnd`
* **Agent spans** — paired `BeforeAgent` / `AfterAgent` events for each agent step
* **LLM spans** — paired `BeforeModel` / `AfterModel` events with model info and tokens
* **Tool spans** — paired `BeforeTool` / `AfterTool` events with input, output, and duration
* **Session grouping** — all spans from the same session grouped by `session_id`

### Hooks Captured

| Hook           | Span Kind | Description                                            |
| :------------- | :-------- | :----------------------------------------------------- |
| `SessionStart` | CHAIN     | Session initialized                                    |
| `BeforeAgent`  | CHAIN     | Agent step started, records input                      |
| `AfterAgent`   | CHAIN     | Agent step completed, records output                   |
| `BeforeModel`  | LLM       | Model call started, records prompt and model           |
| `AfterModel`   | LLM       | Model call completed, records output and tokens        |
| `BeforeTool`   | TOOL      | Tool invocation started, records name and input        |
| `AfterTool`    | TOOL      | Tool invocation completed, records output and duration |
| `SessionEnd`   | CHAIN     | Session teardown, state file cleanup                   |

## Reference

For the full list of environment variables, default file paths, and troubleshooting steps, see the [Gemini tracing README](https://github.com/Arize-ai/coding-harness-tracing/blob/main/tracing/gemini/README.md).

## Uninstall

```bash theme={null}
curl -sSL https://raw.githubusercontent.com/Arize-ai/coding-harness-tracing/main/install.sh | bash -s -- uninstall gemini
```

## Resources

<CardGroup>
  <Card icon="github" href="https://github.com/Arize-ai/coding-harness-tracing" title="Arize Coding Harness Tracing" horizontal />

  <Card icon="github" href="https://github.com/Arize-ai/openinference" title="OpenInference" horizontal />

  <Card icon="github" href="https://github.com/google-gemini/gemini-cli" title="Gemini CLI" horizontal />
</CardGroup>
