You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Google AI Swift SDK is the easiest way for Swift developers to build with the Gemini API. The Gemini API gives you access to Gemini [models](https://ai.google.dev/models/gemini) created by [Google DeepMind](https://deepmind.google/technologies/gemini/#introduction). Gemini models are built from the ground up to be multimodal, so you can reason seamlessly across text, images, and code.
7
-
8
-
> [!CAUTION]
9
-
> **The Google AI SDK for Swift is recommended for prototyping only.** If you plan to enable
10
-
> billing, we strongly recommend that you use a backend SDK to access the Google AI Gemini API. You
11
-
> risk potentially exposing your API key to malicious actors if you embed your API key directly in
12
-
> your Swift app or fetch it remotely at runtime.
6
+
The Google AI Swift SDK is the easiest way for Swift developers to build with
7
+
the Gemini API. The Gemini API gives you access to Gemini
8
+
[models](https://ai.google.dev/models/gemini) created by
5. Open and build the sample app in the `Examples` folder of this repo.
22
-
6. Run the app once to ensure the build script generates an empty `GenerativeAI-Info.plist` file
23
-
7. Paste your API key into the `API_KEY` property in the `GenerativeAI-Info.plist` file.
24
-
8. Run the app
25
-
9. For detailed instructions, try the [Swift SDK tutorial](https://ai.google.dev/tutorials/swift_quickstart) on [ai.google.dev](https://ai.google.dev).
21
+
1. Go to [Google AI Studio](https://aistudio.google.com/).
22
+
2. Login with your Google account.
23
+
3.[Create an API key](https://aistudio.google.com/app/apikey). Note that in
[quickstart](https://ai.google.dev/tutorials/swift_quickstart) for the Google AI SDK for Swift in the
55
-
Google documentation.
64
+
[quickstart](https://ai.google.dev/tutorials/swift_quickstart) for the Google AI
65
+
SDK for Swift in the Google documentation.
56
66
57
-
This quickstart describes how to add your API key and the Swift package to your app, initialize the
58
-
model, and then call the API to access the model. It also describes some additional use cases and
59
-
features, like streaming, counting tokens, and controlling responses.
67
+
This quickstart describes how to add your API key and the Swift package to your
68
+
app, initialize the model, and then call the API to access the model. It also
69
+
describes some additional use cases and features, like streaming, counting
70
+
tokens, and controlling responses.
60
71
61
72
## Logging
62
73
63
-
To enable additional logging in the Xcode console, including a cURL command and raw stream
64
-
response for each model request, add `-GoogleGenerativeAIDebugLogEnabled` as
65
-
`Arguments Passed On Launch` in the Xcode scheme.
74
+
To enable additional logging in the Xcode console, including a cURL command and
75
+
raw stream response for each model request, add
76
+
`-GoogleGenerativeAIDebugLogEnabled` as `Arguments Passed On Launch` in the
77
+
Xcode scheme.
66
78
67
79
## Command Line Tool
68
80
69
-
A command line tool is available to experiment with Gemini model requests via Xcode or the command
70
-
line:
81
+
A command line tool is available to experiment with Gemini model requests via
82
+
Xcode or the command line:
71
83
72
-
1.`open Examples/GenerativeAICLI/Package.swift`
73
-
1. Run in Xcode and examine the console to see the options.
74
-
1. Edit the scheme's `Arguments Passed On Launch` with the desired options.
84
+
1.`open Examples/GenerativeAICLI/Package.swift`
85
+
1.Run in Xcode and examine the console to see the options.
86
+
1.Edit the scheme's `Arguments Passed On Launch` with the desired options.
75
87
76
88
## Documentation
77
89
78
-
See the [Gemini API Cookbook](https://github.com/google-gemini/gemini-api-cookbook/) or [ai.google.dev](https://ai.google.dev) for complete documentation.
90
+
See the
91
+
[Gemini API Cookbook](https://github.com/google-gemini/gemini-api-cookbook/) or
92
+
[ai.google.dev](https://ai.google.dev) for complete documentation.
79
93
80
94
## Contributing
81
95
82
-
See [Contributing](https://github.com/google/generative-ai-swift/blob/main/docs/CONTRIBUTING.md)
0 commit comments