# Volcengine Ark (Doubao)

[Volcengine Ark](https://www.volcengine.com/docs/82379/1298459) is ByteDance's platform for serving Doubao and other models. AISIX lets applications call those models through the gateway's OpenAI-compatible API while managing the Ark credential, caller access, rate limits, and usage accounting.

One Ark provider key can serve OpenAI-compatible Doubao chat, native Responses, native Messages and Count Tokens, and Seedance video tasks. This guide verifies the text APIs first, then reuses the provider key for [video generation](https://docs.api7.ai/ai-gateway/endpoints/video-generation.md).

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

Before starting, prepare the following:

* One AISIX setup:

  <!-- -->

  * For AISIX Enterprise or AISIX Cloud, an environment with an attached gateway and a write-scoped admin token. For AISIX Enterprise, follow the [AISIX Enterprise getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/aisix-cloud-quickstart.md). To request AISIX Cloud access, [contact API7](https://api7.ai/contact).
  * For the open-source AISIX gateway, prepare either a local AISIX installation or the Docker setup from the [AISIX OSS getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart.md). Configure the gateway to load a declarative resources file.

* An Ark API key from the [Volcengine Ark console](https://console.volcengine.com/ark).

* `curl` and `jq`.

## Configure with AISIX Enterprise or AISIX Cloud[​](#configure-with-aisix-enterprise-or-aisix-cloud "Direct link to Configure with AISIX Enterprise or AISIX Cloud")

Export the control-plane connection details:

```
# AISIX_CP is the Admin API base URL; include /api and omit a trailing slash

# The local AISIX Enterprise quickstart uses http://localhost:8080/api

export AISIX_CP="YOUR_AISIX_CONTROL_PLANE_API_URL"

export AISIX_TOKEN="YOUR_ADMIN_TOKEN"

export ENV_ID="YOUR_ENVIRONMENT_ID"
```

Create a provider key, model alias, and caller API key for Doubao text requests. The video workflow later reuses the provider key and caller key.

### Create a Provider Key[​](#create-a-provider-key "Direct link to Create a Provider Key")

Create the provider key that stores the Ark credential and API root:

```
# Replace with your value

export ARK_API_KEY="YOUR_PROVIDER_API_KEY"



PROVIDER_KEY_ID=$(curl -sS -X POST "$AISIX_CP/provider_keys" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "volcengine-prod",

    "provider": "volcengine",

    "api_key": "'"${ARK_API_KEY}"'",

    "api_base": "https://ark.cn-beijing.volces.com/api/v3",

    "apis": {

      "responses": {},

      "messages": { "base": "https://ark.cn-beijing.volces.com/api/compatible" }

    },

    "allowed_environments": ["'"${ENV_ID}"'"]

  }' | jq -r '.provider_key.id')



echo "$PROVIDER_KEY_ID"
```

❶ `provider` is `volcengine`, the provider ID the gateway's video route dispatches on. Volcengine Ark is not listed on models.dev, but this is not a community catalog entry: the gateway implements the Ark video wire natively, and the AISIX Cloud Admin API accepts the ID directly and derives the `openai` adapter for chat traffic. The `adapter` field is only accepted on BYO provider keys.

❷ `api_key` stores the Ark API key. AISIX sends it as a bearer token for the OpenAI-compatible, Responses, and video routes, and as `x-api-key` for native Messages and Count Tokens. It follows the credential-handling behavior in [Provider Keys](https://docs.api7.ai/ai-gateway/models/provider-keys.md#credential-handling).

❸ `api_base` is Ark's OpenAI-compatible base, whose version segment is `/api/v3`. AISIX appends the endpoint path to `api_base` verbatim, so this value produces `https://ark.cn-beijing.volces.com/api/v3/chat/completions`. The field is optional for this provider — when it is omitted, the AISIX Cloud Admin API fills in the same canonical value — but the examples set it explicitly so the upstream root each key targets stays visible in the configuration.

❹ `apis` enables Ark's [native Responses](https://www.volcengine.com/docs/82379/1958524?lang=zh), [Messages](https://docs.volcengine.com/docs/82379/2655179?lang=zh), and [Count Tokens](https://docs.volcengine.com/docs/82379/2655180?lang=zh) routes. Responses uses `api_base`; Messages and Count Tokens use the separate `/api/compatible` base.

The command captures the returned provider key ID in `PROVIDER_KEY_ID`.

The examples use the CN Beijing host `https://ark.cn-beijing.volces.com/api/v3`. ByteDance operates the platform's international counterpart, BytePlus ModelArk, at `https://ark.ap-southeast.bytepluses.com/api/v3` for Asia Pacific and `https://ark.eu-west.bytepluses.com/api/v3` for Europe. API keys and model availability vary by platform and region, so use the host and model ID provisioned for your account. Any Ark base ending in `/api/v3` works unchanged on the video routes, because the gateway derives the vendor root from that suffix.

BytePlus also publishes a [native Responses API](https://docs.byteplus.com/en/docs/ModelArk/Responses_API) on its OpenAI-compatible root. When adapting this example for BytePlus, keep `apis.responses`, but omit `apis.messages`. The `/api/compatible` Messages base is specific to Volcengine, and BytePlus does not currently document matching Messages and Count Tokens routes.

The `doubao-*` model IDs used below belong to Volcengine Ark. BytePlus uses different IDs for its corresponding models, so changing only `api_base` is not sufficient. Select a model ID documented for your region in the [BytePlus ModelArk documentation](https://docs.byteplus.com/en/docs/modelark/1099455) when you use a BytePlus account.

### Create a Model[​](#create-a-model "Direct link to Create a Model")

Ark model IDs combine a family name, version digits, and a release-date suffix, all separated by dashes. The example uses `doubao-seed-2-1-pro-260628`, which Volcengine documents for Responses, Messages, and Count Tokens. Ark also provisions custom inference endpoints whose IDs start with `ep-`. `model_name` accepts either form, because the gateway forwards the value verbatim as the upstream `model`. Check the [Ark model list](https://www.volcengine.com/docs/82379/1330310) for the current catalog and protocol support before creating a model alias.

Create the model alias callers will send in requests:

```
MODEL_ID=$(curl -sS -X POST "$AISIX_CP/environments/$ENV_ID/models" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "doubao-flagship-prod",

    "model_name": "doubao-seed-2-1-pro-260628",

    "provider_key_id": "'"${PROVIDER_KEY_ID}"'"

  }' | jq -r '.model.id')



echo "$MODEL_ID"
```

❶ `display_name` is the alias callers send in `model`.

❷ `model_name` is the Ark model ID, or the ID of an inference endpoint you provisioned in the Ark console, which starts with `ep-`.

❸ `provider_key_id` attaches the alias to the Ark provider key.

### Create a Caller API Key[​](#create-a-caller-api-key "Direct link to Create a Caller API Key")

Create the caller API key that can access the model alias. The plaintext key is server-generated and returned once in the response, so capture it now:

```
CALLER_KEY_RESPONSE=$(curl -sS -X POST "$AISIX_CP/environments/$ENV_ID/api_keys" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "volcengine-caller",

    "allowed_models": ["'"${MODEL_ID}"'"]

  }')



export AISIX_API_KEY=$(printf '%s' "$CALLER_KEY_RESPONSE" | jq -r '.plaintext')

CALLER_API_KEY_ID=$(printf '%s' "$CALLER_KEY_RESPONSE" | jq -r '.api_key.id')
```

The `allowed_models` value must reference the model ID captured in the previous step, so the key can only access the alias you created. The commands also retain the caller key's resource ID so you can add the video model later. After the write, the configuration projects to attached gateways automatically.

## Configure with AISIX OSS[​](#configure-with-aisix-oss "Direct link to Configure with AISIX OSS")

Export the upstream credential and choose the caller API key that applications will send to the gateway:

```
export ARK_API_KEY="YOUR_PROVIDER_API_KEY"

export CALLER_API_KEY="YOUR_CALLER_API_KEY"

export CALLER_API_KEY_SHA256="$(printf '%s' "$CALLER_API_KEY" | sha256sum | cut -d ' ' -f 1)"
```

For a new gateway, use this complete resources file. For an existing gateway, merge the entries into its [current file](https://docs.api7.ai/ai-gateway/reference/resources-file.md#apply-resource-examples-safely), preserving its other resources:

resources.yaml

```
_format_version: "2"



provider_keys:

  - id: 5bf5eda8-8c4c-4de4-9c75-3c749595a789

    display_name: "volcengine-prod"

    provider: "volcengine"

    adapter: "openai"

    api_key: ${ARK_API_KEY}

    api_base: "https://ark.cn-beijing.volces.com/api/v3"

    apis:

      responses: {}

      messages:

        base: "https://ark.cn-beijing.volces.com/api/compatible"



models:

  - id: 69f337f4-6d2b-496c-a553-83c6ab50ce52

    display_name: "doubao-flagship-prod"

    provider: "volcengine"

    model_name: "doubao-seed-2-1-pro-260628"

    provider_key_id: 5bf5eda8-8c4c-4de4-9c75-3c749595a789



api_keys:

  - id: d8361695-393a-42d9-8ae8-cf6e90651010

    display_name: "volcengine-caller"

    key_hash: ${CALLER_API_KEY_SHA256}

    allowed_models:

      - "doubao-flagship-prod"
```

If AISIX is installed locally, validate the file before loading it:

```
aisix validate --resources resources.yaml
```

After validation, start the gateway with the referenced environment variables in its process environment. Reload an existing gateway only if those variables are already available to the process; otherwise, restart it with the updated environment.

If you use Docker, adapt the validation and startup commands in the [AISIX OSS getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart.md). Mount this `resources.yaml` file and pass every environment variable it references with `-e` in both commands. After the resources load, prepare the shared verification request below:

```
export AISIX_API_KEY="$CALLER_API_KEY"
```

## Verify the Provider Connection[​](#verify-the-provider-connection "Direct link to Verify the Provider Connection")

Export the AISIX gateway origin:

```
# AISIX_PROXY has no trailing slash or endpoint path

# The local quickstarts use http://127.0.0.1:3000

export AISIX_PROXY="YOUR_AISIX_GATEWAY_URL"
```

Send a chat-completions request through the AISIX proxy:

```
curl -sS -X POST "$AISIX_PROXY/v1/chat/completions" \

  -H "Authorization: Bearer ${AISIX_API_KEY}" \

  -H "Content-Type: application/json" \

  -d '{

    "model": "doubao-flagship-prod",

    "messages": [

      {

        "role": "user",

        "content": "Say hello from Doubao."

      }

    ]

  }'
```

The gateway returns an OpenAI-compatible response that echoes the caller-facing alias `doubao-flagship-prod`. If the request fails, check the provider key `api_key`, `api_base`, and the Ark model ID in `model_name`. Ark serves models per platform and per region, so a model-not-found error from the upstream can also mean the model is not available to your account on the host `api_base` points at.

Verify native Responses forwarding with the same alias:

```
curl -sS -X POST "$AISIX_PROXY/v1/responses" \

  -H "Authorization: Bearer ${AISIX_API_KEY}" \

  -H "Content-Type: application/json" \

  -d '{

    "model": "doubao-flagship-prod",

    "input": "Say hello from the Ark Responses API."

  }'
```

The response uses Ark's native Responses format rather than the AISIX chat bridge.

Verify the separate Messages base with a Count Tokens request, which does not generate a model response:

```
curl -sS -X POST "$AISIX_PROXY/v1/messages/count_tokens" \

  -H "x-api-key: ${AISIX_API_KEY}" \

  -H "anthropic-version: 2023-06-01" \

  -H "Content-Type: application/json" \

  -d '{

    "model": "doubao-flagship-prod",

    "messages": [

      {

        "role": "user",

        "content": "Count this Ark prompt."

      }

    ]

  }'
```

A successful response contains `input_tokens`. If Chat Completions works but one of these requests fails, confirm that the model supports the requested protocol and check the corresponding `apis` declaration.

## Supply Cost Metadata[​](#supply-cost-metadata "Direct link to Supply Cost Metadata")

models.dev does not price Volcengine Ark models, so the control-plane pricing catalog carries no per-token rates for the `volcengine` provider, and the dashboard suggests no model IDs when you create an alias for it. Cost metadata for [budgets](https://docs.api7.ai/ai-gateway/traffic-controls/budgets.md) and usage reports is operator-supplied on the model alias — the same posture as [BYO endpoints](https://docs.api7.ai/ai-gateway/providers/bring-your-own-endpoint.md). Until you set rates, usage from these aliases carries no cost signal, so spend-based controls do not see this traffic.

Set the rates through [Model Pricing](https://docs.api7.ai/ai-gateway/cloud/model-pricing.md) in AISIX Enterprise or AISIX Cloud, or with the `cost` field on the model in the open-source AISIX gateway's `resources.yaml` — see [Cost Metadata](https://docs.api7.ai/ai-gateway/models/model-aliases.md#cost-metadata). Video submissions are additionally recorded with zero tokens, and duration-based cost accounting for video tasks is not yet applied to budgets.

## Generate Videos with Seedance[​](#generate-videos-with-seedance "Direct link to Generate Videos with Seedance")

The same provider key drives the gateway's modeled video routes. Create a second alias that points at a current Ark video model, such as Doubao Seedance 2.0. Check the [Ark model list](https://www.volcengine.com/docs/82379/1330310) before creating the alias because dated model IDs change as releases move through the catalog:

In AISIX Enterprise and AISIX Cloud, create the video alias:

```
VIDEO_MODEL_ID=$(curl -sS -X POST "$AISIX_CP/environments/$ENV_ID/models" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "doubao-video-prod",

    "model_name": "doubao-seedance-2-0-260128",

    "provider_key_id": "'"${PROVIDER_KEY_ID}"'"

  }' | jq -r '.model.id')



echo "$VIDEO_MODEL_ID"
```

Add the new model ID to the caller key's `allowed_models`. This field is a replacement list, so include the existing chat model ID:

```
curl -sS -X PATCH "$AISIX_CP/environments/$ENV_ID/api_keys/$CALLER_API_KEY_ID" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "allowed_models": ["'"${MODEL_ID}"'", "'"${VIDEO_MODEL_ID}"'"]

  }'
```

For the open-source AISIX gateway, add `doubao-video-prod` to the existing `models` collection. Replace the existing `volcengine-caller` entry with the updated entry below so it allows both model aliases. Preserve unrelated entries and collections:

resources.yaml (video model access)

```
models:

  - id: f1a2c1bd-bfde-4fb4-96f8-04d12477d003

    display_name: "doubao-video-prod"

    provider: "volcengine"

    model_name: "doubao-seedance-2-0-260128"

    provider_key_id: 5bf5eda8-8c4c-4de4-9c75-3c749595a789



api_keys:

  - id: d8361695-393a-42d9-8ae8-cf6e90651010

    display_name: "volcengine-caller"

    key_hash: ${CALLER_API_KEY_SHA256}

    allowed_models:

      - "doubao-flagship-prod"

      - "doubao-video-prod"
```

Validate and reload or restart the declarative resources file as described above.

Submit a video task:

```
curl -sS -X POST "$AISIX_PROXY/v1/videos" \

  -H "Authorization: Bearer ${AISIX_API_KEY}" \

  -H "Content-Type: application/json" \

  -d '{

    "model": "doubao-video-prod",

    "prompt": "A paper boat drifts down a rain-soaked street at dusk.",

    "seconds": 5

  }'
```

Five provider-specific behaviors are worth knowing before you script around this route:

* **The chat `api_base` is reused as-is.** AISIX recognizes the `/api/v3` suffix, derives the vendor root from it, and composes Ark's native task paths underneath: tasks are submitted to `POST {root}/api/v3/contents/generations/tasks` and polled at `GET {root}/api/v3/contents/generations/tasks/{id}`. A provider key already configured for Doubao chat traffic works on the video routes without change.
* **`seconds` maps to `duration`; `size` is not forwarded.** `seconds` is forwarded as the provider's integer `duration`. Ark expresses output dimensions as resolution and ratio quality tiers rather than pixel `WIDTHxHEIGHT` values, so a supplied `size` is validated for shape — a malformed value fails with `400` before the provider is contacted — but omitted from the upstream request, and the provider's default output setting applies.
* **Provider-native video fields require a passthrough route.** The normalized request models only `prompt`, `seconds`, and `size`; extra fields are ignored. To send Ark fields such as reference `content`, `resolution`, `ratio`, `generate_audio`, or `watermark`, call `/passthrough/volcengine/contents/generations/tasks` with the native Ark body and exact model ID. Poll the task at `/passthrough/volcengine/contents/generations/tasks/{id}`. Passthrough does not return the unified AISIX video object or gateway-encoded task ID. The `/passthrough/volcengine` paths on this page assume a [passthrough route](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md) claiming that prefix with Ark's API root as its `target_url`; grant the route name on the caller key's `allowed_routes`.
* **The full four-status lifecycle is reported.** AISIX maps Ark's task states onto the unified enum: `queued` reports as `queued`, `running` as `in_progress`, and `succeeded` as `completed`, while `failed`, `cancelled`, and `expired` all report as `failed` with the provider's error code and message when available. Once the task completes, the poll response also reports the actual video duration in `seconds`.
* **Finished videos are delivered by redirect.** `GET /v1/videos/{id}/content` returns `302` with a `Location` header pointing at the provider's signed download URL. The bytes travel from Ark storage to the client and do not pass through the gateway, so use `curl -L` when downloading.

For the full submit, poll, and download workflow, including status semantics and rate-limit behavior on polling, see [Video Generation](https://docs.api7.ai/ai-gateway/endpoints/video-generation.md).

## Endpoint Coverage[​](#endpoint-coverage "Direct link to Endpoint Coverage")

A Volcengine Ark provider key resolves the `openai` adapter, so route support follows that adapter plus each route's own provider rules:

| Route                                          | Behavior with a `volcengine` model alias                                                                                                                                                                                                                                                                                                                                                                                                      |
| ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/v1/chat/completions`                         | Supported, buffered and streaming.                                                                                                                                                                                                                                                                                                                                                                                                            |
| `/v1/embeddings`                               | Supported when the alias names an Ark embedding model, such as `doubao-embedding-text-240515`. AISIX appends `/embeddings` to `api_base`, reaching the provider's text-vectorization endpoint.                                                                                                                                                                                                                                                |
| `/v1/responses`                                | Sent to Ark's native Responses API because this guide declares `apis.responses`. Without the declaration, AISIX bridges Responses through chat completions. Use a model that Ark documents for Responses.                                                                                                                                                                                                                                     |
| `/v1/messages` and `/v1/messages/count_tokens` | Sent to Volcengine's native Anthropic-compatible routes because this guide declares `apis.messages`. Without the declaration, Messages is translated through chat completions and Count Tokens is unavailable. This configuration is not documented for BytePlus.                                                                                                                                                                             |
| `/v1/videos` and its status and content routes | Supported. See [Generate Videos with Seedance](#generate-videos-with-seedance).                                                                                                                                                                                                                                                                                                                                                               |
| `/v1/images/generations`                       | Not supported through the normalized route because it accepts only models whose provider is `openai` or whose provider key uses the `azure-openai` adapter (see [Provider Requirement](https://docs.api7.ai/ai-gateway/endpoints/image-generation.md#provider-requirement)). Ark exposes the same path for its image models; use `/passthrough/volcengine/images/generations` with the native request body and exact Ark model ID.            |
| `/v1/rerank`                                   | Not supported. This route accepts only the `openai`, `cohere`, and `jina` provider values.                                                                                                                                                                                                                                                                                                                                                    |
| `/v1/models`                                   | Returns caller-accessible AISIX aliases, not the Ark catalog. Consult the Ark console or model list linked above for available provider model IDs.                                                                                                                                                                                                                                                                                            |
| `/passthrough/volcengine/*rest`                | Available through a configured [passthrough route](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md) for provider-native APIs that AISIX has not modeled. Passthrough does not rewrite AISIX aliases and relays SSE incrementally. For the request shapes that record token usage, see [Envelope Detection and Usage](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md#envelope-detection-and-token-usage). |

See [Provider Compatibility](https://docs.api7.ai/ai-gateway/providers/compatibility.md) for the full endpoint and provider matrix.

## Next Steps[​](#next-steps "Direct link to Next Steps")

You have now connected AISIX to Volcengine Ark and verified the model alias. Continue with these guides:

* [Model Aliases](https://docs.api7.ai/ai-gateway/models/model-aliases.md): configure routing, retry behavior, or cost metadata for this alias.
* [Model Pricing](https://docs.api7.ai/ai-gateway/cloud/model-pricing.md): set the operator-supplied per-token rates that budgets and usage reports need for this provider.
* [Video Generation](https://docs.api7.ai/ai-gateway/endpoints/video-generation.md): follow the full submit, poll, and download workflow for Seedance tasks.
* [Provider Compatibility](https://docs.api7.ai/ai-gateway/providers/compatibility.md): review supported proxy endpoints and provider-specific boundaries.
