curl TypeScript Python Go
# Step 1: Extract manuscript metadata
EXTRACTION = $ ( curl - s - X POST https://api.iterationlayer.com/document-extraction/v1/extract \
- H " Authorization: Bearer YOUR_API_KEY " \
- H " Content-Type: application/json " \
- d ' {
"files": [
{
"type": "url",
"name": "manuscript.pdf",
"url": "https://example.com/manuscripts/draft.pdf"
}
],
"schema": {
"fields": [
{ "name": "title", "type": "TEXT", "description": "Book title" },
{ "name": "author", "type": "TEXT", "description": "Author full name" },
{ "name": "subtitle", "type": "TEXT", "description": "Book subtitle" }
]
}
} ' )
TITLE = $ ( echo " $ EXTRACTION " | jq - r ' .results[0].fields.title ' )
AUTHOR = $ ( echo " $ EXTRACTION " | jq - r ' .results[0].fields.author ' )
# Step 2: Generate book cover with extracted metadata
curl - X POST https://api.iterationlayer.com/image-generation/v1/generate \
- H " Authorization: Bearer YOUR_API_KEY " \
- H " Content-Type: application/json " \
- d " {
\" dimensions \" : { \" width \" : 600, \" height \" : 900 },
\" output_format \" : \" png \" ,
\" layers \" : [
{
\" index \" : 0,
\" type \" : \" gradient \" ,
\" gradient_type \" : \" linear \" ,
\" angle_in_degrees \" : 180.0,
\" colors \" : [
{ \" hex_color \" : \" #1B1464 \" , \" position \" : 0.0 },
{ \" hex_color \" : \" #6C63FF \" , \" position \" : 100.0 }
],
\" position \" : { \" x \" : 0.0, \" y \" : 0.0 },
\" dimensions \" : { \" width \" : 600, \" height \" : 900 }
},
{
\" index \" : 1,
\" type \" : \" text \" ,
\" text \" : \" $ TITLE \" ,
\" font_name \" : \" Playfair Display \" ,
\" font_size_in_px \" : 52,
\" text_color \" : \" #FFFFFF \" ,
\" font_weight \" : \" Bold \" ,
\" text_align \" : \" center \" ,
\" position \" : { \" x \" : 50.0, \" y \" : 200.0 },
\" dimensions \" : { \" width \" : 500, \" height \" : 200 }
},
{
\" index \" : 2,
\" type \" : \" text \" ,
\" text \" : \" $ AUTHOR \" ,
\" font_name \" : \" Inter \" ,
\" font_size_in_px \" : 24,
\" text_color \" : \" #D4D0FF \" ,
\" text_align \" : \" center \" ,
\" position \" : { \" x \" : 50.0, \" y \" : 750.0 },
\" dimensions \" : { \" width \" : 500, \" height \" : 40 }
}
]
} " import { IterationLayer } from " iterationlayer " ;
const client = new IterationLayer ( { apiKey : " YOUR_API_KEY " } ) ;
// Step 1: Extract manuscript metadata
const extraction = await client . extract ( {
files : [
{
type : " url " ,
name : " manuscript.pdf " ,
url : " https://example.com/manuscripts/draft.pdf " ,
} ,
] ,
schema : {
fields : [
{ name : " title " , type : " TEXT " , description : " Book title " } ,
{ name : " author " , type : " TEXT " , description : " Author full name " } ,
{ name : " subtitle " , type : " TEXT " , description : " Book subtitle " } ,
] ,
} ,
} ) ;
const { title , author } = extraction . results [ 0 ] . fields ;
// Step 2: Generate book cover with extracted metadata
const coverResult = await client . generateImage ( {
dimensions : { width_in_px : 600 , height_in_px : 900 } ,
output_format : " png " ,
layers : [
{
index : 0 ,
type : " gradient " ,
gradient_type : " linear " ,
angle_in_degrees : 180 . 0 ,
colors : [
{ hex_color : " #1B1464 " , position : 0 . 0 } ,
{ hex_color : " #6C63FF " , position : 100 . 0 } ,
] ,
position : { x_in_px : 0 , y_in_px : 0 } ,
dimensions : { width_in_px : 600 , height_in_px : 900 } ,
} ,
{
index : 1 ,
type : " text " ,
text : title ,
font_name : " Playfair Display " ,
font_size_in_px : 52 ,
text_color : " #FFFFFF " ,
font_weight : " Bold " ,
text_align : " center " ,
position : { x_in_px : 50 , y_in_px : 200 } ,
dimensions : { width_in_px : 500 , height_in_px : 200 } ,
} ,
{
index : 2 ,
type : " text " ,
text : author ,
font_name : " Inter " ,
font_size_in_px : 24 ,
text_color : " #D4D0FF " ,
text_align : " center " ,
position : { x_in_px : 50 , y_in_px : 750 } ,
dimensions : { width_in_px : 500 , height_in_px : 40 } ,
} ,
] ,
} ) ;
await Bun . write ( " cover.png " , Buffer . from ( coverResult . data . buffer , " base64 " ) ) ; import base64
from iterationlayer import IterationLayer
client = IterationLayer ( api_key = " YOUR_API_KEY " )
# Step 1: Extract manuscript metadata
extraction = client . extract (
files = [
{
" type " : " url " ,
" name " : " manuscript.pdf " ,
" url " : " https://example.com/manuscripts/draft.pdf " ,
}
] ,
schema = {
" fields " : [
{ " name " : " title " , " type " : " TEXT " , " description " : " Book title " } ,
{ " name " : " author " , " type " : " TEXT " , " description " : " Author full name " } ,
{ " name " : " subtitle " , " type " : " TEXT " , " description " : " Book subtitle " } ,
]
} ,
)
fields = extraction [ " results " ] [ 0 ] [ " fields " ]
title = fields [ " title " ]
author = fields [ " author " ]
# Step 2: Generate book cover with extracted metadata
cover_result = client . generate_image (
dimensions = { " width_in_px " : 600 , " height_in_px " : 900 } ,
output_format = " png " ,
layers = [
{
" index " : 0 ,
" type " : " gradient " ,
" gradient_type " : " linear " ,
" angle_in_degrees " : 180 . 0 ,
" colors " : [
{ " hex_color " : " #1B1464 " , " position " : 0 . 0 } ,
{ " hex_color " : " #6C63FF " , " position " : 100 . 0 } ,
] ,
" position " : { " x_in_px " : 0 , " y_in_px " : 0 } ,
" dimensions " : { " width_in_px " : 600 , " height_in_px " : 900 } ,
} ,
{
" index " : 1 ,
" type " : " text " ,
" text " : title ,
" font_name " : " Playfair Display " ,
" font_size_in_px " : 52 ,
" text_color " : " #FFFFFF " ,
" font_weight " : " Bold " ,
" text_align " : " center " ,
" position " : { " x_in_px " : 50 , " y_in_px " : 200 } ,
" dimensions " : { " width_in_px " : 500 , " height_in_px " : 200 } ,
} ,
{
" index " : 2 ,
" type " : " text " ,
" text " : author ,
" font_name " : " Inter " ,
" font_size_in_px " : 24 ,
" text_color " : " #D4D0FF " ,
" text_align " : " center " ,
" position " : { " x_in_px " : 50 , " y_in_px " : 750 } ,
" dimensions " : { " width_in_px " : 500 , " height_in_px " : 40 } ,
} ,
] ,
)
with open ( " cover.png " , " wb " ) as f :
f . write ( base64 . b64decode ( cover_result [ " data " ] [ " buffer " ] ) ) package main
import il " github.com/iterationlayer/sdk-go "
client := il . NewClient ( " YOUR_API_KEY " )
// Step 1: Extract manuscript metadata
extraction , err := client . Extract ( il . ExtractRequest {
Files : [ ] il . FileInput {
il . NewFileFromURL ( " manuscript.pdf " , " https://example.com/manuscripts/draft.pdf " ) ,
} ,
Schema : il . ExtractionSchema {
" title " : il . NewTextFieldConfig ( " title " , " Book title " ) ,
" author " : il . NewTextFieldConfig ( " author " , " Author full name " ) ,
" subtitle " : il . NewTextFieldConfig ( " subtitle " , " Book subtitle " ) ,
} ,
} )
title := extraction . Results [ 0 ] . Fields [ " title " ]
author := extraction . Results [ 0 ] . Fields [ " author " ]
// Step 2: Generate book cover with extracted metadata
coverResult , err := client . GenerateImage ( il . GenerateImageRequest {
Dimensions : il . Dimensions { WidthInPx : 600 , HeightInPx : 900 } ,
OutputFormat : " png " ,
Layers : [ ] il . Layer {
il . NewGradientLayer ( 0 , " linear " ,
[ ] il . GradientColor {
{ HexColor : " #1B1464 " , Position : 0 . 0 } ,
{ HexColor : " #6C63FF " , Position : 100 . 0 } ,
} ,
il . Position { XInPx : 0 , YInPx : 0 } ,
il . Dimensions { WidthInPx : 600 , HeightInPx : 900 } ) ,
il . NewTextLayer ( 1 , title , " Playfair Display " , 52 , " #FFFFFF " ,
il . Position { XInPx : 50 , YInPx : 200 } ,
il . Dimensions { WidthInPx : 500 , HeightInPx : 200 } ) ,
il . NewTextLayer ( 2 , author , " Inter " , 24 , " #D4D0FF " ,
il . Position { XInPx : 50 , YInPx : 750 } ,
il . Dimensions { WidthInPx : 500 , HeightInPx : 40 } ) ,
} ,
} )