Skip to content

Latest commit

 

History

History
209 lines (155 loc) · 6 KB

README.md

File metadata and controls

209 lines (155 loc) · 6 KB

pre.dev API Client Libraries

Official client libraries for the Pre.dev Architect API in Python and Node.js/TypeScript.

Generate comprehensive software specifications using AI-powered analysis with a simple, consistent API across both languages.

📦 Packages

This repository contains two client libraries with matching APIs:

Python Package (predev-api-python/)

Python client for the Pre.dev Architect API with full type hints support.

Quick Start:

from predev_api import PredevAPI

predev = PredevAPI(api_key="your_api_key")
result = predev.fast_spec("Build a task management app")

📖 Python Documentation

Node.js/TypeScript Package (predev-api-node/)

Modern TypeScript/Node.js client using ES6+ modules with full type definitions.

Quick Start:

import { PredevAPI } from 'predev-api';

const predev = new PredevAPI({ apiKey: 'your_api_key' });
const result = await predev.fastSpec({ input: 'Build a task management app' });

📖 Node.js Documentation

🚀 Features

Both libraries provide:

  • Build with the agent (client.agent): create a project from a prompt, stream the agent's work, build the plan, check status and credits
  • Fast Spec Generation: Comprehensive specifications quickly - perfect for MVPs and prototypes
  • Deep Spec Generation: Ultra-detailed specifications for complex systems with enterprise-grade depth
  • Async Spec Generation: Non-blocking async methods for long-running requests
  • Status Tracking: Check the status of async specification generation requests
  • Enterprise Support: Both solo and enterprise authentication methods
  • Type Safety: Full type hints (Python) and TypeScript definitions (Node.js)
  • Direct Spec Data: JSON + markdown payloads returned inline alongside S3 URLs
  • Error Handling: Custom exceptions for different error scenarios
  • Modern Conventions: Latest language features and best practices

🔑 Authentication

Get your API key from the pre.dev dashboard

📚 API Endpoints

Fast Spec

Generate comprehensive specifications quickly with balanced depth and speed.

Python:

result = predev.fast_spec(
    input_text="Your project description"
)

TypeScript:

const result = await predev.fastSpec({
  input: "Your project description"
});

Deep Spec

Generate ultra-detailed specifications for complex systems with comprehensive analysis.

Python:

result = predev.deep_spec(
    input_text="Your complex project description"
)

TypeScript:

const result = await predev.deepSpec({
  input: "Your complex project description"
});

Async Spec Generation

Generate specifications asynchronously for long-running requests.

Python:

# Fast spec async
result = predev.fast_spec_async(
    input_text="Your project description"
)
# Returns: AsyncResponse with specId

# Deep spec async
result = predev.deep_spec_async(
    input_text="Your complex project description"
)
# Returns: AsyncResponse with specId

TypeScript:

// Fast spec async
const result = await predev.fastSpecAsync({
  input: "Your project description"
});
// Returns: AsyncResponse with specId

// Deep spec async
const result = await predev.deepSpecAsync({
  input: "Your complex project description"
});
// Returns: AsyncResponse with specId

Get Spec Status

Check the status of an async specification generation request.

Python:

status = predev.get_spec_status("spec_id")

TypeScript:

const status = await predev.getSpecStatus("spec_id");

Build with the agent

const { projectId } = await predev.agent.createProject({ prompt: 'A habit tracker' });
for await (const ev of predev.agent.stream(projectId)) {
  if (ev.event === 'message.delta') process.stdout.write(ev.data.delta);
}
await predev.agent.buildNext(projectId);
console.log(await predev.agent.status(projectId));
project_id = predev.agent.create_project("A habit tracker")["projectId"]
for event in predev.agent.stream(project_id):
    if event["event"] == "message.delta":
        print(event["data"]["delta"], end="")
predev.agent.build_next(project_id)
print(predev.agent.status(project_id))

Methods: createProject / create_project, send, stream, buildNext / build_next, buildAll / build_all, status, stop. See each package README.

🚢 Releasing

Releases publish from CI (.github/workflows/release.yml) when a v* tag is pushed:

  1. Bump the version in predev-api-node/package.json, predev-api-python/setup.py and predev-api-python/predev_api/__init__.py (all three must match), merge to main.
  2. Tag the merge commit and push the tag: git tag v1.2.0 && git push origin v1.2.0.
  3. The workflow checks the tag matches all three versions, runs make check, then publishes predev-api to npm (with provenance) and to PyPI.

Repo secrets: NPM_TOKEN (npm automation token for predev-api) and PYPI_API_TOKEN (PyPI API token scoped to predev-api). scripts/deploy.sh remains for manual releases.

📖 Documentation

💡 Examples

Both packages include comprehensive examples in their respective examples/ directories:

Python Examples

cd predev-api-python
export PREDEV_API_KEY="your_api_key"
python examples/fast_spec_example.py
python examples/deep_spec_example.py
python examples/get_status_example.py

TypeScript Examples

cd predev-api-node
export PREDEV_API_KEY="your_api_key"
npm run build
npx tsx examples/fastSpecExample.ts
npx tsx examples/deepSpecExample.ts
npx tsx examples/getStatusExample.ts

🔗 Links