Developer Documentation

Integrate the power of VisionHub AI into your own applications with our robust API.

Introduction

Welcome to the VisionHub AI developer documentation. Our API provides direct access to our powerful suite of generative AI tools, allowing you to build your own applications and workflows on top of our platform. Whether you want to generate images, enhance prompts, or remove backgrounds programmatically, our RESTful API provides a simple and effective solution.

This documentation will walk you through the necessary steps to get started, from authenticating your requests to using our various endpoints. We provide clear examples to help you integrate quickly and efficiently. If you have any questions, please don't hesitate to reach out to our support team.

Authentication

All API requests to VisionHub AI must be authenticated using an API key. You can generate and manage your API keys from your account settings page. It is crucial to keep your API key secure and not expose it in any client-side code.

To authenticate a request, include your API key in the `Authorization` header of your HTTP request, using the Bearer scheme.

fetch('https://api.visionhub.ai/v1/generate', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ prompt: 'A futuristic cityscape' })
});

Requests made without a valid API key, or with an incorrect key, will result in a `401 Unauthorized` error.

API Endpoints

Our API is organized around REST principles. We offer several endpoints to interact with our services.

POST /v1/generate

This is the primary endpoint for generating images from a text prompt. You can specify the model, aspect ratio, and other parameters in the request body.

{
  "prompt": "A serene zen garden with a cherry blossom tree, digital art",
  "model": "Gemini AI",
  "aspectRatio": "16:9",
  "userId": "user_123"
}

POST /v1/enhance-prompt

This endpoint takes a simple prompt and uses our AI to enrich it with more descriptive details, improving the quality of generated images.

{
  "prompt": "A photo of a dog",
  "tones": ["cinematic", "dramatic"]
}

POST /v1/remove-background

Submit an image as a data URI to this endpoint to receive a version with the background removed.

{
  "photoDataUri": "data:image/png;base64,iVBORw0KGgo..."
}