Skip to content

Commit c5bb6bc

Browse files
committed
docs: make README public-facing for CN and BytePlus
## Summary - rewrite the README for public SDK users - document Volcengine China and BytePlus client initialization - organize supported examples into CN and BytePlus Maven modules - use regional Chat, Responses, embedding, image, and video model IDs - remove retired Seededit image-edit examples - omit the BytePlus text-only embedding example because BytePlus has no model for that endpoint - correct BytePlus IAM comments and environment variable names - keep MCP in both clouds and other hosted built-in tools CN-only with explicit beta headers - add usage and manual migration guidance without internal roadmap language ## Regional model defaults - Responses and Chat: doubao-seed-2-1-pro-260628 / seed-2-0-lite-260428 - Multimodal and sparse embeddings: doubao-embedding-vision-251215 / skylark-embedding-vision-251215 - Image: doubao-seedream-5-0-pro-260628 / dola-seedream-5-0-pro-260628 - Video: doubao-seedance-2-0-fast-260128 / dreamina-seedance-2-0-fast-260128 ## Validation - Maven SDK install and CN/BytePlus example module tests after rebasing onto the latest generated SDK branch - documentation model, link, and whitespace checks See merge request: !78 Sync-Source-Commit: c160b620adb7523914ccb0b52fc539b524e1a3a2 Hand-Written-Reason: Hand-written public documentation and regional examples update; not produced by ark-apis generation. Release-Version: 0.4.0
1 parent 4471db4 commit c5bb6bc

50 files changed

Lines changed: 2508 additions & 275 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Ark Runtime Java SDK
22

3-
The Ark Runtime Java SDK provides convenient access to the Volcengine Ark
4-
REST API from Java 8+ applications. It includes typed request/response
5-
models for every API endpoint, synchronous and streaming helpers, and
6-
automatic retry logic.
3+
The official Java library for accessing ModelArk on Volcengine and BytePlus. It provides typed request and response models, synchronous and streaming helpers, authentication, and automatic retries for Java 8+ applications.
74

85
## Installation
96

@@ -23,34 +20,45 @@ automatic retry logic.
2320
implementation 'com.volcengine:ark-runtime:0.4.0'
2421
```
2522

26-
## Usage
23+
## Choose Volcengine or BytePlus
24+
25+
Set `ARK_API_KEY`, then choose the builder for the service you use. The builder configures the correct base URL and region; request construction and all subsequent SDK calls are the same.
26+
27+
### Volcengine (China)
2728

28-
### Authentication
29+
```java
30+
ArkService service = ArkService.volc()
31+
.apiKey(System.getenv("ARK_API_KEY"))
32+
.build();
33+
```
2934

30-
The SDK reads the `ARK_API_KEY` environment variable by default. You can
31-
also pass the key explicitly via the builder:
35+
### BytePlus (BP)
3236

3337
```java
34-
ArkService service = ArkService.builder()
38+
ArkService service = ArkService.byteplus()
3539
.apiKey(System.getenv("ARK_API_KEY"))
3640
.build();
3741
```
3842

43+
Use a model ID available in the corresponding Volcengine or BytePlus account. Model IDs can differ between the two services; the examples use `doubao-seed-2-1-pro-260628` for Volcengine and `seed-2-0-lite-260428` for BytePlus. Override either default with `ARK_MODEL`.
44+
45+
## Quick start
46+
3947
### Responses API
4048

4149
The Responses API is the primary interface for generating text with Ark
4250
models.
4351

4452
```java
45-
import com.volcengine.ark.runtime.ArkService;
53+
import com.volcengine.ark.runtime.service.ArkService;
4654
import com.volcengine.ark.runtime.models.responses.*;
4755

48-
ArkService service = ArkService.builder()
56+
ArkService service = ArkService.volc()
4957
.apiKey(System.getenv("ARK_API_KEY"))
5058
.build();
5159

5260
ResponsesRequest request = ResponsesRequest.builder()
53-
.model("doubao-seed-2-1-pro-260628")
61+
.model(System.getenv("ARK_MODEL"))
5462
.input(ResponsesInput.ofString("Explain Java generics in two sentences."))
5563
.build();
5664

@@ -60,13 +68,17 @@ System.out.println(response.getOutput());
6068
service.shutdownExecutor();
6169
```
6270

71+
Set `ARK_MODEL` to a model ID from your account before running the example.
72+
73+
## Usage
74+
6375
### Chat Completions
6476

6577
```java
6678
import com.volcengine.ark.runtime.models.chat.*;
6779

