OneAI
Docs
POST /v1/generateStructured outputsValidation + retries

Quickstart

Make your first request and get schema-valid structured outputs.

1) Get an API key

Create a key in Console, then pass it via x-api-key.

curl -X POST http://localhost:4000/v1/generate \
  -H "Content-Type: application/json" \
  -H "x-api-key:YOUR_KEY" \
  -d '{
    "type":"viral_hook",
    "input":{"topic":"OneAI Studio Lite","details":"PWA, templates-first, export md/json"},
    "options":{"templateVersion":1,"maxAttempts":3}
  }'

2) Understand the response

Your backend enforces structure. If validation fails, it retries up to maxAttempts.

Success
{
  "success": true,
  "data": { ...schema-valid output... },
  "attempts": 1
}
Failure
{
  "success": false,
  "error": "Failed to produce valid structured output",
  "details": { "code":"VALIDATION_FAILED", "issues":[...] }
}