diff --git a/apps/landing/src/app/(landings)/blog/[slug]/code.html b/apps/landing/src/app/(landings)/blog/[slug]/code.html new file mode 100644 index 0000000..bf53d27 --- /dev/null +++ b/apps/landing/src/app/(landings)/blog/[slug]/code.html @@ -0,0 +1,445 @@ + + + + +Refined Technical Blog Article + + + + + + + + + +
+
+
+
+
+
+
+
+
+ +
+ + Engineering + + +schedule 8 min read + +
+

+ Optimizing Image Generation Pipelines at Scale +

+

+ Learn how we reduced latency by 40% using edge caching and predictive pre-generation strategies for our high-throughput API endpoints. +

+
+Author Avatar +
+
Alex Chen
+
Senior Infrastructure Engineer • Oct 24, 2023
+
+
+
+
+
+Abstract technical graphic showing network nodes +
+
+
+
+
+
+
+ $ latency --check
+ > 45ms (optimized) +
+
+
+
+
+
+
+
+
+
+ +
+
+

+ When we first launched Banatie's image generation API, we optimized for quality. But as our user base grew, so did the demand for speed. Here is how we tackled the challenge of delivering AI-generated assets in milliseconds. +

+

The Latency Bottleneck

+

+ Our initial architecture was straightforward: a request hits our API gateway, gets queued, processed by a GPU worker, and the resulting image is uploaded to S3. Simple, but slow. +

+

+ Users integrating our API into real-time applications needed faster response times. We identified two main areas for improvement: +

+
    +
  • Cold Starts: Spinning up new GPU instances took 2-3 minutes.
  • +
  • Network Overhead: Round trips between the inference server and storage added 200ms+.
  • +
+
+
+
+info +
+
+
Pro Tip: Analyze your P99
+

+ Don't just look at average latency. Your P99 (99th percentile) latency tells you the experience of your users during worst-case scenarios. Optimizing for P99 often yields the most stable system. +

+
+
+
+

Implementing Edge Caching

+

+ To solve the network overhead, we moved our delivery layer to the edge. By utilizing a global CDN, we could serve cached results instantly for repeated prompts. +

+
+
+
+
+
+
+
+middleware/cache-control.ts +
+ +
+
+
export function setCacheHeaders(res: Response) {
+  // Cache for 1 hour at the edge, validate stale in background
+  res.setHeader(
+    
+  );
+  // Custom tag for purging
+  res.setHeader();
+}
+
+
+

The Results

+

+ After deploying these changes, we saw a dramatic drop in TTFB (Time To First Byte). +

+
+ "The latency improvements were immediate. Our dashboard loads felt instantaneous compared to the previous version, directly impacting our user retention metrics." +
+
+
+Graph comparing latency before and after optimization +
+
+insert_chart +Latency reduction over a 24-hour period post-deployment +
+
+

Predictive Pre-Generation

+

+ For our enterprise clients, we introduced predictive generation. By analyzing usage patterns, we can pre-warm the cache with variations of commonly requested assets before the user even asks for them. +

+

+ This is particularly useful for e-commerce clients who update their catalogs at predictable times. +

+
+

Conclusion

+

+ Optimization is never finished. We are currently exploring WebAssembly for client-side resizing to further offload our servers. Stay tuned for Part 2! +

