Skip to main content

InfraGPT is an AI assistant for interactively managing your infrastructure.

Project description

InfraGPT - Your devops co-pilot 🤖 on Terminal

InfraGPT lets you interactively generate and execute infrastructure commands using large language models (LLMs) in your terminal. InfraGPT works best with OpenAI GPT-4o and Anthropic Claude Sonet models.

PyPI GitHub Workflow Status GitHub Workflow Status

Alt Text

Features

  • Infrastructure Commands: Generate and execute infrastructure commands using natural language
  • Slackbot: Integrate InfraGPT with Slack to generate commands from messages and take actions (coming soon)

Installation

Using pip

Using pip to install packages system-wide is not recommended. pip is a general-purpose package installer for both libraries and apps with no environment isolation. pipx is made specifically for application installation, as it adds isolation yet still makes the apps available in your shell: pipx creates an isolated environment for each application and its associated packages.

pipx does not ship with pip, but installing it is often an important part of bootstrapping your system.

Instead, install InfraGPT using pipx in the next section.

Using pipx

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

# Install infragpt
pipx install infragpt

From Source

  1. Clone the repository:

    git clone https://github.com/73ai/infragpt.git
    cd infragpt
    
  2. Install in development mode:

    pip install -e .
    

Credentials Management

InfraGPT requires API keys to work. There are three ways to provide credentials, in order of priority:

1. Command Line Parameters

# Using OpenAI GPT-4o
infragpt --model gpt4o --api-key "your-openai-api-key"

# Using Anthropic Claude
infragpt --model claude --api-key "your-anthropic-api-key"

2. Configuration File

InfraGPT stores credentials in ~/.config/infragpt/config.yaml and uses them automatically on subsequent runs. This file is created:

  • When you provide credentials interactively
  • Automatically on first run if environment variables are available
  • When you use command line parameters

3. Environment Variables

Set one or more of these environment variables:

# For OpenAI GPT-4o
export OPENAI_API_KEY="your-openai-api-key"

# For Anthropic Claude
export ANTHROPIC_API_KEY="your-anthropic-api-key"

# Optionally specify the model
export INFRAGPT_MODEL="gpt4o"  # or "claude"

Model Selection Rules:

  • If both API keys are set, InfraGPT uses OpenAI by default unless specified otherwise
  • If only one API key is set, the corresponding model is used automatically
  • If a model is explicitly selected (via command line or INFRAGPT_MODEL), the corresponding API key must be available

When environment variables are available, InfraGPT will automatically save the detected model and API key to the configuration file for future use.

If no credentials are found from any of these sources, if an empty API key is detected, or if an invalid API key is provided, InfraGPT will prompt you to select a model and enter your API key interactively at startup, before accepting any commands.

API Key Validation:

  • The application validates API keys by making a small test request to the service provider
  • When entering credentials interactively, API keys are validated immediately
  • Invalid keys from environment variables or the config file are detected at startup
  • The system will continue prompting until valid credentials are provided
  • All validated credentials are automatically saved to the config file

Usage

Launch InfraGPT in interactive mode:

infragpt

Once in interactive mode, enter natural language prompts at the prompt:

> create a new VM instance called test-vm in us-central1 with 2 CPUs

Specify the model to use:

infragpt --model claude

Use keyboard shortcuts in interactive mode:

  • Ctrl+D to exit the application
  • Ctrl+C to clear the current input and start a new prompt

Command History

View your recent command history:

infragpt history

Limit the number of entries:

infragpt history --limit 20

Filter by interaction type:

infragpt history --type command_execution

Export your history to a file:

infragpt history --export history.jsonl

Example Commands

  • "Create a new GKE cluster with 3 nodes in us-central1"
  • "List all storage buckets"
  • "Create a Cloud SQL MySQL instance named 'mydb' in us-west1"
  • "Set up a load balancer for my instance group 'web-servers'"

Options

Interactive Mode Options

  • --model, -m: Choose the LLM model (gpt4o or claude)
  • --api-key, -k: Provide an API key for the selected model
  • --verbose, -v: Enable verbose output

Contributing

For information on how to contribute to InfraGPT, including development setup, release process, and CI/CD configuration, please see the CONTRIBUTING.md file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

infragpt-0.1.50.tar.gz (39.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

infragpt-0.1.50-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

Details for the file infragpt-0.1.50.tar.gz.

File metadata

  • Download URL: infragpt-0.1.50.tar.gz
  • Upload date:
  • Size: 39.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for infragpt-0.1.50.tar.gz
Algorithm Hash digest
SHA256 13a260ec877b424ac0531aa2eb06f0100af0b67c06b8278ea0025b366fd9a883
MD5 62264a648182eb1ab5ac02d32e36e295
BLAKE2b-256 ae9cc11a62438a9753c89a92d3051ba964191281c6dcb0fa78d934089ce97042

See more details on using hashes here.

File details

Details for the file infragpt-0.1.50-py3-none-any.whl.

File metadata

  • Download URL: infragpt-0.1.50-py3-none-any.whl
  • Upload date:
  • Size: 33.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for infragpt-0.1.50-py3-none-any.whl
Algorithm Hash digest
SHA256 afea7957321519fe1c18097d55bc3260583ae5a183109cd61ac6753568f253e7
MD5 610c9ddef0433c4a89c0c9dd5a088c3a
BLAKE2b-256 5f0e76cb437cb07e8b61d0e946c94e65e5c60d1a160a06a547f8707d12235d70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page