This guide provides detailed instructions for getting started with Nia CLI, from installation to advanced usage.

Prerequisites

Before installing Nia CLI, ensure you have:

To verify your Python installation:

python --version
# or
python3 --version

Installation

1

Install Nia CLI

Using pip (recommended):

pip install nia-cli

Alternatively, use pipx for an isolated installation:

# Install pipx if you don't have it
pip install pipx
pipx ensurepath

# Install Nia CLI in isolated environment
pipx install nia-cli

If you’re using a virtual environment, make sure it’s activated before installation.

2

Verify installation

Confirm that Nia CLI was installed correctly:

nia --version

You should see the version number of the installed CLI.

3

Get your API key

If you don’t already have a Nia API key:

  1. Go to app.trynia.ai
  2. Sign up or log in to your account
  3. Navigate to API settings
  4. Generate a new API key

Keep your API key secure. Do not share it or expose it in public repositories.

4

Login to Nia

Authenticate your CLI with your API key:

nia login

When prompted, enter your API key. Alternatively, provide it directly:

nia login YOUR_API_KEY

Your API key will be securely stored in ~/.nia/config.json.

Basic Configuration

After installation and authentication, let’s set up your working environment:

1

View available repositories

If you’ve already indexed repositories through the Nia web interface, you can list them:

nia list

This will show all repositories you have access to, including their IDs, names, branches, and indexing status.

2

Index a new repository

To add a GitHub repository for Nia to analyze:

nia create owner/repo

For example:

nia create nozomio-labs/sample-project

By default, Nia will index the “main” branch. To specify a different branch:

nia create owner/repo -b develop

Initial indexing may take several minutes depending on the size of the repository.

3

Check indexing status

Monitor the progress of repository indexing:

nia status REPOSITORY_ID

Replace REPOSITORY_ID with the ID returned when you created the repository.

4

Set a default repository

To avoid specifying a repository ID in every command:

nia select REPOSITORY_ID

Alternatively, run nia select without arguments to see a list of repositories to choose from.

Starting Your First Chat

Now that you’ve set up Nia CLI and indexed a repository, let’s start interacting with your code:

1

Begin a chat session

Start chatting with your default repository:

nia chat

Or specify a repository:

nia chat REPOSITORY_ID

The chat interface will open in your terminal.

2

Ask questions about your code

Now you can ask Nia about your codebase. Try starting with these questions:

> What is the structure of this repository?
> How does the authentication system work?
> Where is the main entry point for the application?
> Explain the database schema and relationships

Be specific in your questions to get the most precise answers.

3

Explore multi-repository functionality

For projects that span multiple repositories, you can include additional repositories in your chat:

nia chat REPOSITORY_ID --additional REPO_ID2,REPO_ID3

This is particularly useful for microservice architectures or projects with shared dependencies.

4

End your session

When you’re finished, exit the chat:

> exit

Advanced Workflow

Effective Chat Strategies

Start Broad, Then Narrow

Begin with general questions about architecture before diving into specific components

Reference Specific Files

When asking about implementation details, mention file paths for more precise answers

Chain Your Questions

Build on previous questions to maintain context through your exploration

Use Multiple Sessions

Create different chat sessions for different aspects of your codebase

Example Chat Sequence

Configuration File Reference

The Nia CLI configuration file is located at ~/.nia/config.json. Here’s a sample configuration with explanations:

{
  "api_key": "nia_api_key_example123456789",  // Your Nia API key
  "default_repo": "repo_abcdefg123456",       // Currently selected default repository
  "api_url": "https://api.trynia.ai",         // API endpoint (can be customized)
  "user": {
    "name": "Your Name",                      // User information
    "email": "your.email@example.com"
  },
  "model_preferences": {
    "default": "claude-3-sonnet"              // Default model for chat
  },
  "terminal": {
    "colored_output": true,                   // Enable colored output in terminal
    "max_width": 100                          // Maximum width for text display
  }
}

You can manually edit this file if needed, but it’s recommended to use the CLI commands for configuration.

Resolving Common Issues

Best Practices

Regular Updates

Keep Nia CLI up-to-date:

pip install --upgrade nia-cli

Repository Freshness

Re-index after major code changes to ensure accurate answers

Specific Questions

Ask focused questions rather than overly broad ones

Terminal Session

Use a terminal with good Unicode support for optimal display

Secure Storage

Never share your API key or include it in scripts

Multiple Repositories

Set up different projects for different codebases

Going Further

1

Explore integrations

Beyond the CLI, Nia AI offers integrations with:

  • Slack for team-wide code assistance
  • GitHub for automated code reviews
  • VS Code and other editors through extensions

Check the Integrations Overview for details.

2

Automate workflows

Incorporate Nia CLI into your development workflows:

  • Add repository indexing to CI/CD pipelines
  • Create scripts to automate common queries
  • Integrate with project documentation tools
3

Alternative Access Methods

If you prefer not to use the CLI, Nia provides multiple ways to access its functionality:

4

Join the community

Connect with other Nia users:

  • Join our Discord community
  • Share your use cases and feedback
  • Learn from how others are using Nia

For any issues not covered in this guide, contact Nia support at arlan@nozomio.com or visit our Discord community.