Skip to content

Commit d622975

Browse files
authored
feat: add snippets for google image edit
feat: add snippets for google image edit
2 parents 384a7fe + 5644128 commit d622975

5 files changed

Lines changed: 62 additions & 2 deletions

File tree

‎shared/snippets/image/flux/js.hbs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const main = async () => {
66
'Content-Type': 'application/json',
77
},
88
body: JSON.stringify({
9-
prompt: 'A jellyfish in the ocean',
109
model: '{{model}}',
10+
prompt: 'A jellyfish in the ocean',
1111
}),
1212
}).then((res) => res.json());
1313

‎shared/snippets/image/flux/py.hbs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ def main():
99
"Content-Type": "application/json",
1010
},
1111
json={
12-
"prompt": "A jellyfish in the ocean",
1312
"model": "{{model}}",
13+
"prompt": "A jellyfish in the ocean",
1414
},
1515
)
1616

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"title": "Generate an image",
3+
"docs": "https://docs.aimlapi.com/api-references/image-models",
4+
"payload": {
5+
"baseUrl": "https://api.aimlapi.com/v1",
6+
"apiKey": "<YOUR_API_KEY>"
7+
}
8+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const main = async () => {
5+
const response = await fetch('{{baseUrl}}/images/generations', {
6+
method: 'POST',
7+
headers: {
8+
Authorization: 'Bearer {{apiKey}}',
9+
'Content-Type': 'application/json',
10+
},
11+
body: JSON.stringify({
12+
model: '{{model}}',
13+
prompt: 'Mona Lisa with glasses',
14+
image_urls: [
15+
'https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/960px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg',
16+
'https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Glasses_black.jpg/960px-Glasses_black.jpg',
17+
]
18+
}),
19+
}).then((res) => res.json());
20+
21+
console.log('Generation:', response);
22+
};
23+
24+
main();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import requests
2+
3+
4+
def main():
5+
response = requests.post(
6+
"{{baseUrl}}/images/generations",
7+
headers={
8+
"Authorization": "Bearer {{apiKey}}",
9+
"Content-Type": "application/json",
10+
},
11+
json={
12+
"prompt": "Mona Lisa with glasses",
13+
"model": "{{model}}",
14+
"image_urls": [
15+
"https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/960px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg",
16+
"https://upload.wikimedia.org/wikipedia/commons/thumb/a/af/Glasses_black.jpg/960px-Glasses_black.jpg",
17+
]
18+
},
19+
)
20+
21+
response.raise_for_status()
22+
data = response.json()
23+
24+
print("Generation:", data)
25+
26+
27+
if __name__ == "__main__":
28+
main()

0 commit comments

Comments
 (0)