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
Copy file name to clipboardExpand all lines: README.md
+5-105Lines changed: 5 additions & 105 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,113 +106,13 @@ let result = try await Anthropic(apiKey: "your_claude_api_key")
106
106
)
107
107
```
108
108
109
-
## Amazon Web Services Bedrock
109
+
## Extensions
110
110
111
-
This library provides support for the [Anthropic Bedrock API](https://aws.amazon.com/bedrock/claude/) through a separate package.
111
+
By introducing an extension Swift package, it is possible to access the Anthropic Claude API through AWS Bedrock and Vertex AI. The supported services are as follows:
To create an `AnthropicBedrockClient` from a `BedrockRuntimeClient` with a `Model` to access Claude on Bedrock.
132
-
The API usage is the same as the normal AnthropicClient.
133
-
134
-
```swift
135
-
let client =tryBedrockRuntimeClient(region: "us-west-2")
136
-
let anthropic = client.useAnthropic()
137
-
138
-
let response =tryawait anthropic.messages.createMessage(Message(role: .user, content: [.text("This is test text")]), maxTokens: 1024)
139
-
for content in response.content {
140
-
switch content {
141
-
case .text(let text):
142
-
print(text)
143
-
case .image(let imageContent):
144
-
// handle base64 encoded image content
145
-
}
146
-
}
147
-
```
148
-
149
-
Of course, `Streaming Message API` works in the same way.
150
-
151
-
```swift
152
-
let client =tryBedrockRuntimeClient(region: "us-west-2")
153
-
let anthropic = client.useAnthropic()
154
-
155
-
let stream =tryawait anthropic.messages.streamMessage([Message(role: .user, content: [.text("This is test text")])], maxTokens: 1024)
156
-
fortryawait chunk in stream {
157
-
switch chunk.type {
158
-
case .messageStart:
159
-
// handle message start object with casting chunk into `StreamingMessageStartResponse`
160
-
}
161
-
}
162
-
```
163
-
164
-
## Google Vertex AI
165
-
166
-
This library provides support for the [Anthropic Vertex AI](https://cloud.google.com/blog/products/ai-machine-learning/announcing-anthropics-claude-3-models-in-google-cloud-vertex-ai?hl=en) through a separate package.
0 commit comments