AI agents for data querying, Python analysis, and chart generation.
Project description
๐ง oneprompt
โ ๏ธ License Notice: This project is licensed under the PolyForm Shield License 1.0.0.
โ Free for personal use
โ Free for internal business use
โ Prohibited to build a competing product or serviceFor commercial licenses, OEM integration, or questions: contact@oneprompt.com
AI agents for data querying, analysis, and chart generation.
Connect your LLM API key and PostgreSQL database โ query data in natural language, run Python analysis, and generate interactive charts in minutes.
โก Quick Start
1. Install
Choose the package based on your runtime:
| Use case | Package | Includes |
|---|---|---|
| Cloud-only SaaS integration | oneprompt-sdk |
Lightweight HTTP client (oneprompt_sdk) |
| Local/self-hosted MCP stack | oneprompt |
Full SDK + op CLI + Docker workflow |
pip install oneprompt-sdk
or:
pip install oneprompt
Prerequisite for
oneprompt(full/local only): Docker must be installed and running.
2. Initialize a project
op init
When prompted, choose 0/local for this local Docker quickstart.
This scaffolds your working directory with:
| File | Purpose |
|---|---|
.env |
Configuration โ add your API key and database URL |
DATABASE.md |
Schema documentation template for your database |
docker-compose.yml |
Docker stack for the MCP servers |
example.py |
Ready-to-run example script |
3. Configure
Edit .env with your credentials:
LLM_PROVIDER=google
LLM_API_KEY=your-llm-api-key
DATABASE_URL=postgresql://user:pass@localhost:5432/mydb
Get your Gemini API key at Google AI Studio.
4. Document your schema
Edit DATABASE.md to describe your tables, columns, and relationships. The more detail you provide, the better the AI agent will write SQL queries. See Schema Documentation for the recommended format.
5. Start services
op start
This builds and launches 4 Docker containers:
| Service | Port | Description |
|---|---|---|
| Artifact Store | 3336 | Generated file storage (CSV, JSON, HTML) |
| PostgreSQL MCP | 3333 | SQL query execution engine |
| Chart MCP | 3334 | AntV (G2Plot) chart generation |
| Python MCP | 3335 | Sandboxed Python execution for analysis |
6. Use it!
import oneprompt as op
client = op.Client() # Reads from .env automatically
# 1. Query your database with natural language
result = client.query("What are the top 10 products by revenue?")
print(result.summary)
print(result.preview)
# 2. Generate a chart from the results
chart = client.chart("Bar chart of top products", data_from=result)
print(f"Chart saved to: {chart.artifacts[0].path}")
# 3. Run Python analysis
analysis = client.analyze("Calculate month-over-month growth", data_from=result)
print(analysis.summary)
Or run the generated example directly:
python example.py
Cloud-only quickstart (no Docker)
import oneprompt_sdk as op
client = op.Client(oneprompt_api_key="op_live_...")
result = client.query("Top products by revenue", dataset_id="ds_123")
print(result.summary)
๐ Python SDK
Client
The Client class is the main entry point. It reads configuration from .env, environment variables, or explicit parameters:
import oneprompt as op
# Option A: Read from .env (recommended)
client = op.Client()
# Option B: Pass credentials directly
client = op.Client(
llm_api_key="your-key",
database_url="postgresql://user:pass@localhost:5432/mydb",
schema_docs_path="./DATABASE.md",
)
Cloud-only SDK:
import oneprompt_sdk as op
client = op.Client(oneprompt_api_key="op_live_...")
Three core methods
| Method | Description | Returns |
|---|---|---|
client.query(question, ...) |
Query your database with natural language | AgentResult โ SQL results + preview data |
client.chart(description, data_from=...) |
Generate an interactive AntV chart | AgentResult โ HTML chart file |
client.analyze(instruction, data_from=...) |
Run Python analysis code | AgentResult โ analysis results + output files |
Cloud Dataset Selection
When using cloud mode (ONEPROMPT_API_KEY set), query() supports two dataset sources:
# 1) Stored dataset
result = client.query("Top products by revenue", dataset_id="ds_123")
# 2) Ephemeral dataset (no credential persistence)
result = client.query(
"Top products by revenue",
database_url="postgresql://user:pass@host:5432/db",
schema_docs="# optional schema docs",
)
Rules:
- Use exactly one of
dataset_idordatabase_url. schema_docsis supported withdatabase_urlin cloud mode.- Local mode continues to use your configured
DATABASE_URL.
AgentResult
Every method returns an AgentResult with:
| Property | Type | Description |
|---|---|---|
ok |
bool |
Whether the operation succeeded |
summary |
str | None |
Human-readable summary of the result |
preview |
list[dict] |
Preview rows (for data queries) |
columns |
list[str] |
Column names (for data queries) |
artifacts |
list[ArtifactRef] |
Generated files (CSV, JSON, HTML) |
error |
str | None |
Error message if ok is False |
run_id |
str |
Unique identifier of this execution |
session_id |
str |
Session the execution belongs to |
ArtifactRef
Each artifact in result.artifacts has:
| Property | Type | Description |
|---|---|---|
id |
str |
Unique artifact identifier |
name |
str |
Filename (e.g. top_products.csv) |
type |
str | None |
"data", "result", or "chart" |
path |
str | None |
Local file path (after download) |
# Read artifact content
artifact = result.artifacts[0]
text = artifact.read_text() # As string
data = artifact.read_bytes() # As bytes
Chaining agents
Results can be piped between agents using data_from:
# Query โ Chart
data = client.query("Revenue by month for 2025")
chart = client.chart("Line chart of revenue trend", data_from=data)
# Query โ Analyze
data = client.query("All transactions this quarter")
stats = client.analyze("Calculate descriptive statistics", data_from=data)
# Query โ Analyze โ Chart
data = client.query("Daily active users last 90 days")
trend = client.analyze("Calculate 7-day moving average", data_from=data)
chart = client.chart("Line chart with original and smoothed data", data_from=trend)
๐ REST API
For integration with non-Python applications, start a local API server:
op api
The API runs at http://localhost:8000 with these endpoints:
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check |
POST |
/agents/data |
Run natural language data queries |
POST |
/agents/python |
Run Python analysis |
POST |
/agents/chart |
Generate chart visualizations |
POST |
/sessions |
Create a new session |
GET |
/sessions |
List sessions |
GET |
/runs/{run_id}/artifacts/{artifact_id} |
Download a generated artifact |
See docs/reference/rest-api.md for the full API reference.
๐ฅ๏ธ CLI Commands
op init # Scaffold a new project (.env, DATABASE.md, example.py, docker-compose.yml)
op start # Build and start all MCP services (Docker Compose)
op stop # Stop all services
op status # Check which services are running
op logs # Tail service logs
op api # Start the local REST API server
Run op --help for details, or op <command> --help for command-specific options.
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Your App / SDK Client / REST API โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ AI Agents (Gemini + LangChain) โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ Data โ โ Python โ โ Chart โ โ
โ โ Agent โ โ Agent โ โ Agent โ โ
โ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โ
โโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโค
โ MCP Servers (Docker) โ
โ โโโโโโดโโโโโโ โโโโโโดโโโโโโ โโโโโโดโโโโโโ โ
โ โ Postgres โ โ Python โ โ Chart โ โ
โ โ MCP โ โ MCP โ โ MCP โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Artifact Store (generated file storage) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
See docs/architecture/overview.md for the full architecture documentation.
๐ Schema Documentation
For best results, describe your database schema in DATABASE.md. This gives the AI context to write accurate SQL:
# Database Schema
## Tables
### products
| Column | Type | Description |
|--------|------|-------------|
| id | integer | Primary key |
| name | text | Product name |
| price | numeric | Unit price |
| category | text | Product category |
### orders
| Column | Type | Description |
|--------|------|-------------|
| id | integer | Primary key |
| product_id | integer | FK โ products.id |
| quantity | integer | Units ordered |
| created_at | timestamp | Order date |
Then point the client to it:
client = op.Client(schema_docs_path="./DATABASE.md")
See docs/guides/schema-docs.md for the complete guide and best practices.
๐ง Configuration
Configuration is loaded in this order (later overrides earlier):
.envfile in the current directory- Environment variables
- Arguments passed to
op.Client()
| Variable | Description | Default |
|---|---|---|
LLM_API_KEY |
LLM provider API key | Required |
DATABASE_URL |
PostgreSQL connection string | Required |
LLM_MODEL |
Provider model name | provider default |
OP_SCHEMA_DOCS_PATH |
Path to your DATABASE.md |
./DATABASE.md |
OP_DATA_DIR |
Directory for local data/state | ./op_data |
OP_PORT |
REST API server port | 8000 |
OP_ARTIFACT_PORT |
Artifact store port | 3336 |
OP_POSTGRES_MCP_PORT |
PostgreSQL MCP port | 3333 |
OP_CHART_MCP_PORT |
Chart MCP port | 3334 |
OP_PYTHON_MCP_PORT |
Python MCP port | 3335 |
OP_MAX_RECURSION |
Max agent iterations | 10 |
DATASET_TOKEN_SECRET |
Shared secret to encrypt dataset tokens between Data Agent and Postgres MCP | unset |
DATASET_TOKEN_TTL_SECONDS |
TTL for encrypted dataset tokens | 900 |
MCP_AUTH_TOKEN |
Optional shared token for internal MCP auth | unset |
POSTGRES_ALLOWED_HOSTS |
Comma-separated DSN host allowlist (optional hardening) | unset |
POSTGRES_ALLOW_PRIVATE_HOSTS |
Allow private/local DSN hosts | true |
POSTGRES_BLOCK_METADATA_HOSTS |
Block cloud metadata endpoints from DSN | true |
POSTGRES_CONNECT_TIMEOUT_SEC |
PostgreSQL connection timeout | 10 |
POSTGRES_QUERY_TIMEOUT_MS |
SQL statement timeout | 30000 |
POSTGRES_EXPORT_MAX_ROWS |
Max rows exported per query (0 = no cap) |
0 |
See docs/guides/configuration.md for the complete reference.
๐ Documentation
Full documentation is available at docs.oneprompt.com or in the docs/ directory:
| Section | Contents |
|---|---|
| Getting Started | Installation and quick start guide |
| Guides | Configuration, schema docs, agent chaining |
| Reference | Python SDK, REST API, and CLI reference |
| Architecture | System design, components, and data flow |
๐ License
PolyForm Shield License 1.0.0 โ see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oneprompt-0.1.2.tar.gz.
File metadata
- Download URL: oneprompt-0.1.2.tar.gz
- Upload date:
- Size: 64.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c6bc76192c2fefbd0b5b24f6c2f3321b2fb2dddcd5c94b89da794d8858cc53c
|
|
| MD5 |
e3e4656d17d6f2d2afb4cb2a687cfc0d
|
|
| BLAKE2b-256 |
23395530a48741d3d92720d966d09ce5630e3ab5bd2c3b2a6c7999f8c12a5b06
|
Provenance
The following attestation bundles were made for oneprompt-0.1.2.tar.gz:
Publisher:
publish.yml on oneprompteu/oneprompt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oneprompt-0.1.2.tar.gz -
Subject digest:
3c6bc76192c2fefbd0b5b24f6c2f3321b2fb2dddcd5c94b89da794d8858cc53c - Sigstore transparency entry: 973360745
- Sigstore integration time:
-
Permalink:
oneprompteu/oneprompt@1aba243fce4294694de47b7df72f9922d0bdbd61 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/oneprompteu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1aba243fce4294694de47b7df72f9922d0bdbd61 -
Trigger Event:
release
-
Statement type:
File details
Details for the file oneprompt-0.1.2-py3-none-any.whl.
File metadata
- Download URL: oneprompt-0.1.2-py3-none-any.whl
- Upload date:
- Size: 85.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76dfa1f09af82c60746b851924e7234fa2e16d4ad65982e39668f717a937c93e
|
|
| MD5 |
b82d58c5e271a2dac94ce34fe7d22c3f
|
|
| BLAKE2b-256 |
fcba96012dd397b804cc83f8572739319e6fa2a664c212322ddf4bfc016afd53
|
Provenance
The following attestation bundles were made for oneprompt-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on oneprompteu/oneprompt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oneprompt-0.1.2-py3-none-any.whl -
Subject digest:
76dfa1f09af82c60746b851924e7234fa2e16d4ad65982e39668f717a937c93e - Sigstore transparency entry: 973360747
- Sigstore integration time:
-
Permalink:
oneprompteu/oneprompt@1aba243fce4294694de47b7df72f9922d0bdbd61 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/oneprompteu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1aba243fce4294694de47b7df72f9922d0bdbd61 -
Trigger Event:
release
-
Statement type: