Skip to main content
Version: 1.11.0-beta

enhancePrompt

Enhances a user prompt using ImagineoAI's magic prompt endpoint (powered by GPT-4.1-mini). Returns a structured response with enhanced prompt and status.

Available in: Browser & Node.js SDK


Endpoint Namespace

  • New: /api/v1/prompts/enhance (was /prompts/enhance)

Signature

async client.prompts.enhance(input: EnhancePromptRequest): Promise<EnhancePromptResponse>

Parameters

  • input: { prompt: string } — The prompt to enhance. Must be a non-empty string.

Returns

  • Promise<EnhancePromptResponse>

EnhancePromptResponse Structure

{
success: boolean;
message: string;
data: {
enhancedPrompt: string;
};
code?: string; // e.g., 'VALIDATION_ERROR', 'AUTH_ERROR'
details?: any; // Optional, for extra error/debug info
}

Errors

  • Throws if input is invalid (Zod-validated)
  • Throws if the API returns an error or a network error occurs
  • Error messages and codes are now provided in the response for easier debugging

Example (Browser)

const client = new ImagineoAIClient(apiUrl, { apiKey });
const result = await client.prompts.enhance({ prompt: "A cat riding a skateboard" });
if (result.success) {
console.log(result.data.enhancedPrompt);
} else {
console.error(result.message, result.code, result.details);
}

Example (Node.js)

const client = new ImagineoAIClient(apiUrl, { apiKey });
const result = await client.prompts.enhance({ prompt: "A cat riding a skateboard" });
if (result.success) {
console.log(result.data.enhancedPrompt);
}

Notes

  • Input and output types are defined in as EnhancePromptRequest and EnhancePromptResponse.
  • This method is fully type-safe and uses Zod for runtime validation.
  • Breaking Change: The endpoint path and response structure have changed in SDK v1.1.x. Update your code accordingly if upgrading from v0.x.