+
+
+
+ +
+
+
+ + \ No newline at end of file diff --git a/apps/landing/src/app/(landings)/blog/_components/BlogSidebar.tsx b/apps/landing/src/app/(landings)/blog/_components/BlogSidebar.tsx index 848493f..b67d09b 100644 --- a/apps/landing/src/app/(landings)/blog/_components/BlogSidebar.tsx +++ b/apps/landing/src/app/(landings)/blog/_components/BlogSidebar.tsx @@ -24,6 +24,31 @@ export const BlogSidebar = ({ return ( ); }; diff --git a/apps/landing/src/app/(landings)/blog/_posts/api-integration-tips.tsx b/apps/landing/src/app/(landings)/blog/_posts/api-integration-tips.tsx new file mode 100644 index 0000000..17182f6 --- /dev/null +++ b/apps/landing/src/app/(landings)/blog/_posts/api-integration-tips.tsx @@ -0,0 +1,112 @@ +import { BlogHeading, BlogQuote, BlogCTA, BlogCodeBlock } from '../_components'; +import type { TocItem } from '../types'; + +export const tocItems: TocItem[] = [ + { id: 'overview', text: 'Overview', level: 2 }, + { id: 'authentication', text: 'Authentication Setup', level: 2 }, + { id: 'error-handling', text: 'Error Handling', level: 2 }, + { id: 'rate-limits', text: 'Rate Limits', level: 3 }, + { id: 'caching', text: 'Caching Strategies', level: 2 }, + { id: 'conclusion', text: 'Conclusion', level: 2 }, +]; + +export const Content = () => ( + <> + + Overview + +

+ Integrating the Banatie API into your application opens up a world of + possibilities for dynamic image generation. This guide covers the best + practices for a smooth integration. +

+

+ Whether you are building a web application, mobile app, or backend service, + these tips will help you get the most out of the API. +

+ + + Authentication Setup + +

+ All API requests require authentication via an API key. Here is how to + set it up properly: +

+ + + {`const headers = { + 'X-API-Key': process.env.BANATIE_API_KEY, + 'Content-Type': 'application/json' +}; + +const response = await fetch('https://api.banatie.app/text-to-image', { + method: 'POST', + headers, + body: JSON.stringify({ prompt: 'modern office' }) +});`} + + + + Never expose your API key in client-side code. Always make API calls + from your server. + + + + Error Handling + +

+ Proper error handling ensures your application gracefully handles + failures. The API returns standard HTTP status codes. +

+ + + {`try { + const response = await generateImage(prompt); + if (!response.ok) { + if (response.status === 429) { + // Rate limited - implement backoff + } + throw new Error(\`API error: \${response.status}\`); + } +} catch (error) { + console.error('Image generation failed:', error); + // Show fallback image +}`} + + + + Rate Limits + +

+ The API has rate limits to ensure fair usage. Plan your requests + accordingly and implement exponential backoff for retries. +

+ + + Caching Strategies + +

+ Caching generated images can significantly reduce API calls and improve + response times. Consider caching at multiple levels. +

+

+ Use CDN caching for frequently requested images and local caching for + user-specific content. +

+ + + Conclusion + +

+ Following these best practices will help you build a robust integration + with the Banatie API. Start small, test thoroughly, and scale as needed. +

+ + + +); diff --git a/apps/landing/src/app/(landings)/blog/_posts/design-workflow-optimization.tsx b/apps/landing/src/app/(landings)/blog/_posts/design-workflow-optimization.tsx new file mode 100644 index 0000000..161b5ee --- /dev/null +++ b/apps/landing/src/app/(landings)/blog/_posts/design-workflow-optimization.tsx @@ -0,0 +1,92 @@ +import { BlogHeading, BlogQuote, BlogCTA } from '../_components'; +import type { TocItem } from '../types'; + +export const tocItems: TocItem[] = [ + { id: 'introduction', text: 'Introduction', level: 2 }, + { id: 'traditional-workflow', text: 'Traditional Workflow Problems', level: 2 }, + { id: 'ai-powered-approach', text: 'AI-Powered Approach', level: 2 }, + { id: 'figma-integration', text: 'Figma Integration', level: 3 }, + { id: 'time-savings', text: 'Time Savings', level: 2 }, + { id: 'tips', text: 'Pro Tips', level: 2 }, +]; + +export const Content = () => ( + <> + + Introduction + +

+ Design workflows have traditionally been bottlenecked by the need for + placeholder content. Finding the right stock photos or waiting for + actual assets can slow down the creative process significantly. +

+

+ AI-generated placeholders offer a new paradigm where designers can + instantly visualize their concepts with contextually relevant images. +

+ + + Traditional Workflow Problems + +

+ The conventional design process often involves searching through stock + photo libraries, downloading images, and then realizing they do not quite + fit the vision. This cycle repeats multiple times per project. +

+ + + We used to spend hours just finding the right placeholder images. + Now we describe what we need and get it instantly. + + + + AI-Powered Approach + +

+ With AI-generated images, you simply describe what you need. Want a + hero image showing a team collaboration scene? Just ask for it. Need + product mockups with specific aesthetics? Describe the style. +

+

+ This approach keeps you in the creative flow instead of breaking + concentration to hunt for assets. +

+ + + Figma Integration + +

+ Many designers are using Banatie URLs directly in Figma prototypes. + This means your mockups automatically show relevant images without + manual image placement. +

+ + + Time Savings + +

+ Teams report saving 2-4 hours per project on asset hunting alone. + That time can now be spent on actual design work and iteration. +

+

+ The quick iteration cycle also means stakeholder feedback sessions + are more productive since designs look more complete. +

+ + + Pro Tips + +

+ Start with broad prompts and refine as needed. Use consistent style + descriptors across your project for visual coherence. Create a prompt + library for commonly used image types in your brand. +

+ + + +); diff --git a/apps/landing/src/app/(landings)/blog/_posts/image-generation-best-practices.tsx b/apps/landing/src/app/(landings)/blog/_posts/image-generation-best-practices.tsx new file mode 100644 index 0000000..85a0bf6 --- /dev/null +++ b/apps/landing/src/app/(landings)/blog/_posts/image-generation-best-practices.tsx @@ -0,0 +1,97 @@ +import { BlogHeading, BlogQuote, BlogCTA } from '../_components'; +import type { TocItem } from '../types'; + +export const tocItems: TocItem[] = [ + { id: 'introduction', text: 'Introduction', level: 2 }, + { id: 'quality-settings', text: 'Quality Settings', level: 2 }, + { id: 'resolution', text: 'Resolution Guidelines', level: 3 }, + { id: 'consistency', text: 'Maintaining Consistency', level: 2 }, + { id: 'performance', text: 'Performance Optimization', level: 2 }, + { id: 'dos-and-donts', text: 'Dos and Donts', level: 2 }, +]; + +export const Content = () => ( + <> + + Introduction + +

+ Generating high-quality AI images consistently requires understanding + both the capabilities and limitations of the technology. This guide + shares proven practices from thousands of successful generations. +

+

+ Following these guidelines will help you achieve better results with + fewer iterations. +

+ + + Quality Settings + +

+ The API offers different quality tiers. Higher quality settings produce + better images but take longer to generate. Choose based on your use case. +

+

+ For prototyping and development, standard quality is often sufficient. + Reserve high quality for production assets. +

+ + + Resolution Guidelines + +

+ Match the resolution to your actual display size. Generating 4K images + for thumbnail displays wastes resources and slows performance. +

+ + + Start with the exact dimensions you need. You can always regenerate + at higher resolution for final production. + + + + Maintaining Consistency + +

+ For projects requiring visual consistency across multiple images, use + consistent style descriptors and seed values. Document your successful + prompts for reuse. +

+

+ Creating a style guide for your project prompts helps team members + generate images that feel cohesive. +

+ + + Performance Optimization + +

+ Cache generated images when possible. Use lazy loading for below-the-fold + images. Consider generating images ahead of time for predictable content. +

+

+ Batch similar requests together when generating multiple images to + optimize API usage. +

+ + + Dos and Donts + +

+ Do: Test prompts iteratively, use specific descriptors, + cache results, match resolution to need. +

+

+ Do not: Use vague prompts, generate unnecessarily high + resolutions, skip error handling, expose API keys client-side. +

+ + + +); diff --git a/apps/landing/src/app/(landings)/blog/_posts/prompt-engineering-basics.tsx b/apps/landing/src/app/(landings)/blog/_posts/prompt-engineering-basics.tsx new file mode 100644 index 0000000..4b92b31 --- /dev/null +++ b/apps/landing/src/app/(landings)/blog/_posts/prompt-engineering-basics.tsx @@ -0,0 +1,112 @@ +import { BlogHeading, BlogQuote, BlogCTA, BlogCodeBlock } from '../_components'; +import type { TocItem } from '../types'; + +export const tocItems: TocItem[] = [ + { id: 'what-is-prompt-engineering', text: 'What is Prompt Engineering?', level: 2 }, + { id: 'basic-structure', text: 'Basic Prompt Structure', level: 2 }, + { id: 'subject', text: 'Subject', level: 3 }, + { id: 'style', text: 'Style', level: 3 }, + { id: 'context', text: 'Context', level: 3 }, + { id: 'common-mistakes', text: 'Common Mistakes', level: 2 }, + { id: 'advanced-techniques', text: 'Advanced Techniques', level: 2 }, +]; + +export const Content = () => ( + <> + + What is Prompt Engineering? + +

+ Prompt engineering is the art of crafting text descriptions that guide + AI models to generate the exact images you envision. It is a skill that + improves with practice and understanding of how AI interprets language. +

+

+ Good prompts are specific, descriptive, and structured in a way that + the AI can parse effectively. +

+ + + Basic Prompt Structure + +

+ A well-structured prompt typically includes three key elements: subject, + style, and context. Let us break down each component. +

+ + + Subject + +

+ The subject is what you want to see in the image. Be specific about + the main focus. +

+ + + {`Bad: "a person" +Good: "a young professional woman working at a laptop" +Better: "a young professional woman in business casual attire working at a MacBook in a modern office"`} + + + + Style + +

+ Style descriptors help define the visual aesthetic of the generated + image. +

+ + + {`Style keywords: +- "photorealistic" - for lifelike images +- "minimalist" - clean, simple compositions +- "vibrant colors" - saturated, energetic palette +- "soft lighting" - gentle, diffused light`} + + + + Context + +

+ Context provides background information and setting details. +

+ + + The more context you provide, the more aligned the result will be + with your vision. But avoid being so specific that you constrain + the AI too much. + + + + Common Mistakes + +

+ Avoid vague prompts like "something nice" or overly complex prompts + with contradicting elements. Do not list too many subjects as this + confuses the generation. +

+

+ Another common mistake is not iterating. Your first prompt rarely + produces the perfect result - refine and adjust. +

+ + + Advanced Techniques + +

+ As you gain experience, try techniques like negative prompting + (specifying what you do not want), weighted terms, and compositional + guidance. +

+

+ Keep a prompt journal to track what works for your specific use cases. +

+ + + +); diff --git a/apps/landing/src/app/(landings)/blog/_posts/use-cases-ecommerce.tsx b/apps/landing/src/app/(landings)/blog/_posts/use-cases-ecommerce.tsx new file mode 100644 index 0000000..e7b6a56 --- /dev/null +++ b/apps/landing/src/app/(landings)/blog/_posts/use-cases-ecommerce.tsx @@ -0,0 +1,109 @@ +import { BlogHeading, BlogQuote, BlogCTA, BlogCodeBlock } from '../_components'; +import type { TocItem } from '../types'; + +export const tocItems: TocItem[] = [ + { id: 'overview', text: 'Overview', level: 2 }, + { id: 'product-mockups', text: 'Product Mockups', level: 2 }, + { id: 'category-banners', text: 'Category Banners', level: 2 }, + { id: 'lifestyle-images', text: 'Lifestyle Images', level: 3 }, + { id: 'ab-testing', text: 'A/B Testing Visuals', level: 2 }, + { id: 'implementation', text: 'Implementation Example', level: 2 }, +]; + +export const Content = () => ( + <> + + Overview + +

+ E-commerce platforms face unique challenges when it comes to visual + content. From product listings to marketing banners, the need for + high-quality images is constant and demanding. +

+

+ AI-generated placeholders offer e-commerce teams a way to prototype, + test, and iterate faster than ever before. +

+ + + Product Mockups + +

+ Before product photography is complete, use AI to generate realistic + product mockups. This allows the development and marketing teams to + work in parallel rather than waiting for final assets. +

+ + + We launched our new collection page two weeks earlier by using AI + placeholders during development. Real photos were swapped in seamlessly + when ready. + + + + Category Banners + +

+ Category and promotional banners can be prototyped instantly. Test + different visual themes before committing to professional photo shoots. +

+

+ This is especially valuable for seasonal campaigns where timing is + critical. +

+ + + Lifestyle Images + +

+ Lifestyle images showing products in use are expensive to produce. + AI can generate concept images to validate ideas before investing + in professional shoots. +

+ + + A/B Testing Visuals + +

+ Test different visual styles with real users before full production. + Generate multiple variations of hero images and measure which performs + better. +

+

+ This data-driven approach to visual design can significantly improve + conversion rates. +

+ + + Implementation Example + +

+ Here is a simple example of using Banatie for product category images: +

+ + + {` +
+ Summer Collection +
+ + +
+ Product +
`} +
+ + + +); diff --git a/apps/landing/src/app/(landings)/blog/blog-posts.json b/apps/landing/src/app/(landings)/blog/blog-posts.json index a1e6bea..35d6e13 100644 --- a/apps/landing/src/app/(landings)/blog/blog-posts.json +++ b/apps/landing/src/app/(landings)/blog/blog-posts.json @@ -12,11 +12,101 @@ "avatar": "/blog/authors/default.jpg" }, "readTime": "5 min", - "relatedArticles": [], + "relatedArticles": ["api-integration-tips", "prompt-engineering-basics"], "relatedDocs": [ { "title": "API Reference", "href": "/docs/api/", "icon": "code" }, { "title": "Quick Start", "href": "/docs/guides/", "icon": "book" } ] + }, + { + "slug": "api-integration-tips", + "title": "API Integration Tips for Developers", + "description": "Best practices for integrating Banatie API into your applications and workflows.", + "heroImage": "/blog/api-tips-hero.jpg", + "category": "tutorials", + "date": "2025-01-12", + "author": { + "name": "Banatie Team", + "avatar": "/blog/authors/default.jpg" + }, + "readTime": "7 min", + "relatedArticles": ["placeholder-images-guide", "image-generation-best-practices"], + "relatedDocs": [ + { "title": "API Reference", "href": "/docs/api/", "icon": "code" }, + { "title": "Authentication", "href": "/docs/guides/", "icon": "book" } + ] + }, + { + "slug": "design-workflow-optimization", + "title": "Optimizing Your Design Workflow with AI Images", + "description": "How designers can speed up their prototyping process using AI-generated placeholders.", + "heroImage": "/blog/design-workflow-hero.jpg", + "category": "guides", + "date": "2025-01-10", + "author": { + "name": "Banatie Team", + "avatar": "/blog/authors/default.jpg" + }, + "readTime": "6 min", + "relatedArticles": ["use-cases-ecommerce", "placeholder-images-guide"], + "relatedDocs": [ + { "title": "Getting Started", "href": "/docs/guides/", "icon": "book" }, + { "title": "Image Parameters", "href": "/docs/api/", "icon": "code" } + ] + }, + { + "slug": "prompt-engineering-basics", + "title": "Prompt Engineering for Better Image Results", + "description": "Master the art of writing prompts that generate exactly the images you need.", + "heroImage": "/blog/prompt-engineering-hero.jpg", + "category": "tutorials", + "date": "2025-01-08", + "author": { + "name": "Banatie Team", + "avatar": "/blog/authors/default.jpg" + }, + "readTime": "8 min", + "relatedArticles": ["image-generation-best-practices", "placeholder-images-guide"], + "relatedDocs": [ + { "title": "Prompt Guide", "href": "/docs/guides/", "icon": "book" }, + { "title": "API Reference", "href": "/docs/api/", "icon": "code" } + ] + }, + { + "slug": "image-generation-best-practices", + "title": "Best Practices for AI Image Generation", + "description": "Learn the do's and don'ts of generating high-quality AI images for your projects.", + "heroImage": "/blog/best-practices-hero.jpg", + "category": "guides", + "date": "2025-01-05", + "author": { + "name": "Banatie Team", + "avatar": "/blog/authors/default.jpg" + }, + "readTime": "6 min", + "relatedArticles": ["prompt-engineering-basics", "api-integration-tips"], + "relatedDocs": [ + { "title": "Image Quality", "href": "/docs/guides/", "icon": "book" }, + { "title": "Parameters", "href": "/docs/api/", "icon": "code" } + ] + }, + { + "slug": "use-cases-ecommerce", + "title": "AI Placeholders for E-commerce Projects", + "description": "How online stores can use AI-generated images for product mockups and prototypes.", + "heroImage": "/blog/ecommerce-hero.jpg", + "category": "use-cases", + "date": "2025-01-02", + "author": { + "name": "Banatie Team", + "avatar": "/blog/authors/default.jpg" + }, + "readTime": "5 min", + "relatedArticles": ["design-workflow-optimization", "image-generation-best-practices"], + "relatedDocs": [ + { "title": "Quick Start", "href": "/docs/guides/", "icon": "book" }, + { "title": "Batch Generation", "href": "/docs/api/", "icon": "code" } + ] } ] }