Skip to content

Commit 2ec91c4

Browse files
authored
Update README.md
1 parent 63ed0c5 commit 2ec91c4

File tree

1 file changed

+5
-105
lines changed

1 file changed

+5
-105
lines changed

README.md

Lines changed: 5 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -106,113 +106,13 @@ let result = try await Anthropic(apiKey: "your_claude_api_key")
106106
)
107107
```
108108

109-
## Amazon Web Services Bedrock
109+
## Extensions
110110

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:
112112

113-
```swift
114-
let package = Package(
115-
name: "MyPackage",
116-
products: [...],
117-
targets: [
118-
.target(
119-
"YouAppModule",
120-
dependencies: [
121-
.product(name: "AnthropicSwiftSDK-Bedrock", package: "AnthropicSwiftSDK")
122-
]
123-
)
124-
],
125-
dependencies: [
126-
.package(url: "https://github.com/fumito-ito/AnthropicSwiftSDK.git", .upToNextMajor(from: "0.5.0"))
127-
]
128-
)
129-
```
130-
131-
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 = try BedrockRuntimeClient(region: "us-west-2")
136-
let anthropic = client.useAnthropic()
137-
138-
let response = try await 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 = try BedrockRuntimeClient(region: "us-west-2")
153-
let anthropic = client.useAnthropic()
154-
155-
let stream = try await anthropic.messages.streamMessage([Message(role: .user, content: [.text("This is test text")])], maxTokens: 1024)
156-
for try await 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.
167-
168-
```swift
169-
let package = Package(
170-
name: "MyPackage",
171-
products: [...],
172-
targets: [
173-
.target(
174-
"YouAppModule",
175-
dependencies: [
176-
.product(name: "AnthropicSwiftSDK-VertexAI", package: "AnthropicSwiftSDK")
177-
]
178-
)
179-
],
180-
dependencies: [
181-
.package(url: "https://github.com/fumito-ito/AnthropicSwiftSDK.git", .upToNextMajor(from: "0.5.0"))
182-
]
183-
)
184-
```
185-
186-
To create an `AnthropicVertexAIClient` with a `Model` to access Claude on VertexAI.
187-
The API usage is the same as the normal AnthropicClient.
188-
189-
```swift
190-
let anthropic = AnthropicVertexAIClient(projectId: "your-project-id", accessToken: "access-token-for-vertexai", region = .usCentral1)
191-
192-
let response = try await anthropic.messages.createMessage(Message(role: .user, content: [.text("This is test text")]), maxTokens: 1024)
193-
for content in response.content {
194-
switch content {
195-
case .text(let text):
196-
print(text)
197-
case .image(let imageContent):
198-
// handle base64 encoded image content
199-
}
200-
}
201-
```
202-
203-
Of course, `Streaming Message API` works in the same way.
204-
205-
```swift
206-
let anthropic = AnthropicVertexAIClient(projectId: "your-project-id", accessToken: "access-token-for-vertexai", region = .usCentral1)
207-
208-
let stream = try await anthropic.messages.streamMessage([Message(role: .user, content: [.text("This is test text")])], maxTokens: 1024)
209-
for try await chunk in stream {
210-
switch chunk.type {
211-
case .messageStart:
212-
// handle message start object with casting chunk into `StreamingMessageStartResponse`
213-
}
214-
}
215-
```
113+
- [Amazon Web Services Bedrock](https://github.com/fumito-ito/AnthropicSwiftSDK-Bedrock)
114+
- VertexAI
115+
- T.B.D.
216116

217117
## Contributing
218118

0 commit comments

Comments
 (0)