OpenAI + Steampipe
OpenAI is an Artificial Intelligence research and development company that provides APIs for general models.
Steampipe is an open-source zero-ETL engine to instantly query cloud APIs using SQL.
Generate completions for a given text prompt in your OpenAI account:
select completionfrom openai_completionwhere prompt = 'Write a tagline for an ice cream shop.';
+-------------------------------------------------------+| completion |+-------------------------------------------------------+| 1. Cool down with a scoop of our delicious ice cream! || 2. Indulge your cravings with creamy goodness! || 3. Sweeten your day with a scoop of our tasty treats! |+-------------------------------------------------------+
Documentation
Get started
Install
Download and install the latest OpenAI plugin:
steampipe plugin install openai
Credentials
Item | Description |
---|---|
Credentials | OpenAI requires an API Key for all requests. |
Permissions | API Keys have the same permissions as the user who creates them, and if the user permissions change, the API key permissions also change. |
Radius | Each connection represents a single OpenAI Installation. |
Resolution | 1. Credentials explicitly set in a steampipe config file (~/.steampipe/config/openai.spc )2. Credentials specified in environment variables, e.g., OPENAI_API_KEY . |
Configuration
Installing the latest openai plugin will create a config file (~/.steampipe/config/openai.spc
) with a single connection named openai
:
connection "openai" { plugin = "openai"
# Get your API key at https://beta.openai.com/account/api-keys # This can also be set via the `OPENAI_API_KEY` environment variable. api_key = "sk-CGG8G29a47ViRhvVsCGPT8BlbkFJBvFr65mZcMJWH8fay..."}
Credentials from Environment Variables
The OpenAI plugin will use the standard OpenAI environment variables to obtain credentials only if other arguments (api_key
) are not specified in the connection:
export OPENAI_API_KEY=sk-CGG8G29a47ViRhvVsCGPT8BlbkFJBvFr65mZcMJWH8fayZO8
Postgres FDW
This plugin is available as a native Postgres FDW. Unlike Steampipe CLI, which ships with an embedded Postgres server instance, the Postgres FDW can be installed in any supported Postgres database version.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_postgres_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/postgres.sh)" -- openai
The installer will prompt you for the plugin name and version, download and install the appropriate files for your OS, system architecture, and Postgres version.
To configure the Postgres FDW, you will create an extension, foreign server, and schema and import the foreign schema.
CREATE EXTENSION IF NOT EXISTS steampipe_postgres_openai;CREATE SERVER steampipe_openai FOREIGN DATA WRAPPER steampipe_postgres_openai OPTIONS (config '<your_config>');CREATE SCHEMA openai;IMPORT FOREIGN SCHEMA openai FROM SERVER steampipe_openai INTO openai;
SQLite Extension
This plugin is available as a SQLite Extension, making the tables available as SQLite virtual tables.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_sqlite_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/sqlite.sh)" -- openai
The installer will prompt you for the plugin name, version, and destination directory. It will then determine the OS and system architecture, and it will download and install the appropriate package.
To configure the SQLite extension, load the extension module and then run the steampipe_configure_openai
function to configure it with plugin-specific options.
$ sqlite3sqlite> .load ./steampipe_sqlite_extension_openai.sosqlite> select steampipe_configure_openai('<your_config>');
Export
This plugin is available as a standalone Export CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- openai
You can pass the configuration to the command with the --config
argument:
steampipe_export_openai --config '<your_config>' <table_name>