Runnable examples for the ark-runtime-java SDK. Set ARK_API_KEY and, for most examples, ARK_MODEL to a model ID available in your account.
export ARK_API_KEY=...
export ARK_MODEL=...
mvn -q -DskipTests install
mvn -q -f examples/volc/pom.xml compile exec:java \
-Dexec.mainClass=com.volcengine.ark.runtime.examples.volc.CreateResponseExampleRun mvn -q -DskipTests install at the repository root first so the example modules can resolve the ark-runtime jar from your local Maven cache. Replace volc with byteplus in the path and main-class package to run the BytePlus version.
All service-calling examples are grouped by cloud:
com.volcengine.ark.runtime.examples.volcusesArkService.volc()and Volcengine China model IDs.com.volcengine.ark.runtime.examples.byteplususesArkService.byteplus()and BytePlus model IDs.
com.volcengine.ark.runtime.examples.volc.SelfHostedWorkerExample demonstrates the Managed-Agents self-hosted worker poll/handle loop and uses the client's production default https://ark.cn-beijing.volces.com/api/v3.
The paired multimodal and sparse embedding examples default to doubao-embedding-vision-251215 / skylark-embedding-vision-251215. The paired image examples default to doubao-seedream-5-0-pro-260628 / dola-seedream-5-0-pro-260628. The paired video-generation examples default to doubao-seedance-2-0-fast-260128 / dreamina-seedance-2-0-fast-260128.
MCP is available in both clouds and its calls explicitly send ark-beta-mcp: true. Other built-in tools are CN-only: Knowledge Search sends ark-beta-knowledge-search: true, and Doubao App sends ark-beta-doubao-app: true.
AudioGenerationExample is available in both cloud packages. It calls
service.generateAudio(request) synchronously: there is no task creation,
polling, or streaming for this endpoint. It is separate from the video task API.
Use API-key authentication (ARK_API_KEY), not AK/SK, and set ARK_MODEL to an
audio model or endpoint enabled for your account, region, and selected scene.
The examples do not assume a default model or guarantee availability in every region.
Choose exactly one scene as a command-line argument. No argument prints usage
without making a request; a valid invocation makes one potentially billable
generation call, not all four. In addition to ARK_API_KEY and ARK_MODEL, set:
| Scene argument | Environment variables | Request |
|---|---|---|
text |
ARK_AUDIO_TEXT |
Text-only audio generation |
reference |
ARK_AUDIO_TEXT, ARK_REFERENCE_AUDIO_URL |
Text plus reference_audio |
separate |
ARK_AUDIO_TEXT, ARK_SOURCE_AUDIO_URL |
Separation instruction plus separate_audio |
dubbing |
ARK_SOURCE_VIDEO_URL, ARK_TARGET_LANGUAGE |
One dubbing_video and target language, such as en; no text |
Use media URLs accessible to the service and only media you have permission to
process. Dubbing detects the source language automatically. These examples omit
watermark, optional artifacts, and speech adjustments; returned artifacts are in
response.getContent(), and generation duration is in response.getUsage().
Build this SDK checkout first. The audio example uses its new models and method,
so override the example module's older default SDK version with this checkout's
version (0.11.0); this is a local-build instruction, not a publication claim.
mvn -q -DskipTests install
# Set ARK_API_KEY and ARK_MODEL securely, then provide the selected scene's inputs.
export ARK_AUDIO_TEXT='Read this sentence in a calm, clear voice.'
mvn -q -f examples/volc/pom.xml -Dark-runtime.version=0.11.0 compile exec:java \
-Dexec.mainClass=com.volcengine.ark.runtime.examples.volc.AudioGenerationExample \
-Dexec.args=textReplace volc with byteplus in both the POM path and main class for BytePlus.
Change -Dexec.args to the desired scene and supply its inputs from the table.
Each example releases the client's executor in a finally block.
self_hosted_mcp_worker/ demonstrates how to discover tools from a local stdio MCP server, convert them into Agent custom tool declarations, and execute them through the self-hosted worker.
To compile both cloud example modules without making API calls, run from the repository root:
mvn -q -DskipTests install
mvn -q -f examples/volc/pom.xml clean compile
mvn -q -f examples/byteplus/pom.xml clean compileThe cloud example POMs default to SDK 0.8.0. To check another locally installed SDK version, pass -Dark-runtime.version=<version> to each example Maven command.