A short request can be a useful starting point without being a complete execution contract. Enhancement adds structure without replacing the user's wording.

When the request includes recognizable signals, the engine carries them into the structured sections as explicit requirements: output format, hard constraints, audience, runtime conditions, evidence, and success criteria. Clarifying questions are reserved for missing information that blocks reliable progress.

01

Preserve the request

The original input remains visible and is included verbatim in the enhanced prompt.

02

Add execution detail

The output covers constraints, edge cases, assumptions, and a practical way to proceed.

03

Make completion checkable

The result asks for inspectable output and verification instead of an unsupported success claim.

Original: Build a small API for my team

Enhanced prompt (excerpt):
# Execution requirements
- Preserve compatibility and cover errors and edge cases.
# Output requirements
- Provide runnable code with verification steps.
# Completion criteria
- Make the result inspectable and reproducible.

PROFILES IN PRACTICE

One engine, different kinds of work.

The enhancer keeps the same safety contract while changing the execution emphasis for planning, coding, analysis, writing, research, and general tasks.

Planning Plan a small API adds milestones, dependencies, risks, owners, and completion signals.
Coding Fix this endpoint adds compatibility boundaries, error paths, runnable changes, and verification.
Research Compare two approaches adds source expectations, uncertainty, trade-offs, and evidence-linked conclusions.

RUN THE PREVIEW

Try it without an account or API key.

Use the browser Prompt Lab for an immediate preview, or run the published container when you want a terminal transcript you can reproduce on another machine.

After the local result appears, use Copy evidence or Download evidence to carry the report into the optional Usage Report form. Use Copy share link to reproduce the same input, profile, and language in another browser. Review the prompt before sharing because the link fragment contains the input text. The JSON contains no provider secret.

docker run --rm ghcr.io/happy520ai/unified-ai-system/ai-gateway-service:0.5.0 pnpm --silent gateway demo "Build a small API for my team" --enhance --profile coding --json

A successful preview reports providerCalled=false, credentialRequired=false, and deterministic=true. It runs through the local fake provider only after the prompt preview is assembled.

HTTP AND SDK

Keep the same contract in your own workflow.

The enhancement route is read-only with respect to providers. It returns the original request, enhanced prompt, detected profile and language, clarifying questions, and safety metadata.

curl --request POST http://127.0.0.1:3100/prompts/enhance \
  --header "content-type: application/json" \
  --data '{
    "input": "Help me plan a small API for my team",
    "profile": "planning",
    "language": "en"
  }'

The same route is available through the shared SDK. Chat enhancement is opt-in, so existing /chat behavior does not silently change when the gateway is upgraded.

pnpm gateway serve
node docs/examples/shared-sdk-prompt-enhancement.mjs "Help me plan a small API for my team" --profile planning --language en

See the runnable Shared SDK example for provider-free readiness and metadata checks.

To inspect cancellation without starting a gateway, run the loopback cancellation example. It distinguishes caller cancellation from the SDK's TimeoutError cause.

In auto mode, explicit instructions such as Please answer in Chinese or 请用英文回答 take precedence over character-based language detection. A supplied API or CLI language value still wins.

Profilesgeneral, coding, analysis, writing, research, planning
Languagesauto, zh-CN, en
Input limit20,000 characters

MCP / CODEX / IDEs

Expose enhancement as a governed tool.

The published MCP server exposes gateway_prompt_enhance alongside health, readiness, chat, knowledge, workflow, and workforce tools. Register the pinned container in Codex, Cursor, or Cline, then inspect the available tools before making a call.

InputNatural-language request
GatewayProfile / language / policy
OutputInspectable enhanced prompt
Next stepHuman or model execution

Follow the Codex MCP Docker quickstart for the pinned image and the 12-tool verification path.

SAFETY AND GOVERNANCE

Useful structure is not a promise of intelligence.

This engine is a deterministic heuristic transformation. It improves consistency and inspectability; it does not guarantee that every model or task will perform better.

DoesPreserve input, add structure, report metadata, and surface bounded questions.
Does notCall a provider, invent execution results, or enable real-provider access.
Still requiresExplicit authorization, model judgment, and independent evidence for production claims.

Production readiness, L5 autonomy, and AGI are not established by this preview. The repository documents those boundaries because a trustworthy gateway should make its limits visible.