即梦ai 火山方舟api调用踩坑实战
2026/7/7 8:41:46
网站开发
目录doubao-seedream-5-0-260128 调用代码doubao-seedream-4-5-251128 调研代码图生3d测试文生3d资产火山方舟apihttps://console.volcengine.com/ark/region:arkcn-beijing/apikeyhttps://console.volcengine.com/ark/region:cn-beijing/docs/82379/1399008?langzh查看api key点击眼睛doubao-seedream-5-0-260128 调用代码import time # Install SDK: pip install volcengine-python-sdk[ark] . from volcenginesdkarkruntime import Ark client Ark( base_urlhttps://ark.cn-beijing.volces.com/api/v3, # Get API Keyhttps://console.volcengine.com/ark/region:arkcn-beijing/apikey api_keyapi_key) prompt_str Pop Mart blind box style turnaround sheet of a kawaii chibi figure wearing a bear onesie, multi-angle views (front, side, back, high/low angle), dark grey studio background, soft diffused lighting, smooth matte vinyl toy texture, strictly divided 4-color scheme for detachable modular parts, each component uses a single solid color: 1. golden yellow main bear suit, 2. ivory white paw cuffs, 3. bright orange backpack, 4. light pink cloak, smooth surface, gradient orange tips on the ears and feet, bear-shaped hood with rounded ears and cute snout, character with big sparkling eyes, pink blush, tiny pout expression, white paw cuffs, chibi proportions, ultra cute and cuddly vibe, equipped with a detachable mini backpack mounted on the back, plus a separate independent detachable cloak, all accessories and body parts are fully modular and removable accessories, clean product shot, high detail, smooth shadows, hyper-detailed sculpt details --ar 16:9 --style expressive --v 6.0 prompt_str turnaround character sheet of an ultra-cute chubby and dull-witted designer toy shark figure, extra soft and naive facial expression, cuter dumb squinted round eyes to boost呆萌 vibe, 8 orthographic views (front, 3/4, side, back, top, bottom), neutral dark grey seamless studio background, soft gentle rim lighting, PBR high-quality vinyl toy texture, smooth glossy finish, super chubby round plump body with no sharp edges, exaggerated friendly gentle grin with huge oversized fully detachable teeth (each tooth independent and removable separately), bold clean color blocking with 4 distinct vibrant colors assigned to separate modular parts: 1. rich ocean blue for upper body/back, 2. clean cloud white for underbelly, 3. soft coral orange for inner mouth/gums, 4. bright bone white for extra large teeth, simplified soft gill slits without sharp lines, a short cute solid color cloak attached to the sharks back, a mini compact modular backpack fixed firmly on the outer surface of the cloak, no shoulder straps at all, no straps looping over shoulders, no shoulder-mounted parts, backpack completely integrated and fixed on the cloak only, no extra hanging straps, product photography style, hyper-realistic delicate vinyl textures, ultra sharp clean details, soft diffused clean shadows, full clear turnaround display for all angles, no messy background elements --ar 16:9 --style expressive --v 6.0 model_namedoubao-seedream-5-0-260128 size2K starttime.time() imagesResponse client.images.generate( modelmodel_name, promptprompt_str, sizesize, output_formatpng, response_formaturl, watermarkFalse) print(imagesResponse.data[0].url) print(time,time.time()-start)doubao-seedream-4-5-251128 调研代码import time import requests from volcenginesdkarkruntime import Ark client Ark(base_urlhttps://ark.cn-beijing.volces.com/api/v3, api_keyapi_key) model_name doubao-seedream-4-5-251128 start time.time() prompt_str turnaround character sheet of an ultra-cute chubby and dull-witted designer toy shark figure, extra soft and naive facial expression, cuter dumb squinted round eyes to boost呆萌 vibe, 8 orthographic views (front, 3/4, side, back, top, bottom), neutral dark grey seamless studio background, soft gentle rim lighting, PBR high-quality vinyl toy texture, smooth glossy finish, super chubby round plump body with no sharp edges, exaggerated friendly gentle grin with huge oversized fully detachable teeth (each tooth independent and removable separately), bold clean color blocking with 4 distinct vibrant colors assigned to separate modular parts: 1. rich ocean blue for upper body/back, 2. clean cloud white for underbelly, 3. soft coral orange for inner mouth/gums, 4. bright bone white for extra large teeth, simplified soft gill slits without sharp lines, a short cute solid color cloak attached to the sharks back, a mini compact modular backpack fixed firmly on the outer surface of the cloak, no shoulder straps at all, no straps looping over shoulders, no shoulder-mounted parts, backpack completely integrated and fixed on the cloak only, no extra hanging straps, product photography style, hyper-realistic delicate vinyl textures, ultra sharp clean details, soft diffused clean shadows, full clear turnaround display for all angles, no messy background elements --ar 16:9 --style expressive --v 6.0 size1920x1920 try: imagesResponse client.images.generate(modelmodel_name, promptprompt_str, sizesize, watermarkFalse) if imagesResponse.data and len(imagesResponse.data) 0: image_url imagesResponse.data[0].url print(f生成图片URL: {image_url}) # 下载图片 img_data requests.get(image_url).content with open(fimage_{int(time.time())}.png, wb) as f: f.write(img_data) print(图片已保存) else: print(未生成图片) except Exception as e: print(f生成失败: {e}) print(f耗时: {time.time() - start:.2f}秒)图生3d测试Doubao-Seed3D-2.0 不支持多图直接生成一个3D模型文生3d资产import requests import json import os import time from typing import Optional, Dict, Any import requests import json import time api_key ark-223393fc-e15e-4c15-bf56-702dc71dc85f-8b7fc url https://ark.cn-beijing.volces.com/api/v3/contents/generations/tasks headers {Content-Type: application/json, Authorization: fBearer {api_key}} payload {model: hyper3d-gen2-260112, content: [{type: text, # text: Complete full-body quadrupedal mech robot, orange and black armored, rounded head with glowing blue sensors, 4 articulated mechanical legs, hard-surface sci-fi design, high-detail joints, photorealistic 8K, fully assembled, no missing parts. --mesh_mode Raw --hd_texture true --material PBR --addons HighPack --quality_override 1000000 --use_original_alpha false --bbox_condition [100,100,100] --TAPose false}]} text: Pop Mart blind box style kawaii chibi figure wearing a bear onesie, multi-angle turnaround sheet (front, 3/4, side, back, top, bottom views), dark grey seamless studio background, soft diffused lighting, smooth matte vinyl toy texture. Strictly divided 4-color scheme for detachable modular parts, each component uses a single solid color: 1. marigold yellow for main bear suit, 2. ivory white for paw cuffs, 3. bright orange for mini backpack, 4. light pink for cloak. Smooth surface with orange gradient tips on ears and feet. Bear-shaped hood with rounded ears and cute snout, character with big sparkling eyes, pink blush, pout expression, chibi proportions, ultra cute and cuddly vibe. Detachable mini backpack mounted on the back, plus independent detachable cloak, all accessories and body parts fully modular and removable. Clean product photography style, high detail, smooth shadows, hyper-detailed sculpt. --mesh_mode Raw --hd_texture true --material PBR --addons HighPack --quality_override 1000000 --use_original_alpha false --bbox_condition [100,100,100] --TAPose false}]} # 提交任务 response requests.post(url, headersheaders, jsonpayload) response.raise_for_status() task_result response.json() task_id task_result.get(id) # 或者根据实际返回字段调整 print(f任务已提交ID: {task_id}) # 轮询任务状态如果需要 status_url fhttps://ark.cn-beijing.volces.com/api/v3/contents/generations/tasks/{task_id} while True: status_response requests.get(status_url, headersheaders) status_data status_response.json() status status_data.get(status) print(f当前状态: {status}) if status in [completed, succeeded, failed]: break time.sleep(2) # 等待2秒后再次查询 print(最终结果:) print(json.dumps(status_data, indent2, ensure_asciiFalse))