@@ -1064,6 +1064,7 @@ You can use all of the OpenAI snippets aboves with one change. Initialize the Op
1064
1064
1065
1065
### How to generate text content with Gemini
1066
1066
1067
+ ``` swift
1067
1068
import AIProxy
1068
1069
1069
1070
/* Uncomment for BYOK use cases */
@@ -1115,10 +1116,11 @@ You can use all of the OpenAI snippets aboves with one change. Initialize the Op
1115
1116
} catch {
1116
1117
print (" Could not create Gemini generate content request: \( error.localizedDescription ) " )
1117
1118
}
1118
-
1119
+ ```
1119
1120
1120
1121
### How to make a tool call with Gemini
1121
1122
1123
+ ``` swift
1122
1124
import AIProxy
1123
1125
1124
1126
/* Uncomment for BYOK use cases */
@@ -1206,7 +1208,7 @@ You can use all of the OpenAI snippets aboves with one change. Initialize the Op
1206
1208
} catch {
1207
1209
print (" Could not create Gemini tool (function) call: \( error.localizedDescription ) " )
1208
1210
}
1209
-
1211
+ ```
1210
1212
1211
1213
### How to make a search grounding call with Gemini
1212
1214
@@ -1217,6 +1219,7 @@ account for the API keys you use [here](https://aistudio.google.com/app/apikey).
1217
1219
Consider applying to [ google for startups] ( https://cloud.google.com/startup?hl=en ) to gain
1218
1220
credits that you can put towards Gemini.
1219
1221
1222
+ ``` swift
1220
1223
import AIProxy
1221
1224
1222
1225
/* Uncomment for BYOK use cases */
@@ -1270,6 +1273,7 @@ credits that you can put towards Gemini.
1270
1273
} catch {
1271
1274
print (" Could not create Gemini grounding search request: \( error.localizedDescription ) " )
1272
1275
}
1276
+ ```
1273
1277
1274
1278
### How to make a google search grounding call with Gemini 2.0
1275
1279
@@ -1346,11 +1350,11 @@ credits that you can put towards Gemini.
1346
1350
}
1347
1351
```
1348
1352
1349
-
1350
1353
### How to transcribe audio with Gemini
1351
1354
1352
1355
Add a file called ` helloworld.m4a ` to your Xcode assets before running this sample snippet:
1353
1356
1357
+ ``` swift
1354
1358
import AIProxy
1355
1359
1356
1360
/* Uncomment for BYOK use cases */
@@ -1411,13 +1415,13 @@ Add a file called `helloworld.m4a` to your Xcode assets before running this samp
1411
1415
} catch {
1412
1416
print (" Could not create transcript with Gemini: \( error.localizedDescription ) " )
1413
1417
}
1414
-
1418
+ ```
1415
1419
1416
1420
### How to use images in the prompt to Gemini
1417
1421
1418
1422
Add a file called 'my-image.jpg' to Xcode app assets. Then run this snippet:
1419
1423
1420
-
1424
+ ``` swift
1421
1425
import AIProxy
1422
1426
1423
1427
/* Uncomment for BYOK use cases */
@@ -1490,13 +1494,14 @@ Add a file called 'my-image.jpg' to Xcode app assets. Then run this snippet:
1490
1494
} catch {
1491
1495
print (" Could not create Gemini generate content request: \( error.localizedDescription ) " )
1492
1496
}
1493
-
1497
+ ```
1494
1498
1495
1499
### How to upload a video file to Gemini temporary storage
1496
1500
1497
1501
Add a file called ` my-movie.mov ` to your Xcode assets before running this sample snippet.
1498
1502
If you use a file like ` my-movie.mp4 ` , change the mime type from ` video/quicktime ` to ` video/mp4 ` in the snippet below.
1499
1503
1504
+ ``` swift
1500
1505
import AIProxy
1501
1506
1502
1507
/* Uncomment for BYOK use cases */
@@ -1534,12 +1539,13 @@ If you use a file like `my-movie.mp4`, change the mime type from `video/quicktim
1534
1539
} catch {
1535
1540
print (" Could not upload file to Gemini: \( error.localizedDescription ) " )
1536
1541
}
1537
-
1542
+ ```
1538
1543
1539
1544
### How to convert video contents to text with Gemini
1540
1545
1541
1546
Use the file URL returned from the snippet above.
1542
1547
1548
+ ``` swift
1543
1549
import AIProxy
1544
1550
1545
1551
let fileURL = URL (string : " url-from-snippet-above" )!
@@ -1606,10 +1612,11 @@ Use the file URL returned from the snippet above.
1606
1612
} catch {
1607
1613
print (" Could not create Gemini vision request: \( error.localizedDescription ) " )
1608
1614
}
1609
-
1615
+ ```
1610
1616
1611
1617
### How to delete a temporary file from Gemini storage
1612
1618
1619
+ ``` swift
1613
1620
import AIProxy
1614
1621
1615
1622
let fileURL = URL (string : " url-from-snippet-above" )!
@@ -1633,7 +1640,7 @@ Use the file URL returned from the snippet above.
1633
1640
} catch {
1634
1641
print (" Could not delete file from Gemini temporary storage: \( error.localizedDescription ) " )
1635
1642
}
1636
-
1643
+ ```
1637
1644
1638
1645
### How to use structured ouputs with Gemini
1639
1646
@@ -1793,7 +1800,7 @@ Use the file URL returned from the snippet above.
1793
1800
1794
1801
### How to generate an image with Gemini
1795
1802
1796
- ```
1803
+ ``` swift
1797
1804
import AIProxy
1798
1805
1799
1806
/* Uncomment for BYOK use cases */
@@ -1853,7 +1860,7 @@ Use the file URL returned from the snippet above.
1853
1860
}
1854
1861
```
1855
1862
1856
- ### How to generate an image with Imagen
1863
+ ### How to generate an image with Gemini and Imagen
1857
1864
1858
1865
``` swift
1859
1866
import AIProxy
0 commit comments