To use DeepAI with Bolt.new, prompt Bolt to create an API route that calls DeepAI's REST endpoints via HTTP POST with your API key in an api-key header. DeepAI requires no SDK — just fetch calls with multipart/form-data for image operations and JSON for text endpoints. Store your key in .env as DEEPAI_API_KEY. All outbound API calls work in Bolt's WebContainer during development — no deployment required to test image generation and style transfer.
Add Quick AI Features to Your Bolt.new App with DeepAI's Simple REST API
DeepAI offers one of the most approachable AI APIs available — there is no SDK to install, no complex authentication flow, and no elaborate request structure. Every endpoint accepts a POST request with an api-key header and a body containing either image data or text parameters. The response always includes an output_url pointing to the generated image or an output field with the text result. This simplicity makes DeepAI an excellent choice for quickly adding AI capabilities to Bolt.new apps without the learning curve of larger AI platforms.
DeepAI's feature set covers three main categories. Image generation: the text-to-image endpoint converts text descriptions into images, and you can choose from different artistic styles. Image manipulation: the neural style transfer endpoint applies the artistic style of one image to the content of another, and the background remover extracts subjects from backgrounds. Text analysis: the text summarization endpoint condenses long articles into brief summaries, and the sentiment analysis endpoint classifies text as positive, negative, or neutral. Each feature is its own endpoint, making it easy to add exactly the capabilities your app needs without a large dependency.
For Bolt.new developers, DeepAI is particularly practical because all operations are outbound API calls — your API route sends a request to DeepAI's servers and receives a response. There are no incoming webhooks or callbacks to configure. The complete integration works in Bolt's WebContainer during development, and the same code works identically after deploying to Netlify or Vercel. The WebContainer limitation (inability to receive incoming connections) does not apply here since DeepAI never POSTs back to your server.
Integration method
Bolt.new integrates with DeepAI through API routes that call DeepAI's HTTP endpoints using standard fetch with a simple api-key header for authentication. Unlike OpenAI, DeepAI requires no SDK — all endpoints accept multipart/form-data (for image inputs) or JSON (for text inputs) and return a JSON response with an output_url for image results. Your DEEPAI_API_KEY lives in .env and all API calls work from Bolt's WebContainer during development.
Prerequisites
- A DeepAI account at deepai.org (free tier includes limited monthly requests, no credit card required)
- Your DeepAI API key from deepai.org/dashboard after signing up
- A Bolt.new project with React and either Vite (default) or Next.js
- No SDK installation required — DeepAI uses standard HTTP fetch calls
- Optional: Supabase for storing generated images or summaries if you want to cache results
Step-by-step guide
Get Your DeepAI API Key
Get Your DeepAI API Key
Getting a DeepAI API key is one of the fastest API onboarding processes available. Navigate to deepai.org and click Sign Up. You can register with an email address or sign in with Google. After signup, you are immediately taken to your dashboard at deepai.org/dashboard where your API key is displayed prominently at the top of the page. The API key is a UUID-formatted string that looks like d1b38b3f-0a34-4d88-a50b-xxxxxxxx. Copy it immediately — you will add it to your .env file in the next step. DeepAI's free tier includes a certain number of API calls per month (the exact limit is shown on your dashboard) without requiring payment information. Paid plans are available for higher volumes. Unlike OpenAI or Anthropic, DeepAI does not charge based on tokens or compute units — they have flat per-call pricing for paid plans. One important consideration: DeepAI returns the AI-generated images as output_url values hosted on DeepAI's CDN. These URLs are typically valid for 24-48 hours. If you want to permanently store generated images, download them from the output_url and upload to Supabase Storage or another cloud storage within that window. After the URL expires, the image is no longer accessible from DeepAI's servers. Plan your storage strategy before building image generation features.
Pro tip: DeepAI output_url images expire after approximately 24-48 hours. If you want to keep generated images permanently, download them immediately and store in Supabase Storage or AWS S3 before displaying to users.
Expected result: You have your DeepAI API key copied from deepai.org/dashboard, ready to add to your .env file.
Add API Key to .env
Add API Key to .env
Add your DeepAI API key to the .env file in your Bolt project root. DeepAI uses a single API key for all endpoints — there is no distinction between public and private keys. This key must stay server-side. In Vite projects, environment variables are only exposed to browser code if they have the VITE_ prefix. Do not use VITE_DEEPAI_API_KEY — this would expose your API key in the browser's JavaScript bundle where any visitor could extract it and use it against your quota. Instead, use DEEPAI_API_KEY (no prefix), which is only accessible in server-side code (API routes, server components). The downside of a server-side-only variable in a Vite project is that you cannot call DeepAI directly from browser JavaScript — you must route all DeepAI calls through a server-side API route. This is actually the correct architecture: your API key is protected, and you control which prompts and images users can submit to DeepAI. In a Next.js project, API routes in app/api/ run server-side and can access process.env.DEEPAI_API_KEY without the NEXT_PUBLIC_ prefix. In a Vite project deployed to Netlify or Vercel, serverless functions can also access server-side environment variables. Prompt Bolt to set up the environment variable and create a base utility function that sets the api-key header for all DeepAI requests.
Add DEEPAI_API_KEY to the .env file with a placeholder value. Create a utility at lib/deepai.ts that exports an async function callDeepAI(endpoint: string, formData: FormData) which fetches POST https://api.deepai.org/api/{endpoint} with the api-key header set to process.env.DEEPAI_API_KEY and the formData as the body. Return the parsed JSON response. Also export a callDeepAIText(endpoint: string, text: string) function that sends { text } as a FormData field. Handle fetch errors by throwing with the response status and response body text.
Paste this in Bolt.new chat
1// lib/deepai.ts2const DEEPAI_BASE_URL = 'https://api.deepai.org/api';34export async function callDeepAI(endpoint: string, formData: FormData) {5 const response = await fetch(`${DEEPAI_BASE_URL}/${endpoint}`, {6 method: 'POST',7 headers: {8 'api-key': process.env.DEEPAI_API_KEY!,9 },10 body: formData,11 });1213 if (!response.ok) {14 const errorText = await response.text();15 throw new Error(`DeepAI error ${response.status}: ${errorText}`);16 }1718 return response.json();19}2021export async function callDeepAIText(endpoint: string, text: string) {22 const formData = new FormData();23 formData.append('text', text);24 return callDeepAI(endpoint, formData);25}2627export async function callDeepAIImage(endpoint: string, imageBuffer: Buffer, filename: string) {28 const formData = new FormData();29 const blob = new Blob([imageBuffer]);30 formData.append('image', blob, filename);31 return callDeepAI(endpoint, formData);32}Pro tip: DeepAI's API key goes in an api-key header (lowercase, hyphenated), not an Authorization: Bearer header. This is different from most modern APIs. Using the wrong header format results in an 'Incorrect API key' error.
Expected result: DEEPAI_API_KEY is in .env and lib/deepai.ts provides typed utility functions for text, image, and form-based DeepAI calls.
Build an Image Generation API Route
Build an Image Generation API Route
DeepAI's text-to-image endpoint is at https://api.deepai.org/api/text2img. You POST a form with a text field containing the image description. The response JSON contains an output_url pointing to the generated image hosted on DeepAI's CDN. Generation typically takes 5-15 seconds depending on DeepAI's load. For an interactive generator in your Bolt app, the user submits a prompt from the React frontend, the request goes to your API route, which calls DeepAI and returns the output_url, and the frontend displays the image from that URL. DeepAI also offers style-specific generators as separate endpoints: text2img (general), cute-animal-generator, abstract-painting-generator, old-style-generator, and renaissance-painting-generator. Each has the same request format — just change the endpoint URL. This makes it easy to offer a style dropdown in your UI that maps to different DeepAI endpoints. One important UI consideration: since generation takes up to 15 seconds, always show a loading indicator. A skeleton placeholder the size of the expected image, with a spinner and a message like 'Generating your image...' prevents users from clicking Submit multiple times thinking the first request failed. Disable the submit button while a request is in progress and re-enable it on success or error.
Create an API route at /api/deepai/generate that accepts POST with JSON body { prompt: string, style: string }. Map the style value to a DeepAI endpoint: 'general' → 'text2img', 'cute' → 'cute-animal-generator', 'abstract' → 'abstract-painting-generator', 'old-style' → 'old-style-generator'. Call callDeepAI from lib/deepai.ts with the appropriate endpoint and a FormData containing prompt as 'text'. Return { imageUrl: result.output_url } on success. Build a React page at /generate with a prompt textarea, style dropdown, Submit button (disabled while loading), and an img element that shows the returned imageUrl. Show a loading skeleton while generating.
Paste this in Bolt.new chat
1// app/api/deepai/generate/route.ts2import { NextRequest, NextResponse } from 'next/server';3import { callDeepAI } from '@/lib/deepai';45const STYLE_ENDPOINTS: Record<string, string> = {6 general: 'text2img',7 cute: 'cute-animal-generator',8 abstract: 'abstract-painting-generator',9 'old-style': 'old-style-generator',10 renaissance: 'renaissance-painting-generator',11};1213export async function POST(request: NextRequest) {14 const { prompt, style = 'general' } = await request.json();1516 if (!prompt || prompt.trim().length === 0) {17 return NextResponse.json({ error: 'Prompt is required' }, { status: 400 });18 }1920 const endpoint = STYLE_ENDPOINTS[style] || 'text2img';2122 try {23 const formData = new FormData();24 formData.append('text', prompt.trim());2526 const result = await callDeepAI(endpoint, formData);2728 if (!result.output_url) {29 return NextResponse.json({ error: 'No image generated' }, { status: 500 });30 }3132 return NextResponse.json({ imageUrl: result.output_url });33 } catch (error) {34 const message = error instanceof Error ? error.message : 'Generation failed';35 return NextResponse.json({ error: message }, { status: 500 });36 }37}Pro tip: DeepAI generates images at 512x512 pixels by default. The output_url expires after approximately 24-48 hours. If you want users to be able to revisit their generated images, download and re-host them in Supabase Storage when the generation completes.
Expected result: Submitting a prompt on the /generate page calls DeepAI and displays the generated image within 5-15 seconds. The image URL loads correctly from DeepAI's CDN.
Add Style Transfer with Image Uploads
Add Style Transfer with Image Uploads
DeepAI's neural-style endpoint applies the artistic style of one image (the style image) to the content of another (the content image). This requires sending two images as multipart/form-data — one as the 'content' field and one as the 'style' field. In a Bolt React app, this means building a UI with two file upload inputs. When the user selects files and submits, the frontend sends both images to your API route as a multipart form POST. The API route reads the files from the request, creates a new FormData, and forwards both images to DeepAI's neural-style endpoint. Handling file uploads in Next.js API routes requires reading the request body carefully. The easiest approach in Next.js App Router is to use request.formData() which parses the incoming multipart body. You then get the File objects from the FormData, read them as ArrayBuffers, and append them to a new FormData for the DeepAI request. DeepAI accepts standard image formats: JPEG, PNG, and WebP. The style transfer process typically takes 10-30 seconds depending on image complexity. Like text-to-image, the response contains an output_url with the style-transferred image. This feature works in Bolt's WebContainer during development — the file uploads are browser-to-server (within the WebContainer) and the API call to DeepAI is outbound, both of which work without any special configuration.
Create an API route at /api/deepai/style-transfer that accepts POST with multipart/form-data containing 'contentImage' (File) and 'styleImage' (File). Read both files from the request FormData using request.formData(). Create a new FormData with 'content' set to the content image File and 'style' set to the style image File. Call DeepAI's neural-style endpoint with my DEEPAI_API_KEY. Return { imageUrl: result.output_url }. Build a /style-transfer page with two image upload inputs showing previews, a Submit button, and a result section that shows the three images (content, style, result) side by side once complete.
Paste this in Bolt.new chat
1// app/api/deepai/style-transfer/route.ts2import { NextRequest, NextResponse } from 'next/server';3import { callDeepAI } from '@/lib/deepai';45export async function POST(request: NextRequest) {6 const incomingForm = await request.formData();7 const contentImage = incomingForm.get('contentImage') as File;8 const styleImage = incomingForm.get('styleImage') as File;910 if (!contentImage || !styleImage) {11 return NextResponse.json(12 { error: 'Both contentImage and styleImage are required' },13 { status: 400 }14 );15 }1617 try {18 const deepAIForm = new FormData();19 deepAIForm.append('content', contentImage, contentImage.name);20 deepAIForm.append('style', styleImage, styleImage.name);2122 const result = await callDeepAI('neural-style', deepAIForm);2324 if (!result.output_url) {25 return NextResponse.json({ error: 'Style transfer failed' }, { status: 500 });26 }2728 return NextResponse.json({ imageUrl: result.output_url });29 } catch (error) {30 const message = error instanceof Error ? error.message : 'Style transfer failed';31 return NextResponse.json({ error: message }, { status: 500 });32 }33}Pro tip: DeepAI's neural-style endpoint works best with high-contrast style images (paintings, artworks) and clear content images (photos, illustrations). Very similar images for content and style tend to produce subtle results.
Expected result: Uploading a content image and a style image on the /style-transfer page generates a new image that combines both. The style-transferred image appears in the result section within 15-30 seconds.
Add Text Summarization
Add Text Summarization
DeepAI's summarization endpoint is the simplest API call in their catalog — POST a FormData with a single text field and receive a JSON response with an output field containing the summary text. Unlike the image endpoints, the text summarization response returns immediately and the output is a string, not a URL. The endpoint is https://api.deepai.org/api/summarization. This makes summarization easy to add to any content-heavy page in your Bolt app: fetch an article from Supabase, extract the body text, call the summarization endpoint, and display the result. For production use, cache summaries in Supabase alongside the source content — regenerating on every page load wastes API calls and slows the page. Store the summary text in a summary column in your Supabase articles table and only call DeepAI if the summary column is null. This pattern works well with ISR pages: on the first request, generate the summary and save it; subsequent requests serve the cached version. DeepAI also offers a text-generator endpoint for completing or extending text, a sentiment-analysis endpoint (returns positive/negative/neutral with a confidence score), and a language-detector endpoint (identifies which language a text is written in). All text endpoints use the same simple text form field pattern and return immediate JSON responses. All of these work in Bolt's WebContainer during development since they are outbound API calls.
Add a text summarization feature. Create an API route at /api/deepai/summarize that accepts POST with JSON { text: string }. Build a FormData with the text field and call DeepAI's summarization endpoint using callDeepAIText from lib/deepai.ts. Return { summary: result.output }. On my article detail pages (/articles/[slug]), add a 'Summarize Article' button below the title. Clicking it POSTs the article body to /api/deepai/summarize, then displays the summary in a teal highlighted box above the article body labeled 'AI Summary'. Cache the summary in Supabase by updating the article's summary column — only call DeepAI if the summary is null.
Paste this in Bolt.new chat
1// app/api/deepai/summarize/route.ts2import { NextRequest, NextResponse } from 'next/server';3import { callDeepAIText } from '@/lib/deepai';45export async function POST(request: NextRequest) {6 const { text } = await request.json();78 if (!text || text.trim().length < 100) {9 return NextResponse.json(10 { error: 'Text must be at least 100 characters to summarize' },11 { status: 400 }12 );13 }1415 // Truncate very long texts to avoid API limits16 const truncatedText = text.length > 10000 ? text.substring(0, 10000) : text;1718 try {19 const result = await callDeepAIText('summarization', truncatedText);2021 if (!result.output) {22 return NextResponse.json({ error: 'Summarization returned no output' }, { status: 500 });23 }2425 return NextResponse.json({ summary: result.output });26 } catch (error) {27 const message = error instanceof Error ? error.message : 'Summarization failed';28 return NextResponse.json({ error: message }, { status: 500 });29 }30}Pro tip: DeepAI's summarization works best on articles of at least 300-500 words. Very short texts return generic summaries. Truncate input at 10,000 characters to avoid hitting API body size limits.
Expected result: Clicking 'Summarize Article' on an article page calls DeepAI and displays a 2-3 sentence AI summary in a highlighted box. The summary is cached in Supabase for subsequent page loads.
Common use cases
AI Image Generator Tool
Build a text-to-image generator where users type a description and your app generates an image using DeepAI's text2img endpoint. Show the generated image inline and let users download it or save it to their account. Great for creative tools, content creation apps, and product visualization.
Add an AI image generator to my app at /generate. Create a form with a text prompt input and a Style dropdown (fantasy, surreal, steampunk, baroque). On submit, POST to /api/deepai/generate which calls DeepAI's text2img endpoint with the prompt and style using my DEEPAI_API_KEY from .env. Display the returned output_url as an image below the form. Add a Download button and a loading skeleton while the image is generating. Handle errors by showing the error message below the form.
Copy this prompt to try it in Bolt.new
Artistic Style Transfer Feature
Let users upload a content image and a style image, then generate a new image that has the content of the first image rendered in the artistic style of the second. This works as a creative filter tool — users can make their photos look like famous painting styles or match a brand's visual identity.
Build a style transfer tool at /style-transfer. Create two file upload inputs: one for the 'content image' (the photo to transform) and one for the 'style image' (the artistic style to apply). On submit, POST both images as multipart/form-data to /api/deepai/style-transfer which calls DeepAI's neural-style endpoint. Display the original images side by side and show the style-transferred result below. Add a loading message 'Applying style... this takes about 15 seconds'. Use my DEEPAI_API_KEY from .env.
Copy this prompt to try it in Bolt.new
Auto-Summary for Long-Form Content
Add a one-click 'Summarize' button to any page displaying long articles, reports, or documentation. The button sends the text to DeepAI's summarization endpoint and displays a concise 2-3 sentence summary. Useful for content portals, research tools, and news aggregators.
Add an AI summarization feature to my article pages. For each article displayed, add a 'TL;DR' button below the title. Clicking it POSTs the article body text to /api/deepai/summarize which calls DeepAI's summarization endpoint with the text in the content field. Display the returned summary in a highlighted quote block below the article title. Show a loading spinner while summarizing. Store the summary in Supabase linked to the article ID so it only needs to be generated once.
Copy this prompt to try it in Bolt.new
Troubleshooting
'Incorrect API key' error from DeepAI even though the key looks correct
Cause: The api-key header name is incorrect (wrong case or wrong format), the API key was copied with extra whitespace, or the DEEPAI_API_KEY environment variable is not accessible in the API route.
Solution: Verify the header name is exactly 'api-key' (lowercase, hyphenated) — not 'Authorization', not 'x-api-key', and not 'API-Key'. Trim whitespace from the key value before using it. In Next.js, confirm the variable is named DEEPAI_API_KEY (no NEXT_PUBLIC_ prefix) and is accessed via process.env.DEEPAI_API_KEY in an API route, not in browser-side code.
1// Correct header format2fetch('https://api.deepai.org/api/text2img', {3 method: 'POST',4 headers: { 'api-key': process.env.DEEPAI_API_KEY!.trim() },5 body: formData,6});Image generation API route returns a CORS error in the browser
Cause: The DeepAI API is being called directly from browser-side React code (useEffect, event handler) instead of through a server-side API route.
Solution: All DeepAI calls must go through your server-side API route, not from browser-side JavaScript. Move the fetch call to your /api/deepai/generate route and call that route from your React component. The server-side route is not subject to browser CORS restrictions.
Style transfer returns an output_url but the image does not load in the browser
Cause: The output_url has expired (DeepAI images expire after ~24-48 hours), or the image was generated but is still being processed on DeepAI's CDN.
Solution: For recently generated images, wait 5-10 seconds and refresh — DeepAI CDN propagation can be delayed. For expired URLs, regenerate the image. To prevent expiry issues in production, download the image from output_url immediately after generation and store it in Supabase Storage using the anon key's storage upload endpoint, then store the Supabase Storage URL in your database instead of the DeepAI URL.
Best practices
- Never call DeepAI directly from browser-side JavaScript — always proxy through a server-side API route to protect your API key from extraction
- Cache AI-generated content (summaries, images) in Supabase — each API call consumes your monthly quota and image generation can take 10-15 seconds
- Download and re-host DeepAI image output_url results to your own storage immediately if users need permanent access — DeepAI image URLs expire after approximately 24-48 hours
- Validate and sanitize text inputs before sending to DeepAI — enforce minimum/maximum lengths to avoid unexpected API behavior
- Add loading states for all DeepAI image operations — generation takes 5-30 seconds and users need feedback to know the request is processing
- Implement rate limiting on your API routes if DeepAI features are publicly accessible — without limits, users could exhaust your monthly quota quickly
- Use separate API routes for each DeepAI feature rather than a single generic proxy route — this makes it easier to add feature-specific validation, caching, and error handling
Alternatives
OpenAI's DALL-E and GPT APIs provide more powerful and customizable AI capabilities with better image quality, but require more complex setup and higher per-call costs.
IBM Watson provides enterprise-grade NLP services including more sophisticated text analysis, tone analysis, and language translation beyond DeepAI's simpler feature set.
TensorFlow.js runs AI models directly in the browser without any API calls or external services, offering zero latency for inference but requiring model management expertise.
Azure Machine Learning provides full ML pipeline management and custom model deployment for organizations needing proprietary models rather than shared API endpoints.
Frequently asked questions
Is DeepAI free to use with Bolt.new?
DeepAI offers a free tier with a limited number of API calls per month — the exact number is visible on your deepai.org/dashboard after signup. No credit card is required for the free tier. Paid plans are available for higher monthly volumes with flat per-call pricing. For building and testing a Bolt.new integration, the free tier is sufficient.
Why do I need a server-side API route instead of calling DeepAI directly from React?
Calling DeepAI from browser-side JavaScript would expose your API key in the browser's network requests, where any user could extract it using browser developer tools and use it against your quota. Routing all DeepAI calls through a server-side Next.js API route keeps your API key in process.env on the server, where it is never sent to the browser.
How long does DeepAI image generation take?
Text-to-image generation typically takes 5-15 seconds depending on DeepAI's current server load. Style transfer takes 10-30 seconds. Background removal is faster at 3-8 seconds. Always show a loading indicator to prevent users from thinking the request failed and submitting multiple times. Consider adding a progress message after 10 seconds like 'Still generating, almost done...' to reduce user anxiety.
Can I use DeepAI in Bolt's WebContainer preview during development?
Yes, completely. DeepAI integration is all outbound API calls from your server-side route to DeepAI's servers — no incoming webhooks or callbacks. The WebContainer supports outbound HTTP requests, so you can test image generation, style transfer, and text summarization during development without deploying. The same code works identically after deploying to Netlify or Vercel.
How do I permanently store DeepAI-generated images?
DeepAI returns an output_url pointing to an image on their CDN that expires after approximately 24-48 hours. To keep images permanently, immediately fetch the image bytes from the output_url in your API route and upload them to Supabase Storage using the service role key. Store the Supabase Storage public URL in your database instead of the DeepAI URL. This way your images survive DeepAI's CDN expiry.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation