# Create an environment that stores outputs in your TOS bucket.
curl -sS --fail-with-body "https://ark.cn-beijing.volces.com/api/v3/environments" \
-H "Authorization: Bearer $ARK_API_KEY" \
-H "Content-Type: application/json" \
"name": "<ENVIRONMENT_NAME>",
"bucket": "<TOS_BUCKET>",
ENVIRONMENT_ID=$(jq -er '.id' <<<"$environment")
echo "Environment ID: $ENVIRONMENT_ID"
# Example output: Environment ID: env-20260723142038-xxxxx
# Replace the output storage configuration for future sessions.
curl -sS --fail-with-body "https://ark.cn-beijing.volces.com/api/v3/environments/$ENVIRONMENT_ID" \
-H "Authorization: Bearer $ARK_API_KEY" \
-H "Content-Type: application/json" \
"bucket": "<NEW_TOS_BUCKET>",
jq '{id, tos: .config.tos}' <<<"$updated_environment"
# "id": "env-20260723142038-xxxxx",
# "tos": {"bucket": "<NEW_TOS_BUCKET>", "prefix": "new-prefix/"}
# Clear the configuration so future sessions use the default storage.
curl -sS --fail-with-body "https://ark.cn-beijing.volces.com/api/v3/environments/$ENVIRONMENT_ID" \
-H "Authorization: Bearer $ARK_API_KEY" \
-H "Content-Type: application/json" \
jq '{id, tos: (.config.tos // null)}' <<<"$cleared_environment"
# "id": "env-20260723142038-xxxxx",