Image Generation

Serverless Logo Generator

Build an on-demand logo generation service using OneInfer's image generation API. Users describe their brand and receive high-quality logos in seconds — no GPU management required.

OneInfer Image APIStable Diffusion XLNext.jsPython

What you'll build

  • + A REST endpoint that accepts a brand description and returns a generated logo
  • + Prompt engineering to produce clean, brand-ready imagery
  • + Serverless architecture — pay only for what you generate

Step-by-step guide

1

Install the OpenAI-compatible client

OneInfer's image API is OpenAI-compatible, so you can use the standard SDK.

bash
pip install openai
2

Generate a logo with the Images API

Use your OneInfer API key and point the base URL to https://api.oneinfer.ai/v1.

python
import openai
import base64

client = openai.OpenAI(
    api_key="your-oneinfer-api-key",
    base_url="https://api.oneinfer.ai/v1"
)

response = client.images.generate(
    model="stable-diffusion-xl",
    prompt=(
        "A minimalist logo for a tech startup called 'NovaSpark'. "
        "Clean vector style, deep blue and white, professional, no text."
    ),
    n=1,
    size="1024x1024",
    response_format="b64_json"
)

# Decode and save
image_data = base64.b64decode(response.data[0].b64_json)
with open("logo.png", "wb") as f:
    f.write(image_data)

print("Logo saved to logo.png")
3

Wrap it in a Next.js API route

typescript
// pages/api/generate-logo.ts
import type { NextApiRequest, NextApiResponse } from "next";

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
    const { brandName, description, colors } = req.body;

    const prompt = `Minimalist logo for "${brandName}". ${description}.
Color palette: ${colors}. Clean vector style, no text, white background.`;

    const response = await fetch("https://api.oneinfer.ai/v1/images/generations", {
        method: "POST",
        headers: {
            "Authorization": `Bearer ${process.env.ONEINFER_API_KEY}`,
            "Content-Type": "application/json"
        },
        body: JSON.stringify({
            model: "stable-diffusion-xl",
            prompt,
            n: 1,
            size: "1024x1024",
            response_format: "url"
        })
    });

    const data = await response.json();
    res.json({ url: data.data[0].url });
}
4

Add prompt refinements

Negative prompts improve quality significantly:

python
negative_prompt = (
    "text, letters, watermark, blurry, low quality, "
    "cluttered, realistic photo, 3D render"
)
Tip: Append negative_prompt to your request body to steer generation away from unwanted results.