Text to Image API

Category: ai

Generate images from text descriptions using OpenAI DALL-E 3. Returns a URL to the generated image.

Endpoint

POST https://anythingtext.com/api/tools/txt2img
Authentication Required Content-Type: application/json

Authentication

This API requires an API key. Generate one from the API Keys section in your dashboard settings.

Include the X-API-Key header in all API requests:

X-API-Key: atk_your_api_key_here

Rate Limiting

API requests are limited to 60 requests per minute per user. If you exceed this limit, the API returns a 429 Too Many Requests response.

Every response includes rate limit headers:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 42

When rate limited, the response body contains:

{ "error": "Rate limit exceeded. Maximum 60 requests per minute.", "retryAfter": 42, "limit": 60 }

Request Parameters

Name Type Required Description
prompt String Required Text description of the image to generate
Example: A sunset over a mountain lake, digital art style

Response

Content-Type: application/json

URL of the generated image

{
  "imageUrl": "https://oaidalleapiprodscus.blob.core.windows.net/..."
}

Error Responses

StatusDescriptionBody
401 Not authenticated {"error": "Please log in..."}
400 Bad request / Missing required params {"error": "... is required"}
500 Internal server error {"error": "Failed to ..."}

cURL Example

curl -X POST https://anythingtext.com/api/tools/txt2img \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your_api_key_here" \
  -d '{"prompt": "A sunset over a mountain lake"}'

Code Samples

const response = await fetch('https://anythingtext.com/api/tools/txt2img', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'X-API-Key': 'your_api_key_here'
    },
    body: JSON.stringify({
        prompt: 'A sunset over a mountain lake, digital art style'
    })
});

const data = await response.json();
console.log('Image URL:', data.imageUrl);

// Display in an <img> tag
const img = document.createElement('img');
img.src = data.imageUrl;
document.body.appendChild(img);
import requests

response = requests.post(
    'https://anythingtext.com/api/tools/txt2img',
    json={'prompt': 'A sunset over a mountain lake, digital art style'},
    headers={'X-API-Key': 'your_api_key_here'}
)

data = response.json()
print('Image URL:', data['imageUrl'])

# Download the image
import urllib.request
urllib.request.urlretrieve(data['imageUrl'], 'generated.png')
print('Image saved to generated.png')
import java.net.URI;
import java.net.http.*;

HttpClient client = HttpClient.newHttpClient();
String json = "{\"prompt\": \"A sunset over a mountain lake\"}";

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://anythingtext.com/api/tools/txt2img"))
    .header("Content-Type", "application/json")
    .header("X-API-Key", "your_api_key_here")
    .POST(HttpRequest.BodyPublishers.ofString(json))
    .build();

HttpResponse<String> response = client.send(request,
    HttpResponse.BodyHandlers.ofString());

System.out.println("Response: " + response.body());
// Parse JSON to extract imageUrl