6880
ChatCompletionRequest request = ChatCompletionRequest.builder()
69-
.model("doubao-seed-2-1-pro-260628")
81+
.model(System.getenv("ARK_MODEL"))
7082
.messages(Arrays.asList(
7183
ChatCompletionRequestUserMessage.builder()
7284
.role(ChatCompletionRequestMessageType.USER)
@@ -104,10 +116,9 @@ method -- you do not need to set it on the request builder.
104116
```java
105117
import io.reactivex.Flowable;
106118
import com.volcengine.ark.runtime.models.responses.*;
107-
import com.volcengine.ark.runtime.models.responses.events.*;
108119

109120
ResponsesRequest request = ResponsesRequest.builder()
110-
.model("doubao-seed-2-1-pro-260628")
121+
.model(System.getenv("ARK_MODEL"))
111122
.input(ResponsesInput.ofString("Write a haiku about Java."))
112123
.build();
113124

@@ -142,19 +153,28 @@ Build tools with `FunctionTool.builder()` and pass them in the request:
142153

143154
```java
144155
import com.volcengine.ark.runtime.models.responses.*;
156+
import java.util.*;
157+
158+
Map<String, Object> city = new HashMap<>();
159+
city.put("type", "string");
160+
city.put("description", "City name");
161+
162+
Map<String, Object> properties = new HashMap<>();
163+
properties.put("city", city);
164+
165+
Map<String, Object> parameters = new HashMap<>();
166+
parameters.put("type", "object");
167+
parameters.put("properties", properties);
168+
parameters.put("required", Collections.singletonList("city"));
145169

146170
FunctionTool weatherTool = FunctionTool.builder()
147171
.name("get_weather")
148172
.description("Get the current weather for a city")
149-
.parameters(Map.of(
150-
"type", "object",
151-
"properties", Map.of(
152-
"city", Map.of("type", "string", "description", "City name")),
153-
"required", List.of("city")))
173+
.parameters(parameters)
154174
.build();
155175

156176
ResponsesRequest request = ResponsesRequest.builder()
157-
.model("doubao-seed-2-1-pro-260628")
177+
.model(System.getenv("ARK_MODEL"))
158178
.input(ResponsesInput.ofString("What is the weather in Beijing?"))
159179
.tools(Collections.singletonList(Tool.ofFunction(weatherTool)))
160180
.build();
@@ -178,32 +198,19 @@ try {
178198
}
179199
```
180200

181-
## API Reference
182-
183-
| API | Method |
184-
|------------------------|----------------------------------------------------------------------------|
185-
| Responses | `service.createResponse()` / `service.streamResponse()` |
186-
| Chat Completions | `service.createChatCompletion()` / `service.streamChatCompletion()` |
187-
| Embeddings | `service.createEmbedding()` |
188-
| Multimodal Embeddings | `service.createMultiModalEmbedding()` |
189-
| Content Generation | `service.createContentGenerationTask()` |
190-
| Images | `service.createImageGeneration()` |
191-
| Files | `service.createFile()` / `service.listFiles()` / `service.deleteFile()` |
192-
| Tokenization | `service.createTokenization()` |
193-
194201
## Examples
195202

203+
For detailed usage guidance and legacy migration, see
204+
[`docs/README.md`](docs/README.md) and
205+
[`docs/migration.md`](docs/migration.md).
206+
196207
Runnable single-file programs are available in the
197208
[examples/](./examples) directory:
198209

199-
- **Responses** -- `CreateResponseExample`, `ResponseOperationsExample`
200-
- **Chat Completions** -- `ChatCompletionsExample`, `ChatCompletionsFunctionCallExample`, `ChatCompletionsVisionExample`
201-
- **Embeddings** -- `EmbeddingsExample`, `MultiModalEmbeddingsExample`, `SparseEmbeddingsExample`
202-
- **Content Generation** -- `ContentGenerationTaskExample`
203-
- **Images** -- `ImageGenerationExample`
204-
- **Files** -- `FileUploadExample`, `FileVideoResponsesExample`
205-
- **Tokenization** -- `TokenizationExample`
206-
- **Batch** -- `BatchChatCompletionsExample`
210+
- **[Volcengine China examples](./examples/volc)** -- Chat, Responses, images, video generation, embeddings, files, tokenization, batch APIs, and resource APIs using `ArkService.volc()`
211+
- **[BytePlus examples](./examples/byteplus)** -- supported counterparts using `ArkService.byteplus()` and BytePlus model IDs
212+
213+
MCP is demonstrated in both clouds with `ark-beta-mcp: true`. Other built-in-tool examples are CN-only and explicitly send their required beta headers.
207214

208215
## Requirements
209216

‎docs/README.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Ark Runtime Java SDK documentation
2+
3+
This directory contains detailed usage and migration guidance for the Ark
4+
Runtime Java SDK.
5+
6+
## Choose the right document
7+
8+
- [Usage guide](usage.md): dependency setup, regional
9+
clients, generated request models, streaming, and built-in tools.
10+
- [Migration guide](migration.md): migrate from either legacy Volcengine or
11+
BytePlus Java SDK.
12+
- [`../examples/volc`](../examples/volc): runnable Volcengine examples.
13+
- [`../examples/byteplus`](../examples/byteplus): runnable BytePlus examples.
14+
15+
## Important usage rules
16+
17+
1. Use `ArkService.volc()` for CN or `ArkService.byteplus()` for BytePlus. Only
18+
client creation and regional model identifiers differ; request setup stays
19+
the same.
20+
2. Read `ARK_API_KEY` from the environment. Never insert credentials into
21+
source, build files, fixtures, logs, or generated patches.
22+
3. Build requests with classes under `com.volcengine.ark.runtime.models`.
23+
Respect generated union factories such as `ResponsesInput.ofString`.
24+
4. Responses streams contain typed event subclasses. Handle the subclasses the
25+
application needs and tolerate additional event types.
26+
5. MCP is supported in CN and BytePlus. Other hosted built-in tools shown in
27+
this repository are CN-only. Pass the matching `ark-beta-*` header to both
28+
streaming and non-streaming requests.
29+
6. Call `shutdownExecutor()` when an application owns the service lifecycle.
30+
31+
## Minimal verification
32+
33+
```bash
34+
mvn test
35+
mvn checkstyle:check
36+
```
37+
38+
Also run one streaming and one non-streaming request in the selected cloud.
39+
Smoke-test each built-in tool separately to validate its entitlement and beta
40+
header.

‎docs/migration.md‎

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Migrate from the legacy Java SDK
2+
3+
This guide covers:
4+
5+
- `com.volcengine:volcengine-java-sdk-ark-runtime`
6+
- `com.byteplus:byteplus-java-sdk-v2-ark-runtime`
7+
8+
Both migrate to `com.volcengine:ark-runtime`. The new common Java package is
9+
also `com.volcengine.ark.runtime` for BytePlus applications.
10+
11+
## 1. Migration order
12+
13+
Migrate one API flow at a time:
14+
15+
1. Choose the target cloud: Volcengine (CN) or BytePlus.
16+
2. Replace the Ark Runtime dependency and select the regional service builder.
17+
3. Update imports to the new common package and API-specific generated models.
18+
4. Rebuild request unions with the new factories and generated enums.
19+
5. Update response types, Chat deltas, and Responses event subclasses.
20+
6. Add the required beta header to every built-in-tool request and remove any
21+
CN-only tool from a BytePlus target.
22+
7. Compile and smoke-test that flow before migrating the next one.
23+
24+
Do not bulk-replace the old model package or event class names. The correct new
25+
class depends on the request variant and the events the application consumes.
26+
27+
## 2. Dependency and client mapping
28+
29+
```xml
30+
<dependency>
31+
<groupId>com.volcengine</groupId>
32+
<artifactId>ark-runtime</artifactId>
33+
<version>0.1.0</version>
34+
</dependency>
35+
```
36+
37+
| Legacy | New |
38+
|---|---|
39+
| `ArkService.builder()` | CN: `ArkService.volc()`; BP: `ArkService.byteplus()` |
40+
| `new ArkService(apiKey)` | use regional builder, `.apiKey(apiKey).build()` |
41+
| `com.byteplus.ark.runtime...` | `com.volcengine.ark.runtime...` |
42+
| old `.model...` packages | new `.models...` API-specific classes |
43+
44+
Preserve dispatcher, connection pool, timeout, and API key calls after changing
45+
the builder entry point.
46+
47+
## 3. Request-model mapping
48+
49+
The generated model layer changed substantially; do not bulk-replace `model`
50+
with `models` and assume the result is correct.
51+
52+
Chat mappings:
53+
54+
| Legacy | New |
55+
|---|---|
56+
| `model.completion.chat.ChatMessage` | typed `models.chat.ChatCompletionRequest*Message` subtype |
57+
| `ChatMessageRole.USER` | `ChatCompletionRequestMessageType.USER` |
58+
| string message content | `ChatCompletionMessageContent.ofString(value)` |
59+
| `ChatCompletionRequest` | `models.chat.ChatCompletionRequest` |
60+
61+
Responses mappings:
62+
63+
| Legacy | New |
64+
|---|---|
65+
| `CreateResponsesRequest` | `ResponsesRequest` |
66+
| `ResponseObject` | `Response` |
67+
| `ResponsesInput.builder().stringValue(v).build()` | `ResponsesInput.ofString(v)` |
68+
| list input builder | `ResponsesInput.ofList(List<InputItem>)` |
69+
| `ResponsesThinking` | `Thinking` |
70+
| `ResponsesConstants` values | generated enums such as `ThinkingMode` and `MessageRole` |
71+
72+
For a list input, construct a concrete `InputItem` implementation, place it in
73+
a `List<InputItem>`, then call `ResponsesInput.ofList`. For function results,
74+
use `ItemFunctionToolCallOutput` and keep both the tool call ID and previous
75+
response ID.
76+
77+
If the old application persists serialized request JSON, add a fixture test
78+
that deserializes or rebuilds it with new models and compares the outgoing JSON
79+
field by field.
80+
81+
## 4. Streaming mapping
82+
83+
The RxJava flow remains, but payload access changed.
84+
85+
Chat:
86+
87+
| Legacy | New |
88+
|---|---|
89+
| `choice.getChoices().get(0).getMessage().getContent()` | `chunk.getChoices().get(0).getDelta().getContent()` |
90+
91+
Responses:
92+
93+
| Legacy | New |
94+
|---|---|
95+
| `model.responses.event.StreamEvent` | `models.responses.ResponseStreamEvent` |
96+
| old event subpackages | generated event classes directly in `models.responses` |
97+
| `OutputTextDeltaEvent` | `ResponseTextDeltaEvent` |
98+
| `ResponseCompletedEvent` | new `ResponseCompletedEvent` class and `Response` payload |
99+
100+
Use `instanceof` before casting. Capture function/MCP IDs from their typed
101+
output-item event and response IDs from the completed event. Preserve
102+
`doOnError` or an equivalent error path; `blockingForEach` returning normally is
103+
the end of stream, not proof that every expected event was present.
104+
105+
## 5. Extra headers and regional behavior
106+
107+
Both ordinary and stream methods have header-map overloads:
108+
109+
```java
110+
Map<String, String> headers = Collections.singletonMap("ark-beta-mcp", "true");
111+
service.createResponse(request, headers);
112+
service.streamResponse(request, headers);
113+
```
114+
115+
MCP (`ark-beta-mcp`) is supported in both clouds. Web search
116+
(`ark-beta-web-search`), knowledge search (`ark-beta-knowledge-search`), Doubao
117+
App (`ark-beta-doubao-app`), and image process (`ark-beta-image-process`) are
118+
CN-only. A BytePlus migration must stop for review if it finds one of those
119+
tools.
120+
121+
## 6. Regional model IDs
122+
123+
Model names and endpoint IDs are cloud-specific. Prefer application
124+
configuration, and update any legacy hard-coded default when changing clouds:
125+
126+
| API | Volcengine (CN) example | BytePlus example |
127+
|---|---|---|
128+
| Responses / Chat | `doubao-seed-2-1-pro-260628` | `seed-2-0-lite-260428` |
129+
| Multimodal / sparse embeddings | `doubao-embedding-vision-251215` | `skylark-embedding-vision-251215` |
130+
| Image generation | `doubao-seedream-5-0-pro-260628` | `dola-seedream-5-0-pro-260628` |
131+
| Video generation | `doubao-seedance-2-0-fast-260128` | `dreamina-seedance-2-0-fast-260128` |
132+
133+
Use a model or endpoint ID provisioned for the target account if it differs
134+
from these example defaults.
135+
136+
## 7. Validate the migration
137+
138+
1. Search for the legacy dependency, package names, model imports, and generic
139+
service builder; none should remain in migrated Ark Runtime code.
140+
2. Run `mvn test` and `mvn checkstyle:check`.
141+
3. Verify one non-streaming and one streaming Chat or Responses request.
142+
4. Confirm stream text comes from deltas and typed Responses events.
143+
5. Smoke-test every built-in tool with its required beta header.
144+
6. Test CN and BytePlus independently if both are supported. Never reuse a
145+
regional key, model ID, endpoint ID, or service instance across clouds.
146+
7. Confirm `shutdownExecutor()` runs when the owning application shuts down.
147+
148+
A migration is not complete merely because the project compiles. The live
149+
stream and tool checks catch missing deltas, incorrect event casts, unsupported
150+
regional tools, and omitted headers.

0 commit comments

Comments
 (0)