Image Generation
Generates an Image using AI
Generated images will be saved for 7 days. After that period, they will be cached and might no longer be accessible.
POST /api/ai/generate-image
https://api.cookie-api.com/api/ai/generate-image
Authentication Learn how to get your API Key and use it in your requests!
{ "prompt": "Description of the Image that should be generated.",}
curl --location 'https://api.cookie-api.com/api/ai/generate-image' \--header 'Authorization: API_Key' \--data '{ "prompt": "A nice House"}'
import requests
url = 'https://api.cookie-api.com/api/ai/generate-image'headers = { 'Authorization': 'API_Key'}data = { 'prompt': 'A nice House'}
response = requests.post(url, headers=headers, json=data)print(response.json())
const fetch = require('node-fetch');
const url = 'https://api.cookie-api.com/api/ai/generate-image';const headers = { 'Authorization': 'API_Key', 'Content-Type': 'application/json'};const body = { prompt: 'A nice House'};
fetch(url, { method: 'POST', headers: headers, body: JSON.stringify(body)}).then(res => res.json()).then(data => console.log(data)).catch(err => console.error(err));
package main
import ( "bytes" "encoding/json" "fmt" "log" "net/http")
func main() { url := "https://api.cookie-api.com/api/ai/generate-image" requestBody := map[string]string{ "prompt": "A nice House", }
requestBodyJSON, err := json.Marshal(requestBody) if err != nil { log.Fatal(err) }
req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBodyJSON)) if err != nil { log.Fatal(err) }
req.Header.Set("Authorization", "API_Key") req.Header.Set("Content-Type", "application/json")
client := &http.Client{} resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close()
var res map[string]interface{} if err := json.NewDecoder(resp.Body).Decode(&res); err != nil { log.Fatal(err) }
fmt.Println(res)}
const https = require('https');
const options = { hostname: 'api.cookie-api.com', path: '/api/ai/generate-image', method: 'POST', headers: { 'Authorization': 'API_Key', 'Content-Type': 'application/json' }};
const data = JSON.stringify({ prompt: 'A nice House'});
const req = https.request(options, res => { let body = '';
res.on('data', chunk => { body += chunk; });
res.on('end', () => { console.log(JSON.parse(body)); });});
req.on('error', error => { console.error(error);});
req.write(data);req.end();
require 'net/http'require 'uri'require 'json'
uri = URI.parse('https://api.cookie-api.com/api/ai/generate-image')
headers = { 'Authorization' => 'API_Key', 'Content-Type' => 'application/json'}
request_body = { prompt: 'A nice House'}.to_json
request = Net::HTTP::Post.new(uri, headers)request.body = request_body
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(request)end
puts response.body
use reqwest::blocking::Client;use reqwest::header::{HeaderMap, CONTENT_TYPE};
fn main() { let url = "https://api.cookie-api.com/api/ai/generate-image"; let client = Client::new();
let mut headers = HeaderMap::new(); headers.insert("Authorization", "API_Key".parse().unwrap()); headers.insert(CONTENT_TYPE, "application/json".parse().unwrap());
let body = r#"{ "prompt": "A nice House" }"#;
let res = client .post(url) .headers(headers) .body(body) .send() .unwrap();
println!("{}", res.text().unwrap());}
Responses
{ "success": true, "url": "https://images.cookie-api.com/ai/97b77115-ef86-4d88-872b-61c8b657ef2b.jpeg"}