prompt2json

command module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 17 Imported by: 0

README

GitHub release License Active Go Report Card

prompt2json

Unix-style CLI that sends a system instruction, required JSON Schema, and text or file inputs to Vertex AI (Gemini models) and returns schema-validated JSON for easy batch processing.

Overview

prompt2json is designed for composable command line workflows:

  • Turn free form prompts into machine reliable JSON for automation and batch workflows
  • Enforce output shape using JSON Schema rather than post processing heuristics
  • Make Gemini usable in shell pipelines, scripts, and data processing jobs
  • Enable repeatable, inspectable prompt experiments from the command line
  • Treat LLM calls as deterministic interfaces, not interactive sessions

Installation

go install github.com/UnitVectorY-Labs/prompt2json@latest

Build from source:

git clone https://github.com/UnitVectorY-Labs/prompt2json.git
cd prompt2json
go build -o prompt2json

Examples

The following example is a simple demonstration of how input text can be classified specifying the systems instructions and critically the JSON schema that defines and enforces the expected output structure.

export GOOGLE_CLOUD_PROJECT=example-project
echo "this is great" | prompt2json \
    --system-instruction "Classify sentiment" \
    --schema '{"type":"object","properties":{"sentiment":{"type":"string","enum":["POSITIVE","NEGATIVE","NEUTRAL"]},"confidence":{"type":"integer","minimum":0,"maximum":100}},"required":["sentiment","confidence"]}' \
    --location us-central1 \
    --model gemini-2.5-flash

The output will be minified JSON matching the specified schema:

{"sentiment":"POSITIVE","confidence":95}

Usage

The prompt2json application follows Unix-style CLI conventions and can be used in shell pipelines, scripts, and data processing jobs.

prompt2json [OPTIONS]
Authentication

prompt2json uses Google Application Default Credentials.

Authenticate locally with:

gcloud auth application-default login

Or via service account:

export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json

For complete usage documentation including all options, environment variables, and command line conventions, see the Usage documentation.

Limitations

  • Image attachments are limited to 7 MB each before base64 encoding
  • Total request size is limited to roughly 20 MB
  • Supported attachment types are PNG, JPEG, WebP, and PDF
  • Limitations of Gemini models apply

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL