Python
from magic_hour import Client
from os import getenv
client = Client(token=getenv("API_TOKEN"))
res = client.v1.ai_qr_code_generator.generate(
content="https://magichour.ai",
style={"art_style": "Watercolor"},
name="Qr Code image",
wait_for_completion=True,
download_outputs=True,
download_directory="."
)import { Client } from "magic-hour";
const client = new Client({ token: process.env["API_TOKEN"]!! });
const res = await client.v1.aiQrCodeGenerator.generate(
{
content: "https://magichour.ai",
name: "Qr Code image",
style: { artStyle: "Watercolor" },
},
{
waitForCompletion: true,
downloadOutputs: true,
downloadDirectory: ".",
},
);package main
import (
os "os"
sdk "github.com/magichourhq/magic-hour-go/client"
nullable "github.com/magichourhq/magic-hour-go/nullable"
ai_qr_code_generator "github.com/magichourhq/magic-hour-go/resources/v1/ai_qr_code_generator"
types "github.com/magichourhq/magic-hour-go/types"
)
func main() {
client := sdk.NewClient(
sdk.WithBearerAuth(os.Getenv("API_TOKEN")),
)
res, err := client.V1.AiQrCodeGenerator.Create(ai_qr_code_generator.CreateRequest{
Content: "https://magichour.ai",
Name: nullable.NewValue("My Qr Code image"),
Style: types.V1AiQrCodeGeneratorCreateBodyStyle{
ArtStyle: "Watercolor",
},
})
}let client = magic_hour::Client::default()
.with_bearer_auth(&std::env::var("API_TOKEN").unwrap());
let res = client
.v1()
.ai_qr_code_generator()
.create(magic_hour::resources::v1::ai_qr_code_generator::CreateRequest {
content: "https://magichour.ai".to_string(),
name: Some("My Qr Code image".to_string()),
style: magic_hour::models::V1AiQrCodeGeneratorCreateBodyStyle {
art_style: "Watercolor".to_string(),
},
})
.await;curl --request POST \
--url https://api.magichour.ai/v1/ai-qr-code-generator \
--header 'accept: application/json' \
--header 'authorization: Bearer <token>' \
--header 'content-type: application/json' \
--data '
{
"name": "My Qr Code image",
"content": "https://magichour.ai",
"style": {
"art_style": "Watercolor"
}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.magichour.ai/v1/ai-qr-code-generator",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'My Qr Code image',
'content' => 'https://magichour.ai',
'style' => [
'art_style' => 'Watercolor'
]
]),
CURLOPT_HTTPHEADER => [
"accept: application/json",
"authorization: Bearer <token>",
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.magichour.ai/v1/ai-qr-code-generator")
.header("accept", "application/json")
.header("content-type", "application/json")
.header("authorization", "Bearer <token>")
.body("{\"name\":\"My Qr Code image\",\"content\":\"https://magichour.ai\",\"style\":{\"art_style\":\"Watercolor\"}}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magichour.ai/v1/ai-qr-code-generator")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": \"https://magichour.ai\",\n \"style\": {\n \"art_style\": \"Watercolor\"\n },\n \"name\": \"My Qr Code image\"\n}"
response = http.request(request)
puts response.read_body{
"id": "cuid-example",
"credits_charged": 0
}{
"code": "invalid_request",
"message": "<string>"
}{
"code": "unauthorized",
"message": "<string>"
}{
"code": "insufficient_credits",
"message": "<string>"
}{
"code": "not_found",
"message": "<string>"
}{
"code": "unprocessable_entity",
"message": "<string>"
}{
"code": "internal_server_error",
"message": "<string>"
}Image Projects
AI QR Code Generator
Create an AI QR code. Each QR code costs 0 credits.
POST
/
v1
/
ai-qr-code-generator
Python
from magic_hour import Client
from os import getenv
client = Client(token=getenv("API_TOKEN"))
res = client.v1.ai_qr_code_generator.generate(
content="https://magichour.ai",
style={"art_style": "Watercolor"},
name="Qr Code image",
wait_for_completion=True,
download_outputs=True,
download_directory="."
)import { Client } from "magic-hour";
const client = new Client({ token: process.env["API_TOKEN"]!! });
const res = await client.v1.aiQrCodeGenerator.generate(
{
content: "https://magichour.ai",
name: "Qr Code image",
style: { artStyle: "Watercolor" },
},
{
waitForCompletion: true,
downloadOutputs: true,
downloadDirectory: ".",
},
);package main
import (
os "os"
sdk "github.com/magichourhq/magic-hour-go/client"
nullable "github.com/magichourhq/magic-hour-go/nullable"
ai_qr_code_generator "github.com/magichourhq/magic-hour-go/resources/v1/ai_qr_code_generator"
types "github.com/magichourhq/magic-hour-go/types"
)
func main() {
client := sdk.NewClient(
sdk.WithBearerAuth(os.Getenv("API_TOKEN")),
)
res, err := client.V1.AiQrCodeGenerator.Create(ai_qr_code_generator.CreateRequest{
Content: "https://magichour.ai",
Name: nullable.NewValue("My Qr Code image"),
Style: types.V1AiQrCodeGeneratorCreateBodyStyle{
ArtStyle: "Watercolor",
},
})
}let client = magic_hour::Client::default()
.with_bearer_auth(&std::env::var("API_TOKEN").unwrap());
let res = client
.v1()
.ai_qr_code_generator()
.create(magic_hour::resources::v1::ai_qr_code_generator::CreateRequest {
content: "https://magichour.ai".to_string(),
name: Some("My Qr Code image".to_string()),
style: magic_hour::models::V1AiQrCodeGeneratorCreateBodyStyle {
art_style: "Watercolor".to_string(),
},
})
.await;curl --request POST \
--url https://api.magichour.ai/v1/ai-qr-code-generator \
--header 'accept: application/json' \
--header 'authorization: Bearer <token>' \
--header 'content-type: application/json' \
--data '
{
"name": "My Qr Code image",
"content": "https://magichour.ai",
"style": {
"art_style": "Watercolor"
}
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.magichour.ai/v1/ai-qr-code-generator",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'My Qr Code image',
'content' => 'https://magichour.ai',
'style' => [
'art_style' => 'Watercolor'
]
]),
CURLOPT_HTTPHEADER => [
"accept: application/json",
"authorization: Bearer <token>",
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://api.magichour.ai/v1/ai-qr-code-generator")
.header("accept", "application/json")
.header("content-type", "application/json")
.header("authorization", "Bearer <token>")
.body("{\"name\":\"My Qr Code image\",\"content\":\"https://magichour.ai\",\"style\":{\"art_style\":\"Watercolor\"}}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magichour.ai/v1/ai-qr-code-generator")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": \"https://magichour.ai\",\n \"style\": {\n \"art_style\": \"Watercolor\"\n },\n \"name\": \"My Qr Code image\"\n}"
response = http.request(request)
puts response.read_body{
"id": "cuid-example",
"credits_charged": 0
}{
"code": "invalid_request",
"message": "<string>"
}{
"code": "unauthorized",
"message": "<string>"
}{
"code": "insufficient_credits",
"message": "<string>"
}{
"code": "not_found",
"message": "<string>"
}{
"code": "unprocessable_entity",
"message": "<string>"
}{
"code": "internal_server_error",
"message": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <api_key>, where <api_key> is your API key. To get your API key, go to Developer Hub and click "Create new API Key".
Body
application/json
Body
Response
Success
Success
Unique ID of the image. Use it with the Get image Project API to fetch status and downloads.
Example:
"cuid-example"
The amount of credits deducted from your account to generate the image. We charge credits right when the request is made.
If an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund.
Example:
0
Was this page helpful?