@@ -19,6 +19,7 @@ included:
19
19
- OpenRouter
20
20
- DeepSeek
21
21
- Fireworks AI
22
+ - Brave
22
23
23
24
Your initialization code determines whether requests go straight to the provider or are
24
25
protected through the [ AIProxy] ( https://www.aiproxy.pro ) backend.
@@ -100,6 +101,7 @@ offer full demo apps to jump-start your development. Please see the [AIProxyBoot
100
101
* [ OpenRouter] ( #openrouter )
101
102
* [ DeepSeek] ( #deepseek )
102
103
* [ Fireworks AI] ( #fireworks-ai )
104
+ * [ Brave] ( #brave )
103
105
* [ Advanced Settings] ( #advanced-settings )
104
106
105
107
@@ -3825,6 +3827,8 @@ not on the messages's `reasoningContent` property. Instead, the reasoning conten
3825
3827
`message.content` enclosed in `<think></think>` tags:
3826
3828
3827
3829
```swift
3830
+ import AIProxy
3831
+
3828
3832
/* Uncomment for BYOK use cases */
3829
3833
// let fireworksAIService = AIProxy.fireworksAIDirectService(
3830
3834
// unprotectedAPIKey: "your-fireworks-key"
@@ -3874,6 +3878,48 @@ not on the messages's `reasoningContent` property. Instead, the reasoning conten
3874
3878
3875
3879
***
3876
3880
3881
+ ## Brave
3882
+
3883
+ When you create a service in the AIProxy dashboard, use `https://api.search.brave.com` as the
3884
+ proxy base URL.
3885
+
3886
+ ```swift
3887
+ import AIProxy
3888
+
3889
+ /* Uncomment for BYOK use cases */
3890
+ // let braveService = AIProxy.braveDirectService(
3891
+ // unprotectedAPIKey: "your-brave-key"
3892
+ // )
3893
+
3894
+ /* Uncomment for all other production use cases */
3895
+ // let braveService = AIProxy.braveService(
3896
+ // partialKey: "partial-key-from-your-developer-dashboard",
3897
+ // serviceURL: "service-url-from-your-developer-dashboard"
3898
+ // )
3899
+
3900
+ do {
3901
+ let searchResult = try await braveService.webSearchRequest(query: "How does concurrency work in Swift 6")
3902
+ let resultCount = searchResult.web?.results?.count ?? 0
3903
+ let urls = searchResult.web?.results?.compactMap { $0.url }
3904
+ print(
3905
+ """
3906
+ Brave responded with \(resultCount) search results.
3907
+ The search returned these urls: \(urls ?? [])
3908
+ """
3909
+ )
3910
+ } catch AIProxyError.unsuccessfulRequest(let statusCode, let responseBody) {
3911
+ print("Receivedt non-200 status code: \( statusCode ) with response body: \( responseBody ) ")
3912
+ } catch {
3913
+ // You may want to catch additional Foundation errors and pop the appropriate UI
3914
+ // to the user. See "How to catch Foundation errors for specific conditions" here:
3915
+ // https://www.aiproxy.com/docs/integration-options.html
3916
+ print("Could not make brave search: \( error.localizedDescription ) ")
3917
+ }
3918
+ ```
3919
+
3920
+ ***
3921
+
3922
+
3877
3923
## OpenMeteo
3878
3924
3879
3925
### How to fetch the weather with OpenMeteo
0 commit comments