Turning a text prompt into an image only takes one API key and a single request, but a real production app needs more than a quick demo. You need the right header, the right request format, safe key storage, and a plan for image links that do not last forever. This guide covers how the DeepAI API works, where its limits show up, and when a broader option like Apiframe’s unified media API makes more sense.
What the DeepAI API Does and How Authentication Works
The DeepAI API gives developers a simple way to call AI features over the web, with image generation as the main feature most small apps use. It also offers a smaller set of image tools, including editing and inpainting (changing part of an image), upscaling, background removal, and coloring black-and-white photos.
One detail worth knowing before you sign up: API access on DeepAI is included with a DeepAI Pro subscription, not a bare free account. Create your account, subscribe to Pro, then open the developer dashboard to get your API key, usually shown as a long string of letters and numbers. Treat that key like a password. Store it in a server environment variable, and never put it inside a React app or any script that runs in the browser.
The header format matters here. DeepAI expects the key in an api-key header. It does not use the more common “bearer token” format you will see in many other API guides. If you send Authorization: Bearer ... instead, the request can fail even though your key is completely valid.
Image requests also expect form data, not JSON. That means your request should include a text field called text. Do not send a JSON body unless a specific endpoint’s documentation tells you to. Different DeepAI endpoints can expect different input formats, so check each one before writing a single shared client for all of them.
If you are weighing whether one key across several media types is worth it, compare this setup to what a unified AI media API offers. Apiframe, for example, uses one interface for image, video, and music generation, which can cut down on the number of separate integrations you need to maintain. Our guide to choosing an AI media API covers what to weigh in that comparison.
import os
api_key = os.environ["DEEPAI_API_KEY"]
prompt = "A quiet mountain cabin beneath a sky full of stars" response = http_client.post( "TEXT_TO_IMAGE_ENDPOINT", headers={"api-key": api_key}, data={"text": prompt}, timeout=60,
) response.raise_for_status()
result = response.json()
print(result)Either way, keep the secret key on your own server. Your browser should call your own backend, and that backend adds the DeepAI key before forwarding the request. This also gives you one place to add login checks, logging, retries, and usage limits. Our guide on AI media API security best practices covers these habits in more depth.
Key takeaway: Use the api-key header, send image prompts as form data, and keep every credential on your server, never in client-side code.
Making a Text-to-Image Request and Handling the Response
A DeepAI image request is simple in concept: send a prompt, wait for a response, then read the JSON that comes back. That response usually includes an output_url pointing to the generated image.
That URL works fine for a quick demo, but it shouldn't become the permanent link stored in your database. The image host may delete the file after roughly 24 to 48 hours. If your app only saves that link, older posts can quietly turn into broken images.
Use a short server-side pipeline instead:
- Accept the prompt from your app.
- Send the form-data POST request.
- Read the returned image URL.
- Download the image bytes at once.
- Upload those bytes to storage you control.
- Save your persistent storage URL with the prompt and request ID.
Once you have done that, the image can appear in a gallery, design tool, or content feed without depending on a temporary link from DeepAI. It also helps to add a cache key based on the prompt and settings used. If the same request comes in again, you can serve the saved result instead of generating a new image and spending another credit.
From the user’s side, generation should feel like it is happening in the background, even if your own request technically waits for a response. Test the full flow, including timeouts and clear error messages. If a request takes several seconds, show a loading indicator. Otherwise, people may hit submit again and use up your quota faster than expected.
The prompt itself makes a real difference. “A dog” leaves a lot of room for the model to guess. A prompt that describes the subject, setting, lighting, camera angle, and style gives the model much clearer direction. You can make this easier for your users with built-in style presets, like an “old painting” look or a “3D animal render” option. If you need ideas for writing better prompts, our AI image API guide has practical tips.
For a slightly different approach, Apiframe’s API uses a job-based flow: you submit a request, then either check for the result or receive it through a webhook (an automatic message sent to your server when a job finishes), and download it once it is ready. This is common for longer video and music jobs, but the same storage advice applies to images too: save the file yourself instead of relying on a temporary link. Our guide on setting up webhook callbacks for media generation walks through that pattern.
image_url = result.get("output_url")
if not image_url: raise ValueError("The response did not include an image URL") image_bytes = http_client.get(image_url, timeout=60).content
# Upload image_bytes to storage that your app controls.Always check the response before showing it to users. Confirm the request succeeded, make sure the URL is actually there, and log any provider error without logging your API key. These small checks save a lot of debugging time later, especially when a prompt fails or the API returns something unexpected.
Pricing, Credits, Pro Benefits, and Broader API Capabilities
DeepAI’s pricing is easier to plan around than many usage-based image APIs. API access is included with a DeepAI Pro subscription, and DeepAI says you pay affordable pay-as-you-go rates when you go past the usage included in your plan. Pro has been listed at about $9.99 per month, though prices and promotions can change. Always check DeepAI’s current pricing page before you finalize a budget, and confirm exactly what your plan includes on your account page.
The credit model still needs care. A flat monthly price does not mean unlimited capacity for a busy public app. Track requests by user, reject duplicate submissions, and set a daily budget for development. A viral feature can use up a fixed allowance much faster than a private prototype.
DeepAI’s broader platform also includes tools like chat and other media types beyond image generation, but that breadth is different from API breadth. Ask for endpoint details before you plan a video or music workflow around it, since not every feature on DeepAI’s consumer site is necessarily available through the API.
Apiframe takes a different approach here. It supports image, video, and music generation through a single interface, though exact pricing and free-tier limits are best confirmed on the Apiframe pricing page instead of assumed. This creates a real trade-off: DeepAI offers simple entry pricing for budget-conscious developers focused on images, while Apiframe may suit a team that would rather avoid separate integrations for each type of media. Our Modal pricing comparison covers DeepAI alongside Apiframe, fal, OpenRouter, and WaveSpeed, and our comparison of AI development platforms gives the wider picture. For a closer look at per-image costs, see our guides to AI image API pricing and what you really pay for a unified media API. Before a purchase, ask both vendors about included credits, overage rules, how many jobs can run at once, failed requests, and commercial use.
Pro tip: Measure your cost per finished image, not cost per API call. Failed requests, retries, storage, and content review can all change the real cost per usable asset.
Use Cases, Limitations, Security, and Production Scaling
The DeepAI API is a good fit for projects that need quick image generation with minimal setup. A design team might use it for early concept sketches. A web app could turn a short user prompt into a profile picture or a visual card. An internal tool might generate a handful of rough creative options before a human designer picks a direction. If you only need to cut out subjects, see our guide to background removal APIs.
It is a weaker fit for workflows that need print-ready output without extra processing. Commonly cited default output sizes for the API sit in the smaller range, which is fine for previews but not for large banners or high-resolution product photos. Higher-resolution options exist through DeepAI’s Genius Mode. Confirm the current size options and which plan unlocks them before promising anything larger in your product.
Speed is another area worth checking carefully. There is not much reliable public data on average response times for DeepAI or most other providers, including Apiframe. Some examples report waits of several seconds, with longer waits possible depending on load. Treat this as something to plan your interface around, not a guarantee from the provider.
As traffic grows, it helps to treat the whole request path as a queue. Your backend should accept the job, hand back a request ID right away, and let the client check on its status separately. Limit how many jobs a single user can start at once. Add automatic retries that wait a little longer each time for temporary failures, but cap the number of retries so one bad request does not quietly burn through your monthly usage.
A few security habits are worth following no matter how much traffic you have:
- Keep the API key in server-side secrets only.
- Set request limits per user.
- Strip sensitive prompt text out of public-facing logs.
- Review or scan generated images before showing them publicly.
- Store permanent files in private storage when access needs to be restricted.
Cache successful results. If ten users request the same preset artwork, one stored result may serve all ten. But do not cache private prompts under a shared key. Include the account ID when the output should stay private.
If your roadmap includes video or music generation down the line, it is worth evaluating Apiframe as a single integration point instead of adding a separate provider for each media type. Its request, job-checking or webhook, and download pattern gives you a sense of the kind of contract to look for before putting any media API into production. For a broader side-by-side view, our roundup of AI media generation APIs and our guide to choosing an AI media API both walk through what to weigh beyond price alone. If video is part of that roadmap, our AI video generation API guide is a useful next read.
The decision usually comes down to this: choose DeepAI when a modest image feature and simple, predictable pricing matter most. Test Apiframe when your product needs multiple media types and a single integration, but ask for a written quote and real speed numbers first.
DeepAI API FAQ
How do I get a DeepAI API key?
Create an account and subscribe to DeepAI Pro, since API access is included with that plan and not available on a free account. Copy the key from the developer area into a server-side environment variable. Never place it in browser JavaScript, mobile app code, or a public code repository. Your backend should attach the key to each request and expose only your own controlled route to the client.
What header does the DeepAI API use?
DeepAI uses an api-key header for sign-in, not the standard bearer token format used in many other REST APIs. Send your key as that header’s value, then pass the image prompt as form data. Using the wrong header name can cause an authentication error even when your account and key are both active.
How do I generate an image with Python?
Use any Python HTTP client to send a request to the text-to-image endpoint. Put your key in the api-key header and your prompt in a form field named text. Read the JSON response, find the returned image URL, and download the file before showing it to users.
How long does a DeepAI image URL last?
A generated image URL may expire after roughly 24 to 48 hours. That means the DeepAI API response is not meant to be a permanent record. Download the image as soon as the request succeeds, move it into storage you control, and save that permanent link in your own database.
How much does DeepAI Pro cost?
Pro has been listed at about $9.99 per month, though pricing can vary with promotions and change over time. API access is included, with pay-as-you-go rates beyond your plan’s allowance. Your actual project cost still depends on your usage volume, retries, storage, and traffic, so confirm current terms on your account page before budgeting. Our guide to free AI image generation APIs can help if you want to compare free options first.
Is DeepAI good for production apps?
DeepAI can work well in production once you add the pieces it does not handle for you. Route the API key through your own server, save images to your own storage instead of relying on temporary links, show a loading state during generation, and set limits on how many requests a single user can make. Test image size, speed, quota behavior, and error handling before launch. If your product needs more than just images, it is worth comparing DeepAI with Apiframe’s unified API approach. Our Getting Started with Apiframe guide shows how to try it.
Conclusion
For a single image feature, start with one server-side request and a simple storage step for the results. If your product is likely to grow into video or music generation too, it is worth evaluating Apiframe early, asking for clear pricing and speed numbers, and running a small load test before committing.